Search in sources :

Example 11 with SingleInputGateBuilder

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

the class AlignedCheckpointsTest method createCheckpointedInputGate.

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 12 with SingleInputGateBuilder

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

the class StreamTaskMailboxTestHarnessBuilder method initializeNetworkInput.

private void initializeNetworkInput(NetworkInputConfig networkInput, StreamNode targetVertexDummy, StreamMockEnvironment streamMockEnvironment, List<StreamEdge> inPhysicalEdges) {
    int gateIndex = networkInput.getInputGateIndex();
    TypeSerializer<?> inputSerializer = networkInput.getTypeSerializer();
    inputGates[gateIndex] = new StreamTestSingleInputGate<>(inputChannelsPerGate.get(gateIndex), gateIndex, inputSerializer, bufferSize, modifyGateBuilder.apply(new SingleInputGateBuilder().setBufferDebloatConfiguration(BufferDebloatConfiguration.fromConfiguration(streamMockEnvironment.getTaskManagerInfo().getConfiguration()))));
    StreamNode sourceVertexDummy = new StreamNode(0, null, null, (StreamOperator<?>) null, null, SourceStreamTask.class);
    StreamEdge streamEdge = new StreamEdge(sourceVertexDummy, targetVertexDummy, gateIndex + 1, new BroadcastPartitioner<>(), null);
    inPhysicalEdges.add(streamEdge);
    streamMockEnvironment.addInputGate(inputGates[gateIndex].getInputGate());
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) StreamEdge(org.apache.flink.streaming.api.graph.StreamEdge) StreamNode(org.apache.flink.streaming.api.graph.StreamNode)

Example 13 with SingleInputGateBuilder

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

the class InputChannelRecoveredStateHandlerTest method setUp.

@Before
public void setUp() {
    // given: Segment provider with defined number of allocated segments.
    networkBufferPool = new NetworkBufferPool(preAllocatedSegments, 1024);
    // and: Configured input gate with recovered channel.
    inputGate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildLocalRecoveredChannel).setSegmentProvider(networkBufferPool).build();
    icsHander = buildInputChannelStateHandler(inputGate);
    channelInfo = new InputChannelInfo(0, 0);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool) Before(org.junit.Before)

Example 14 with SingleInputGateBuilder

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

the class ChannelPersistenceITCase method buildGate.

private SingleInputGate buildGate(NetworkBufferPool networkBufferPool, int numberOfChannels) throws IOException {
    SingleInputGate gate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildRemoteRecoveredChannel).setBufferPoolFactory(networkBufferPool.createBufferPool(numberOfChannels, Integer.MAX_VALUE)).setSegmentProvider(networkBufferPool).setNumberOfChannels(numberOfChannels).build();
    gate.setup();
    return gate;
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Example 15 with SingleInputGateBuilder

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

the class AlternatingCheckpointsTest method testBarrierHandling.

private void testBarrierHandling(SnapshotType checkpointType) throws Exception {
    final long barrierId = 123L;
    ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
    SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
    TestInputChannel fast = new TestInputChannel(gate, 0, false, true);
    TestInputChannel slow = new TestInputChannel(gate, 1, false, true);
    gate.setInputChannels(fast, slow);
    SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(gate);
    CheckpointedInputGate checkpointedGate = new CheckpointedInputGate(gate, barrierHandler, new SyncMailboxExecutor());
    if (checkpointType.isSavepoint()) {
        fast.setBlocked(true);
        slow.setBlocked(true);
    }
    CheckpointOptions options = checkpointType.isSavepoint() ? alignedNoTimeout(checkpointType, getDefault()) : unaligned(CheckpointType.CHECKPOINT, getDefault());
    Buffer barrier = barrier(barrierId, 1, options);
    send(barrier.retainBuffer(), fast, checkpointedGate);
    assertEquals(checkpointType.isSavepoint(), target.triggeredCheckpoints.isEmpty());
    send(barrier.retainBuffer(), slow, checkpointedGate);
    assertEquals(singletonList(barrierId), target.triggeredCheckpoints);
    if (checkpointType.isSavepoint()) {
        for (InputChannel channel : gate.getInputChannels().values()) {
            assertFalse(String.format("channel %d should be resumed", channel.getChannelIndex()), ((TestInputChannel) channel).isBlocked());
        }
    }
}
Also used : TestBufferFactory.createBuffer(org.apache.flink.runtime.io.network.util.TestBufferFactory.createBuffer) Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) EventSerializer.toBuffer(org.apache.flink.runtime.io.network.api.serialization.EventSerializer.toBuffer) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) SyncMailboxExecutor(org.apache.flink.runtime.mailbox.SyncMailboxExecutor) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) InputChannel(org.apache.flink.runtime.io.network.partition.consumer.InputChannel) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Aggregations

SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)22 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)20 Test (org.junit.Test)11 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)9 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)8 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)7 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)5 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)5 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)5 TestingConnectionManager (org.apache.flink.runtime.io.network.TestingConnectionManager)4 NettyShuffleEnvironment (org.apache.flink.runtime.io.network.NettyShuffleEnvironment)3 NettyShuffleEnvironmentBuilder (org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder)3 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)3 InputChannelBuilder (org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder)3 Closer (org.apache.flink.shaded.guava30.com.google.common.io.Closer)3 MailboxExecutorImpl (org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl)3 TaskMailboxImpl (org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailboxImpl)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Deadline (org.apache.flink.api.common.time.Deadline)2 CheckedThread (org.apache.flink.core.testutils.CheckedThread)2