Search in sources :

Example 1 with InputChannelInfo

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;
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)

Example 2 with InputChannelInfo

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();
        }
    }
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)

Example 3 with InputChannelInfo

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));
    }
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder) BufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferConsumer) BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent)

Example 4 with InputChannelInfo

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());
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) ArrayList(java.util.ArrayList) BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 5 with InputChannelInfo

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));
}
Also used : LongSerializer(org.apache.flink.api.common.typeutils.base.LongSerializer) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) StreamTestSingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.StreamTestSingleInputGate) Test(org.junit.Test)

Aggregations

InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)30 Test (org.junit.Test)21 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)9 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)8 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)8 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)5 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)5 BufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilder)4 MemorySegment (org.apache.flink.core.memory.MemorySegment)3 ResultSubpartitionInfo (org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo)3 CancelCheckpointMarker (org.apache.flink.runtime.io.network.api.CancelCheckpointMarker)3 SubtaskConnectionDescriptor (org.apache.flink.runtime.io.network.api.SubtaskConnectionDescriptor)3 BufferBuilderTestUtils.createBufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createBufferBuilder)3 BufferOrEvent (org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent)3 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LongSerializer (org.apache.flink.api.common.typeutils.base.LongSerializer)2 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)2 NetworkBuffer (org.apache.flink.runtime.io.network.buffer.NetworkBuffer)2