List<ProducerBatch> expiredBatches = this.accumulator.expiredBatches(now); expiredBatches.addAll(expiredInflightBatches);
assertEquals("Our partition's leader should be ready", Collections.singleton(node1), readyNodes); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch should not expire when just linger has passed", 0, expiredBatches.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch may expire when the partition is muted", 1, expiredBatches.size()); assertEquals("No partitions should be ready.", 0, accum.ready(cluster, time.milliseconds()).readyNodes.size());
expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("RecordAccumulator has expired batches if the partition is not muted", mute ? 1 : 0, expiredBatches.size());
List<ProducerBatch> expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batches will be muted no matter if the partition is muted or not", 2, expiredBatches.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("All batches should have been expired earlier", 0, expiredBatches.size()); assertEquals("No partitions should be ready.", 0, accum.ready(cluster, time.milliseconds()).readyNodes.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch should not be expired when metadata is still available and partition is muted", 0, expiredBatches.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("All batches should have been expired", 0, expiredBatches.size()); assertEquals("No partitions should be ready.", 0, accum.ready(cluster, time.milliseconds()).readyNodes.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch should not be expired.", 0, expiredBatches.size()); time.sleep(1L); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch should not be expired when the partition is muted", 0, expiredBatches.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("All batches should have been expired.", 0, expiredBatches.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch should not be expired when the partition is muted", 0, expiredBatches.size()); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("The batch should not be expired when the partition is muted", 0, expiredBatches.size());