Search in sources :

Example 41 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate in project flink by apache.

the class UnalignedCheckpointsCancellationTest method test.

@Test
public void test() throws Exception {
    TestInvokable invokable = new TestInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(numChannels).setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    SingleCheckpointBarrierHandler unaligner = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    for (RuntimeEvent e : events) {
        if (e instanceof CancelCheckpointMarker) {
            unaligner.processCancellationBarrier((CancelCheckpointMarker) e, new InputChannelInfo(0, channel));
        } else if (e instanceof CheckpointBarrier) {
            unaligner.processBarrier((CheckpointBarrier) e, new InputChannelInfo(0, channel), false);
        } else {
            throw new IllegalArgumentException("unexpected event type: " + e);
        }
    }
    assertEquals("expectAbortCheckpoint", expectAbortCheckpoint, invokable.checkpointAborted);
    assertEquals("expectTriggerCheckpoint", expectTriggerCheckpoint, invokable.checkpointTriggered);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) CancelCheckpointMarker(org.apache.flink.runtime.io.network.api.CancelCheckpointMarker) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) RuntimeEvent(org.apache.flink.runtime.event.RuntimeEvent) Test(org.junit.Test)

Example 42 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate in project flink by apache.

the class UnalignedCheckpointsTest method testProcessCancellationBarrierBeforeProcessAndReceiveBarrier.

@Test
public void testProcessCancellationBarrierBeforeProcessAndReceiveBarrier() throws Exception {
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    handler.processCancellationBarrier(new CancelCheckpointMarker(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0));
    verifyTriggeredCheckpoint(handler, invokable, DEFAULT_CHECKPOINT_ID);
    // it would not trigger checkpoint since the respective cancellation barrier already
    // happened before
    handler.processBarrier(buildCheckpointBarrier(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0), false);
    verifyTriggeredCheckpoint(handler, invokable, DEFAULT_CHECKPOINT_ID);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) CancelCheckpointMarker(org.apache.flink.runtime.io.network.api.CancelCheckpointMarker) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 43 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate in project flink by apache.

the class UnalignedCheckpointsTest method testProcessCancellationBarrierAfterProcessBarrier.

/**
 * Tests {@link
 * SingleCheckpointBarrierHandler#processCancellationBarrier(CancelCheckpointMarker,
 * InputChannelInfo)} abort the current pending checkpoint triggered by {@link
 * CheckpointBarrierHandler#processBarrier(CheckpointBarrier, InputChannelInfo)}.
 */
@Test
public void testProcessCancellationBarrierAfterProcessBarrier() throws Exception {
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    // should trigger respective checkpoint
    handler.processBarrier(buildCheckpointBarrier(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0), false);
    assertTrue(handler.isCheckpointPending());
    assertEquals(DEFAULT_CHECKPOINT_ID, handler.getLatestCheckpointId());
    testProcessCancellationBarrier(handler, invokable);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 44 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate in project flink by apache.

the class CheckpointBarrierTrackerTest method createCheckpointedInputGate.

// ------------------------------------------------------------------------
// Utils
// ------------------------------------------------------------------------
private CheckpointedInputGate createCheckpointedInputGate(int numberOfChannels, AbstractInvokable toNotify) throws IOException {
    final NettyShuffleEnvironment environment = new NettyShuffleEnvironmentBuilder().build();
    SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(numberOfChannels).setupBufferPoolFactory(environment).build();
    gate.setInputChannels(IntStream.range(0, numberOfChannels).mapToObj(channelIndex -> InputChannelBuilder.newBuilder().setChannelIndex(channelIndex).setupFromNettyShuffleEnvironment(environment).setConnectionManager(new TestingConnectionManager()).buildRemoteChannel(gate)).toArray(RemoteInputChannel[]::new));
    gate.setup();
    gate.requestPartitions();
    return createCheckpointedInputGate(gate, toNotify);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) TestingConnectionManager(org.apache.flink.runtime.io.network.TestingConnectionManager) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)

Example 45 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate in project flink by apache.

the class StreamNetworkBenchmarkEnvironment method createInputGateWithMetrics.

private IndexedInputGate createInputGateWithMetrics(SingleInputGateFactory gateFactory, InputGateDeploymentDescriptor gateDescriptor, int gateIndex) {
    final TaskMetricGroup taskMetricGroup = UnregisteredMetricGroups.createUnregisteredTaskMetricGroup();
    final SingleInputGate singleGate = gateFactory.create(receiverEnv.createShuffleIOOwnerContext("receiving task[" + gateIndex + "]", taskMetricGroup.executionId(), taskMetricGroup), gateIndex, gateDescriptor, SingleInputGateBuilder.NO_OP_PRODUCER_CHECKER);
    return new InputGateWithMetrics(singleGate, new SimpleCounter());
}
Also used : InputGateWithMetrics(org.apache.flink.runtime.taskmanager.InputGateWithMetrics) SimpleCounter(org.apache.flink.metrics.SimpleCounter) TaskMetricGroup(org.apache.flink.runtime.metrics.groups.TaskMetricGroup) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Aggregations

SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)56 Test (org.junit.Test)32 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)30 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)22 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)21 InputChannelTestUtils.createRemoteInputChannel (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel)15 InputChannelTestUtils.createSingleInputGate (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate)15 BufferPool (org.apache.flink.runtime.io.network.buffer.BufferPool)14 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)11 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)10 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)8 IOException (java.io.IOException)7 ConnectionManager (org.apache.flink.runtime.io.network.ConnectionManager)7 PartitionRequestClient (org.apache.flink.runtime.io.network.PartitionRequestClient)7 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)7 BufferResponse (org.apache.flink.runtime.io.network.netty.NettyMessage.BufferResponse)7 InputChannelTestUtils.createDummyConnectionManager (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createDummyConnectionManager)7 InputChannelBuilder (org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder)7 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)6 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)5