jsancio commented on a change in pull request #9819:
URL: https://github.com/apache/kafka/pull/9819#discussion_r561427699
##########
File path:
raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java
##########
@@ -53,13 +56,20 @@ public long sizeInBytes() throws IOException {
}
@Override
- public void append(ByteBuffer buffer) throws IOException {
+ public void append(BaseRecords records) throws IOException {
if (frozen) {
throw new IllegalStateException(
- String.format("Append is not supported. Snapshot is already
frozen: id = %s; temp path = %s", snapshotId, tempSnapshotPath)
+ String.format("Append is not supported. Snapshot is
already frozen: id = %s; temp path = %s", snapshotId, tempSnapshotPath)
);
}
-
+ ByteBuffer buffer;
+ if (records instanceof MemoryRecords) {
+ buffer = ((MemoryRecords) records).buffer();
+ } else {
+ buffer = ByteBuffer.allocate(records.sizeInBytes());
+ ((FileRecords) records).channel().read(buffer);
+ buffer.flip();
+ }
Review comment:
> I change the signature to keep consistent with FileRawSnapshotReader
Okay. I think this is something that I struggled with when creating the
original APIs. I am okay with "inconsistent" APIs since
`RawSnapshot{Reader,Writer}` are internal interfaces to the raft client and are
not exposed to the state machine (controller).
I think this "inconsistency" will go away when we implement the long term
solution.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]