Search in sources :

Example 1 with CheckpointableInput

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

the class AlternatingCollectingBarriers method alignmentTimeout.

@Override
public BarrierHandlerState alignmentTimeout(Controller controller, CheckpointBarrier checkpointBarrier) throws IOException, CheckpointException {
    state.prioritizeAllAnnouncements();
    CheckpointBarrier unalignedBarrier = checkpointBarrier.asUnaligned();
    controller.initInputsCheckpoint(unalignedBarrier);
    for (CheckpointableInput input : state.getInputs()) {
        input.checkpointStarted(unalignedBarrier);
    }
    controller.triggerGlobalCheckpoint(unalignedBarrier);
    return new AlternatingCollectingBarriersUnaligned(true, state);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) CheckpointableInput(org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput)

Example 2 with CheckpointableInput

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

the class AlternatingWaitingForFirstBarrierUnaligned method barrierReceived.

@Override
public BarrierHandlerState barrierReceived(Controller controller, InputChannelInfo channelInfo, CheckpointBarrier checkpointBarrier, boolean markChannelBlocked) throws CheckpointException, IOException {
    // as it is being blocked by the credit-based network
    if (markChannelBlocked && !checkpointBarrier.getCheckpointOptions().isUnalignedCheckpoint()) {
        channelState.blockChannel(channelInfo);
    }
    CheckpointBarrier unalignedBarrier = checkpointBarrier.asUnaligned();
    controller.initInputsCheckpoint(unalignedBarrier);
    for (CheckpointableInput input : channelState.getInputs()) {
        input.checkpointStarted(unalignedBarrier);
    }
    controller.triggerGlobalCheckpoint(unalignedBarrier);
    if (controller.allBarriersReceived()) {
        for (CheckpointableInput input : channelState.getInputs()) {
            input.checkpointStopped(unalignedBarrier.getId());
        }
        return stopCheckpoint();
    }
    return new AlternatingCollectingBarriersUnaligned(alternating, channelState);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) CheckpointableInput(org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput)

Example 3 with CheckpointableInput

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

the class InputProcessorUtil method createCheckpointBarrierHandler.

public static CheckpointBarrierHandler createCheckpointBarrierHandler(CheckpointableTask toNotifyOnCheckpoint, StreamConfig config, SubtaskCheckpointCoordinator checkpointCoordinator, String taskName, List<IndexedInputGate>[] inputGates, List<StreamTaskSourceInput<?>> sourceInputs, MailboxExecutor mailboxExecutor, TimerService timerService) {
    CheckpointableInput[] inputs = Stream.<CheckpointableInput>concat(Arrays.stream(inputGates).flatMap(Collection::stream), sourceInputs.stream()).sorted(Comparator.comparing(CheckpointableInput::getInputGateIndex)).toArray(CheckpointableInput[]::new);
    Clock clock = SystemClock.getInstance();
    switch(config.getCheckpointMode()) {
        case EXACTLY_ONCE:
            int numberOfChannels = (int) Arrays.stream(inputs).mapToLong(gate -> gate.getChannelInfos().size()).sum();
            return createBarrierHandler(toNotifyOnCheckpoint, config, checkpointCoordinator, taskName, mailboxExecutor, timerService, inputs, clock, numberOfChannels);
        case AT_LEAST_ONCE:
            if (config.isUnalignedCheckpointsEnabled()) {
                throw new IllegalStateException("Cannot use unaligned checkpoints with AT_LEAST_ONCE " + "checkpointing mode");
            }
            int numInputChannels = Arrays.stream(inputs).mapToInt(CheckpointableInput::getNumberOfInputChannels).sum();
            return new CheckpointBarrierTracker(numInputChannels, toNotifyOnCheckpoint, clock, config.getConfiguration().get(ExecutionCheckpointingOptions.ENABLE_CHECKPOINTS_AFTER_TASKS_FINISH));
        default:
            throw new UnsupportedOperationException("Unrecognized Checkpointing Mode: " + config.getCheckpointMode());
    }
}
Also used : CheckpointableInput(org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput) SystemClock(org.apache.flink.util.clock.SystemClock) Clock(org.apache.flink.util.clock.Clock)

Aggregations

CheckpointableInput (org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput)3 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)2 Clock (org.apache.flink.util.clock.Clock)1 SystemClock (org.apache.flink.util.clock.SystemClock)1