jsancio commented on code in PR #15671:
URL: https://github.com/apache/kafka/pull/15671#discussion_r1586489784


##########
clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java:
##########
@@ -807,4 +809,62 @@ private static void writeSnapshotFooterRecord(
             builder.appendSnapshotFooterMessage(timestamp, 
snapshotFooterRecord);
         }
     }
+
+    public static MemoryRecords withKRaftVersionRecord(
+        long initialOffset,
+        long timestamp,
+        int leaderEpoch,
+        ByteBuffer buffer,
+        KRaftVersionRecord kraftVersionRecord
+    ) {
+        writeKRaftVersionRecord(buffer, initialOffset, timestamp, leaderEpoch, 
kraftVersionRecord);
+        buffer.flip();
+        return MemoryRecords.readableRecords(buffer);
+    }
+
+    private static void writeKRaftVersionRecord(
+        ByteBuffer buffer,
+        long initialOffset,
+        long timestamp,
+        int leaderEpoch,
+        KRaftVersionRecord kraftVersionRecord
+    ) {
+        try (MemoryRecordsBuilder builder = new MemoryRecordsBuilder(
+            buffer, RecordBatch.CURRENT_MAGIC_VALUE, CompressionType.NONE,
+            TimestampType.CREATE_TIME, initialOffset, timestamp,
+            RecordBatch.NO_PRODUCER_ID, RecordBatch.NO_PRODUCER_EPOCH, 
RecordBatch.NO_SEQUENCE,
+            false, true, leaderEpoch, buffer.capacity())
+        ) {
+            builder.appendKRaftVersionMessage(timestamp, kraftVersionRecord);
+        }
+    }
+
+    public static MemoryRecords withVotersRecord(
+        long initialOffset,
+        long timestamp,
+        int leaderEpoch,
+        ByteBuffer buffer,
+        VotersRecord votersRecord
+    ) {
+        writeVotersRecord(buffer, initialOffset, timestamp, leaderEpoch, 
votersRecord);

Review Comment:
   Yeah. I see that. Looks like this is an existing issue with existing control 
record builders. Let me fix the ones that are specific for KRaft. We can fix 
the other ones in another PR.



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to