ruanliang-hualun commented on code in PR #12092:
URL: https://github.com/apache/kafka/pull/12092#discussion_r857058649
##########
clients/src/test/java/org/apache/kafka/clients/producer/internals/RecordAccumulatorTest.java:
##########
@@ -142,15 +144,26 @@ public void testDrainBatches() throws Exception {
// drain batches from 2 nodes: node1 => tp2, node2 => tp3 (because tp4
is muted)
Map<Integer, List<ProducerBatch>> batches4 = accum.drain(cluster, new
HashSet<Node>(Arrays.asList(node1, node2)), (int) batchSize, 0);
verifyTopicPartitionInBatches(batches4, tp2, tp3);
+
+
+ // add record for tp1, tp2, tp3, and unmute tp4
+ accum.append(tp1, 0L, key, value, Record.EMPTY_HEADERS, null,
maxBlockTimeMs, false, time.milliseconds());
+ accum.append(tp2, 0L, key, value, Record.EMPTY_HEADERS, null,
maxBlockTimeMs, false, time.milliseconds());
+ accum.append(tp3, 0L, key, value, Record.EMPTY_HEADERS, null,
maxBlockTimeMs, false, time.milliseconds());
+ accum.unmutePartition(tp4);
+ // set maxSize as a max value, so that the all partitions in 2 nodes
should be drained: node1 => [tp1, tp2], node2 => [tp3, tp4]
+ Map<Integer, List<ProducerBatch>> batches5 = accum.drain(cluster, new
HashSet<Node>(Arrays.asList(node1, node2)), Integer.MAX_VALUE, 0);
+ verifyTopicPartitionInBatches(batches5, tp1, tp2, tp3, tp4);
}
- private void verifyTopicPartitionInBatches(Map<Integer,
List<ProducerBatch>> batches, TopicPartition... tp) {
- assertEquals(tp.length, batches.size());
+ private void verifyTopicPartitionInBatches(Map<Integer,
List<ProducerBatch>> nodeBatches, TopicPartition... tp) {
+ int allTpBatchCount =
nodeBatches.values().stream().flatMap(Collection::stream).collect(Collectors.toList()).size();
Review Comment:
allTpBatchCount represent the count of the producerbatch from the
nodeBatches map
--
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]