Search in sources :

Example 6 with TestingResultPartitionManager

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());
}
Also used : ResultSubpartitionView(org.apache.flink.runtime.io.network.partition.ResultSubpartitionView) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) TestingResultPartitionManager(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager) Test(org.junit.Test)

Example 7 with TestingResultPartitionManager

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());
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) BufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferConsumer) BufferBuilderTestUtils.createFilledFinishedBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) TestingResultPartitionManager(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager) Test(org.junit.Test)

Example 8 with TestingResultPartitionManager

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)));
}
Also used : PipelinedResultPartition(org.apache.flink.runtime.io.network.partition.PipelinedResultPartition) ResultSubpartition(org.apache.flink.runtime.io.network.partition.ResultSubpartition) ResultPartitionBuilder(org.apache.flink.runtime.io.network.partition.ResultPartitionBuilder) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) TestingResultPartitionManager(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager) Test(org.junit.Test)

Example 9 with TestingResultPartitionManager

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());
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) PipelinedResultPartition(org.apache.flink.runtime.io.network.partition.PipelinedResultPartition) ResultSubpartitionView(org.apache.flink.runtime.io.network.partition.ResultSubpartitionView) ResultSubpartition(org.apache.flink.runtime.io.network.partition.ResultSubpartition) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) TestingResultPartitionManager(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager) Test(org.junit.Test)

Aggregations

TestingResultPartitionManager (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager)9 Test (org.junit.Test)9 InputChannelTestUtils.createLocalInputChannel (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel)8 ResultSubpartitionView (org.apache.flink.runtime.io.network.partition.ResultSubpartitionView)5 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)3 InputChannelTestUtils.createSingleInputGate (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate)3 PipelinedResultPartition (org.apache.flink.runtime.io.network.partition.PipelinedResultPartition)3 ResultSubpartition (org.apache.flink.runtime.io.network.partition.ResultSubpartition)3 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 CancelTaskException (org.apache.flink.runtime.execution.CancelTaskException)1 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)1 BufferBuilderTestUtils.createFilledFinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer)1 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)1 NoOpResultSubpartitionView (org.apache.flink.runtime.io.network.partition.NoOpResultSubpartitionView)1 ResultPartitionBuilder (org.apache.flink.runtime.io.network.partition.ResultPartitionBuilder)1 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)1 CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)1