Search in sources :

Example 1 with TaggedOperatorSubtaskState

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));
}
Also used : TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState)

Example 2 with TaggedOperatorSubtaskState

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());
}
Also used : Path(org.apache.flink.core.fs.Path) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) HashMapStateBackend(org.apache.flink.runtime.state.hashmap.HashMapStateBackend) TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState) Test(org.junit.Test)

Example 3 with TaggedOperatorSubtaskState

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());
}
Also used : Path(org.apache.flink.core.fs.Path) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) HashMapStateBackend(org.apache.flink.runtime.state.hashmap.HashMapStateBackend) TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState) Test(org.junit.Test)

Example 4 with TaggedOperatorSubtaskState

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());
}
Also used : Path(org.apache.flink.core.fs.Path) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) HashMapStateBackend(org.apache.flink.runtime.state.hashmap.HashMapStateBackend) TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState) Test(org.junit.Test)

Example 5 with TaggedOperatorSubtaskState

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());
}
Also used : Path(org.apache.flink.core.fs.Path) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) HashMapStateBackend(org.apache.flink.runtime.state.hashmap.HashMapStateBackend) TaggedOperatorSubtaskState(org.apache.flink.state.api.output.TaggedOperatorSubtaskState) Test(org.junit.Test)

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