jsancio commented on code in PR #18956:
URL: https://github.com/apache/kafka/pull/18956#discussion_r1965933312
##########
raft/src/test/java/org/apache/kafka/raft/internals/BatchAccumulatorTest.java:
##########
@@ -102,6 +102,35 @@ public void testLeaderChangeMessageWritten() {
Mockito.verify(memoryPool).release(buffer);
}
+ @Test
+ public void testKRaftVersionRecordWritten() {
+ int leaderEpoch = 17;
+ long baseOffset = 0;
+ int lingerMs = 50;
+ int maxBatchSize = 512;
+
+ ByteBuffer buffer = ByteBuffer.allocate(maxBatchSize);
+ Mockito.when(memoryPool.tryAllocate(maxBatchSize))
+ .thenReturn(buffer);
+
+ BatchAccumulator<String> acc = buildAccumulator(
+ leaderEpoch,
+ baseOffset,
+ lingerMs,
+ maxBatchSize
+ );
Review Comment:
We indent by 4 spaces in Java code.
```java
Mockito.when(memoryPool.tryAllocate(maxBatchSize))
.thenReturn(buffer);
BatchAccumulator<String> acc = buildAccumulator(
leaderEpoch,
baseOffset,
lingerMs,
maxBatchSize
);
```
##########
raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java:
##########
@@ -354,6 +355,27 @@ public void appendLeaderChangeMessage(
);
}
+ /**
+ * Append a {@link KRaftVersionRecord} record to the batch
+ *
+ * @param kraftVersionRecord The message to append
+ * @param currentTimestamp The current time in milliseconds
+ * @throws IllegalStateException on failure to allocate a buffer for the
record
+ */
+ public void appendKRaftVersionRecord(
+ KRaftVersionRecord kraftVersionRecord,
+ long currentTimestamp
+ ) {
Review Comment:
We indent by 4 spaces in Java code.
```java
public void appendKRaftVersionRecord(
KRaftVersionRecord kraftVersionRecord,
long currentTimestamp
) {
```
##########
raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java:
##########
@@ -354,6 +355,27 @@ public void appendLeaderChangeMessage(
);
}
+ /**
+ * Append a {@link KRaftVersionRecord} record to the batch
+ *
+ * @param kraftVersionRecord The message to append
+ * @param currentTimestamp The current time in milliseconds
+ * @throws IllegalStateException on failure to allocate a buffer for the
record
+ */
+ public void appendKRaftVersionRecord(
+ KRaftVersionRecord kraftVersionRecord,
+ long currentTimestamp
+ ) {
+ appendControlMessages((baseOffset, epoch, compression, buffer) ->
+ MemoryRecords.withKRaftVersionRecord(
+ baseOffset,
+ currentTimestamp,
+ epoch,
+ buffer,
+ kraftVersionRecord
+ )
+ );
Review Comment:
We indent by 4 spaces in Java code.
```java
appendControlMessages((baseOffset, epoch, compression, buffer) ->
MemoryRecords.withKRaftVersionRecord(
baseOffset,
currentTimestamp,
epoch,
buffer,
kraftVersionRecord
)
);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]