use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.
the class KeyedStateBootstrapOperator 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));
}
use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.
the class StateBootstrapTransformationTest method testMaxParallelismRespected.
@Test
public void testMaxParallelismRespected() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(10);
DataStream<Integer> input = env.fromElements(0);
StateBootstrapTransformation<Integer> transformation = OperatorTransformation.bootstrapWith(input).transform(new ExampleStateBootstrapFunction());
int maxParallelism = transformation.getMaxParallelism(4);
DataStream<TaggedOperatorSubtaskState> result = transformation.writeOperatorSubtaskStates(OperatorIDGenerator.fromUid("uid"), new HashMapStateBackend(), new Path(), maxParallelism);
Assert.assertEquals("The parallelism of a data set should be constrained my the savepoint max parallelism", 4, result.getParallelism());
}
use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.
the class StateBootstrapTransformationTest method testOperatorSpecificMaxParallelismRespected.
@Test
public void testOperatorSpecificMaxParallelismRespected() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
DataStream<Integer> input = env.fromElements(0);
StateBootstrapTransformation<Integer> transformation = OperatorTransformation.bootstrapWith(input).setMaxParallelism(1).transform(new ExampleStateBootstrapFunction());
int maxParallelism = transformation.getMaxParallelism(4);
DataStream<TaggedOperatorSubtaskState> result = transformation.writeOperatorSubtaskStates(OperatorIDGenerator.fromUid("uid"), new HashMapStateBackend(), new Path(), maxParallelism);
Assert.assertEquals("The parallelism of a data set should be constrained my the savepoint max parallelism", 1, result.getParallelism());
}
use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.
the class StateBootstrapTransformationTest method testDefaultParallelismRespectedWhenLessThanMaxParallelism.
@Test
public void testDefaultParallelismRespectedWhenLessThanMaxParallelism() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
DataStream<Integer> input = env.fromElements(0);
StateBootstrapTransformation<Integer> transformation = OperatorTransformation.bootstrapWith(input).transform(new ExampleStateBootstrapFunction());
int maxParallelism = transformation.getMaxParallelism(10);
DataStream<TaggedOperatorSubtaskState> result = transformation.writeOperatorSubtaskStates(OperatorIDGenerator.fromUid("uid"), new HashMapStateBackend(), new Path(), maxParallelism);
Assert.assertEquals("The parallelism of a data set should not change when less than the max parallelism of the savepoint", env.getParallelism(), result.getParallelism());
}
use of org.apache.flink.state.api.output.TaggedOperatorSubtaskState in project flink by apache.
the class StateBootstrapTransformationTest method testBroadcastStateTransformationParallelism.
@Test
public void testBroadcastStateTransformationParallelism() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(10);
DataStream<Integer> input = env.fromElements(0);
StateBootstrapTransformation<Integer> transformation = OperatorTransformation.bootstrapWith(input).transform(new ExampleBroadcastStateBootstrapFunction());
int maxParallelism = transformation.getMaxParallelism(4);
DataStream<TaggedOperatorSubtaskState> result = transformation.writeOperatorSubtaskStates(OperatorIDGenerator.fromUid("uid"), new HashMapStateBackend(), new Path(), maxParallelism);
Assert.assertEquals("Broadcast transformations should always be run at parallelism 1", 1, result.getParallelism());
}
Aggregations