use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.
the class RescalingStreamTaskNetworkInput method getRecordDeserializers.
private static <T> Map<InputChannelInfo, DemultiplexingRecordDeserializer<T>> getRecordDeserializers(CheckpointedInputGate checkpointedInputGate, TypeSerializer<T> inputSerializer, IOManager ioManager, InflightDataRescalingDescriptor rescalingDescriptor, Function<Integer, StreamPartitioner<?>> gatePartitioners, TaskInfo taskInfo) {
RecordFilterFactory<T> recordFilterFactory = new RecordFilterFactory<>(taskInfo.getIndexOfThisSubtask(), inputSerializer, taskInfo.getNumberOfParallelSubtasks(), gatePartitioners, taskInfo.getMaxNumberOfParallelSubtasks());
final DeserializerFactory deserializerFactory = new DeserializerFactory(ioManager);
Map<InputChannelInfo, DemultiplexingRecordDeserializer<T>> deserializers = Maps.newHashMapWithExpectedSize(checkpointedInputGate.getChannelInfos().size());
for (InputChannelInfo channelInfo : checkpointedInputGate.getChannelInfos()) {
deserializers.put(channelInfo, DemultiplexingRecordDeserializer.create(channelInfo, rescalingDescriptor, deserializerFactory, recordFilterFactory));
}
return deserializers;
}
use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.
the class UpstreamRecoveryTrackerImpl method handleEndOfRecovery.
@Override
public void handleEndOfRecovery(InputChannelInfo channelInfo) throws IOException {
if (numUnrestoredChannels > 0) {
Preconditions.checkState(!restoredChannels.contains(channelInfo), "already restored: %s", channelInfo);
restoredChannels.add(channelInfo);
numUnrestoredChannels--;
if (numUnrestoredChannels == 0) {
for (InputChannelInfo inputChannelInfo : inputGate.getChannelInfos()) {
inputGate.resumeConsumption(inputChannelInfo);
}
restoredChannels.clear();
}
}
}
use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.
the class StreamTaskNetworkInputTest method createDataBuffer.
private BufferOrEvent createDataBuffer() throws IOException {
try (BufferBuilder bufferBuilder = BufferBuilderTestUtils.createEmptyBufferBuilder(PAGE_SIZE)) {
BufferConsumer bufferConsumer = bufferBuilder.createBufferConsumer();
serializeRecord(42L, bufferBuilder);
serializeRecord(44L, bufferBuilder);
return new BufferOrEvent(bufferConsumer.build(), new InputChannelInfo(0, 0));
}
}
use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.
the class StreamTaskNetworkInputTest method testNoDataProcessedAfterCheckpointBarrier.
/**
* InputGate on CheckpointBarrier can enqueue a mailbox action to execute and
* StreamTaskNetworkInput must allow this action to execute before processing a following
* record.
*/
@Test
public void testNoDataProcessedAfterCheckpointBarrier() throws Exception {
CheckpointBarrier barrier = new CheckpointBarrier(0, 0, CheckpointOptions.forCheckpointWithDefaultLocation());
List<BufferOrEvent> buffers = new ArrayList<>(2);
buffers.add(new BufferOrEvent(barrier, new InputChannelInfo(0, 0)));
buffers.add(createDataBuffer());
VerifyRecordsDataOutput<Long> output = new VerifyRecordsDataOutput<>();
StreamTaskNetworkInput<Long> input = createStreamTaskNetworkInput(buffers);
assertHasNextElement(input, output);
assertEquals(0, output.getNumberOfEmittedRecords());
}
use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.
the class StreamTaskNetworkInputTest method testInputStatusAfterEndOfRecovery.
@Test
public void testInputStatusAfterEndOfRecovery() throws Exception {
int numInputChannels = 2;
LongSerializer inSerializer = LongSerializer.INSTANCE;
StreamTestSingleInputGate<Long> inputGate = new StreamTestSingleInputGate<>(numInputChannels, 0, inSerializer, 1024);
DataOutput<Long> output = new NoOpDataOutput<>();
Map<InputChannelInfo, TestRecordDeserializer> deserializers = createDeserializers(inputGate.getInputGate());
StreamTaskInput<Long> input = new TestStreamTaskNetworkInput(inputGate, inSerializer, numInputChannels, deserializers);
inputGate.sendElement(new StreamRecord<>(42L), 0);
assertThat(input.emitNext(output), equalTo(DataInputStatus.MORE_AVAILABLE));
inputGate.sendEvent(EndOfChannelStateEvent.INSTANCE, 0);
assertThat(input.emitNext(output), equalTo(DataInputStatus.MORE_AVAILABLE));
inputGate.sendEvent(EndOfChannelStateEvent.INSTANCE, 1);
assertThat(input.emitNext(output), equalTo(DataInputStatus.END_OF_RECOVERY));
}
Aggregations