Search in sources :

Example 11 with TaggedOperatorSubtaskState

use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.

the class StateBootstrapTransformation method writeOperatorSubtaskStates.

private SingleOutputStreamOperator<TaggedOperatorSubtaskState> writeOperatorSubtaskStates(OperatorID operatorID, StateBackend stateBackend, Configuration additionalConfig, Path savepointPath, int localMaxParallelism) {
    StreamOperator<TaggedOperatorSubtaskState> operator = factory.createOperator(System.currentTimeMillis(), savepointPath);
    operator = stream.getExecutionEnvironment().clean(operator);
    final StreamConfig config = getConfig(operatorID, stateBackend, additionalConfig, operator);
    BootstrapStreamTaskRunner<T> operatorRunner = new BootstrapStreamTaskRunner<>(config, localMaxParallelism);
    DataStream<T> input = stream;
    if (keySelector != null) {
        input = stream.keyBy(this.keySelector);
    }
    SingleOutputStreamOperator<TaggedOperatorSubtaskState> subtaskStates = input.transform(operatorID.toHexString(), TypeInformation.of(TaggedOperatorSubtaskState.class), operatorRunner).setMaxParallelism(localMaxParallelism);
    if (operator instanceof BroadcastStateBootstrapOperator) {
        subtaskStates = subtaskStates.setParallelism(1);
    } else {
        int currentParallelism = getParallelism(subtaskStates);
        if (currentParallelism > localMaxParallelism) {
            subtaskStates.setParallelism(localMaxParallelism);
        }
    }
    return subtaskStates;
}
Also used : BroadcastStateBootstrapOperator(org.apache.flink.state.api.output.operators.BroadcastStateBootstrapOperator) BootstrapStreamTaskRunner(org.apache.flink.state.api.output.BootstrapStreamTaskRunner) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState)

Example 12 with TaggedOperatorSubtaskState

use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.

the class BroadcastStateBootstrapOperator method endInput.

@Override
public void endInput() throws Exception {
    TaggedOperatorSubtaskState state = SnapshotUtils.snapshot(this, getRuntimeContext().getIndexOfThisSubtask(), timestamp, getContainingTask().getConfiguration().isExactlyOnceCheckpointMode(), getContainingTask().getConfiguration().isUnalignedCheckpointsEnabled(), getContainingTask().getConfiguration().getConfiguration(), savepointPath);
    output.collect(new StreamRecord<>(state));
}
Also used : TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState)

Example 13 with TaggedOperatorSubtaskState

use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.

the class StateBootstrapOperator method endInput.

@Override
public void endInput() throws Exception {
    TaggedOperatorSubtaskState state = SnapshotUtils.snapshot(this, getRuntimeContext().getIndexOfThisSubtask(), timestamp, getContainingTask().getConfiguration().isExactlyOnceCheckpointMode(), getContainingTask().getConfiguration().isUnalignedCheckpointsEnabled(), getContainingTask().getConfiguration().getConfiguration(), savepointPath);
    output.collect(new StreamRecord<>(state));
}
Also used : TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState)

Example 14 with TaggedOperatorSubtaskState

use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.

the class StateBootstrapWrapperOperator method endInput.

@Override
public void endInput() throws Exception {
    TaggedOperatorSubtaskState state = SnapshotUtils.snapshot(this, operator.getContainingTask().getEnvironment().getTaskInfo().getIndexOfThisSubtask(), timestamp, operator.getContainingTask().getConfiguration().isExactlyOnceCheckpointMode(), operator.getContainingTask().getConfiguration().isUnalignedCheckpointsEnabled(), operator.getContainingTask().getConfiguration().getConfiguration(), savepointPath);
    output.collect(new StreamRecord<>(state));
}
Also used : TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState)

Aggregations

TaggedOperatorSubtaskState (org.apache.flink.state.api.output.TaggedOperatorSubtaskState)14 Path (org.apache.flink.core.fs.Path)8 Test (org.junit.Test)8 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)4 HashMapStateBackend (org.apache.flink.runtime.state.hashmap.HashMapStateBackend)4 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)4 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)4 BroadcastStateBootstrapOperator (org.apache.flink.state.api.output.operators.BroadcastStateBootstrapOperator)2 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)2 BootstrapStreamTaskRunner (org.apache.flink.state.api.output.BootstrapStreamTaskRunner)1 BoundedOneInputStreamTaskRunner (org.apache.flink.state.api.output.BoundedOneInputStreamTaskRunner)1 KeyGroupRangePartitioner (org.apache.flink.state.api.output.partitioner.KeyGroupRangePartitioner)1