Search in sources :

Example 1 with Clock

use of org.apache.flink.util.clock.Clock 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)1 Clock (org.apache.flink.util.clock.Clock)1 SystemClock (org.apache.flink.util.clock.SystemClock)1