accum.mutePartition(tp1); else accum.unmutePartition(tp1, 0L);
@Test public void testMutedPartitions() throws InterruptedException { long now = time.milliseconds(); // test case assumes that the records do not fill the batch completely int batchSize = 1025; RecordAccumulator accum = createTestRecordAccumulator( batchSize + DefaultRecordBatch.RECORD_BATCH_OVERHEAD, 10 * batchSize, CompressionType.NONE, 10); int appends = expectedNumAppends(batchSize); for (int i = 0; i < appends; i++) { accum.append(tp1, 0L, key, value, Record.EMPTY_HEADERS, null, maxBlockTimeMs); assertEquals("No partitions should be ready.", 0, accum.ready(cluster, now).readyNodes.size()); } time.sleep(2000); // Test ready with muted partition accum.mutePartition(tp1); RecordAccumulator.ReadyCheckResult result = accum.ready(cluster, time.milliseconds()); assertEquals("No node should be ready", 0, result.readyNodes.size()); // Test ready without muted partition accum.unmutePartition(tp1, 0L); result = accum.ready(cluster, time.milliseconds()); assertTrue("The batch should be ready", result.readyNodes.size() > 0); // Test drain with muted partition accum.mutePartition(tp1); Map<Integer, List<ProducerBatch>> drained = accum.drain(cluster, result.readyNodes, Integer.MAX_VALUE, time.milliseconds()); assertEquals("No batch should have been drained", 0, drained.get(node1.id()).size()); // Test drain without muted partition. accum.unmutePartition(tp1, 0L); drained = accum.drain(cluster, result.readyNodes, Integer.MAX_VALUE, time.milliseconds()); assertTrue("The batch should have been drained.", drained.get(node1.id()).size() > 0); }
accum.mutePartition(tp1); else accum.unmutePartition(tp1, 0L);
this.accumulator.unmutePartition(batch.topicPartition, throttleUntilTimeMs);
assertEquals("The batches will be muted no matter if the partition is muted or not", 2, expiredBatches.size()); accum.unmutePartition(tp1, 0L); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("All batches should have been expired earlier", 0, expiredBatches.size()); assertEquals("The batch should not be expired when metadata is still available and partition is muted", 0, expiredBatches.size()); accum.unmutePartition(tp1, 0L); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("All batches should have been expired", 0, expiredBatches.size()); assertEquals("The batch should not be expired when the partition is muted", 0, expiredBatches.size()); accum.unmutePartition(tp1, 0L); expiredBatches = accum.expiredBatches(time.milliseconds()); assertEquals("All batches should have been expired.", 0, expiredBatches.size()); accum.unmutePartition(tp1, time.milliseconds() + throttleTimeMs);