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);
}
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());
}
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);
}
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;
}
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());
}
}
}
Aggregations