use of org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder in project flink by apache.
the class InputChannelTestUtils method createLocalInputChannel.
public static LocalInputChannel createLocalInputChannel(SingleInputGate inputGate, ResultPartitionManager partitionManager, int initialBackoff, int maxBackoff, Consumer<InputChannelBuilder> setter) {
InputChannelBuilder inputChannelBuilder = InputChannelBuilder.newBuilder().setPartitionManager(partitionManager).setInitialBackoff(initialBackoff).setMaxBackoff(maxBackoff);
setter.accept(inputChannelBuilder);
return inputChannelBuilder.buildLocalChannel(inputGate);
}
use of org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder in project flink by apache.
the class CreditBasedPartitionRequestClientHandlerTest method testReadBufferResponseWithReleasingOrRemovingChannel.
private void testReadBufferResponseWithReleasingOrRemovingChannel(boolean isRemoved, boolean readBeforeReleasingOrRemoving) throws Exception {
int bufferSize = 1024;
NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, bufferSize);
SingleInputGate inputGate = createSingleInputGate(1, networkBufferPool);
RemoteInputChannel inputChannel = new InputChannelBuilder().buildRemoteChannel(inputGate);
inputGate.setInputChannels(inputChannel);
inputGate.setup();
CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler();
EmbeddedChannel embeddedChannel = new EmbeddedChannel(handler);
handler.addInputChannel(inputChannel);
try {
if (!readBeforeReleasingOrRemoving) {
// Release the channel.
inputGate.close();
if (isRemoved) {
handler.removeInputChannel(inputChannel);
}
}
BufferResponse bufferResponse = createBufferResponse(TestBufferFactory.createBuffer(bufferSize), 0, inputChannel.getInputChannelId(), 1, new NetworkBufferAllocator(handler));
if (readBeforeReleasingOrRemoving) {
// Release the channel.
inputGate.close();
if (isRemoved) {
handler.removeInputChannel(inputChannel);
}
}
handler.channelRead(null, bufferResponse);
assertEquals(0, inputChannel.getNumberOfQueuedBuffers());
if (!readBeforeReleasingOrRemoving) {
assertNull(bufferResponse.getBuffer());
} else {
assertNotNull(bufferResponse.getBuffer());
assertTrue(bufferResponse.getBuffer().isRecycled());
}
embeddedChannel.runScheduledPendingTasks();
NettyMessage.CancelPartitionRequest cancelPartitionRequest = embeddedChannel.readOutbound();
assertNotNull(cancelPartitionRequest);
assertEquals(inputChannel.getInputChannelId(), cancelPartitionRequest.receiverId);
} finally {
releaseResource(inputGate, networkBufferPool);
embeddedChannel.close();
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder in project flink by apache.
the class UnalignedCheckpointsTest method testEndOfStreamWithPendingCheckpoint.
@Test
public void testEndOfStreamWithPendingCheckpoint() throws Exception {
final int numberOfChannels = 2;
final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
final SingleInputGate inputGate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildLocalChannel).setNumberOfChannels(numberOfChannels).build();
final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), false, 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());
assertEquals(numberOfChannels, handler.getNumOpenChannels());
// should abort current checkpoint while processing eof
handler.processEndOfPartition(new InputChannelInfo(0, 0));
assertFalse(handler.isCheckpointPending());
assertEquals(DEFAULT_CHECKPOINT_ID, handler.getLatestCheckpointId());
assertEquals(numberOfChannels - 1, handler.getNumOpenChannels());
assertEquals(DEFAULT_CHECKPOINT_ID, invokable.getAbortedCheckpointId());
}
use of org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder 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.InputChannelBuilder in project flink by apache.
the class NettyMessageClientDecoderDelegateTest method setup.
@Before
public void setup() throws IOException, InterruptedException {
CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler();
networkBufferPool = new NetworkBufferPool(NUMBER_OF_BUFFER_RESPONSES, BUFFER_SIZE);
channel = new EmbeddedChannel(new NettyMessageClientDecoderDelegate(handler));
inputGate = createSingleInputGate(1, networkBufferPool);
RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, new TestingPartitionRequestClient(), NUMBER_OF_BUFFER_RESPONSES);
inputGate.setInputChannels(inputChannel);
inputGate.setup();
inputChannel.requestSubpartition();
handler.addInputChannel(inputChannel);
inputChannelId = inputChannel.getInputChannelId();
SingleInputGate releasedInputGate = createSingleInputGate(1, networkBufferPool);
RemoteInputChannel releasedInputChannel = new InputChannelBuilder().buildRemoteChannel(inputGate);
releasedInputGate.close();
handler.addInputChannel(releasedInputChannel);
releasedInputChannelId = releasedInputChannel.getInputChannelId();
}
Aggregations