use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager in project flink by apache.
the class LocalInputChannelTest method testGetBufferFromLocalChannelWhenCompressionEnabled.
/**
* Verifies that buffer is not compressed when getting from a {@link LocalInputChannel}.
*/
@Test
public void testGetBufferFromLocalChannelWhenCompressionEnabled() throws Exception {
ResultSubpartitionView subpartitionView = InputChannelTestUtils.createResultSubpartitionView(true);
TestingResultPartitionManager partitionManager = new TestingResultPartitionManager(subpartitionView);
LocalInputChannel channel = createLocalInputChannel(new SingleInputGateBuilder().build(), partitionManager);
// request partition and get next buffer
channel.requestSubpartition();
Optional<InputChannel.BufferAndAvailability> bufferAndAvailability = channel.getNextBuffer();
assertTrue(bufferAndAvailability.isPresent());
assertFalse(bufferAndAvailability.get().buffer().isCompressed());
}
use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager in project flink by apache.
the class LocalInputChannelTest method testNoDataPersistedAfterReceivingAlignedBarrier.
@Test
public void testNoDataPersistedAfterReceivingAlignedBarrier() throws Exception {
CheckpointBarrier barrier = new CheckpointBarrier(1L, 0L, CheckpointOptions.alignedWithTimeout(CheckpointType.CHECKPOINT, getDefault(), 123L));
BufferConsumer barrierHolder = EventSerializer.toBufferConsumer(barrier, false);
BufferConsumer data = createFilledFinishedBufferConsumer(1);
RecordingChannelStateWriter stateWriter = new RecordingChannelStateWriter();
LocalInputChannel channel = InputChannelBuilder.newBuilder().setPartitionManager(new TestingResultPartitionManager(InputChannelTestUtils.createResultSubpartitionView(barrierHolder, data))).setStateWriter(stateWriter).buildLocalChannel(new SingleInputGateBuilder().build());
channel.requestSubpartition();
// pull AC barrier
channel.getNextBuffer();
// pretend that alignment timed out
stateWriter.start(barrier.getId(), barrier.getCheckpointOptions());
channel.checkpointStarted(barrier);
// pull data
channel.getNextBuffer();
assertTrue("no data should be persisted after receiving a barrier", stateWriter.getAddedInput().isEmpty());
}
use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager in project flink by apache.
the class LocalInputChannelTest method testAnnounceNewBufferSize.
@Test
public void testAnnounceNewBufferSize() throws IOException, InterruptedException {
// given: Configured LocalInputChannel and pipelined subpartition.
PipelinedResultPartition parent = (PipelinedResultPartition) new ResultPartitionBuilder().setResultPartitionType(ResultPartitionType.PIPELINED).setFileChannelManager(NoOpFileChannelManager.INSTANCE).setNumberOfSubpartitions(2).build();
ResultSubpartition subpartition0 = parent.getAllPartitions()[0];
ResultSubpartition subpartition1 = parent.getAllPartitions()[1];
LocalInputChannel channel0 = createLocalInputChannel(new SingleInputGateBuilder().build(), new TestingResultPartitionManager(subpartition0.createReadView(() -> {
})));
LocalInputChannel channel1 = createLocalInputChannel(new SingleInputGateBuilder().build(), new TestingResultPartitionManager(subpartition1.createReadView(() -> {
})));
channel0.requestSubpartition();
channel1.requestSubpartition();
// and: Preferable buffer size is default value.
assertEquals(Integer.MAX_VALUE, subpartition0.add(createFilledFinishedBufferConsumer(16)));
assertEquals(Integer.MAX_VALUE, subpartition1.add(createFilledFinishedBufferConsumer(16)));
// when: Announce the different buffer size for different channels via LocalInputChannel.
channel0.announceBufferSize(9);
channel1.announceBufferSize(20);
// then: The corresponded subpartitions have the new size.
assertEquals(9, subpartition0.add(createFilledFinishedBufferConsumer(16)));
assertEquals(20, subpartition1.add(createFilledFinishedBufferConsumer(16)));
}
use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager in project flink by apache.
the class LocalInputChannelTest method testEnqueueAvailableChannelWhenResuming.
@Test
public void testEnqueueAvailableChannelWhenResuming() throws IOException, InterruptedException {
PipelinedResultPartition parent = (PipelinedResultPartition) PartitionTestUtils.createPartition(ResultPartitionType.PIPELINED, NoOpFileChannelManager.INSTANCE);
ResultSubpartition subpartition = parent.getAllPartitions()[0];
ResultSubpartitionView subpartitionView = subpartition.createReadView(() -> {
});
TestingResultPartitionManager partitionManager = new TestingResultPartitionManager(subpartitionView);
LocalInputChannel channel = createLocalInputChannel(new SingleInputGateBuilder().build(), partitionManager);
channel.requestSubpartition();
// Block the subpartition
subpartition.add(EventSerializer.toBufferConsumer(new CheckpointBarrier(1, 1, CheckpointOptions.forCheckpointWithDefaultLocation()), false));
assertTrue(channel.getNextBuffer().isPresent());
// Add more data
subpartition.add(createFilledFinishedBufferConsumer(4096));
subpartition.flush();
// No buffer since the subpartition is blocked.
assertFalse(channel.inputGate.pollNext().isPresent());
// Resumption makes the subpartition available.
channel.resumeConsumption();
Optional<BufferOrEvent> nextBuffer = channel.inputGate.pollNext();
assertTrue(nextBuffer.isPresent());
assertTrue(nextBuffer.get().isBuffer());
}
Aggregations