Class StateAssignmentOperation
java.lang.Object
org.apache.flink.runtime.checkpoint.StateAssignmentOperation
This class encapsulates the operation of assigning restored state when restoring from a
checkpoint.
-
Constructor Summary
ConstructorsConstructorDescriptionStateAssignmentOperation(long restoreCheckpointId, Set<ExecutionJobVertex> tasks, Map<OperatorID, OperatorState> operatorStates, boolean allowNonRestoredState) -
Method Summary
Modifier and TypeMethodDescriptionapplyRepartitioner(OperatorStateRepartitioner<T> opStateRepartitioner, List<List<T>> chainOpParallelStates, int oldParallelism, int newParallelism) Repartitions the given operator state using the givenOperatorStateRepartitionerwith respect to the new parallelism.static <T> Map<OperatorInstanceID,List<T>> applyRepartitioner(OperatorID operatorID, OperatorStateRepartitioner<T> opStateRepartitioner, List<List<T>> chainOpParallelStates, int oldParallelism, int newParallelism) voidvoidcheckParallelismPreconditions(org.apache.flink.runtime.checkpoint.TaskStateAssignment taskStateAssignment) static List<KeyGroupRange>createKeyGroupPartitions(int numberKeyGroups, int parallelism) Groups the available set of key groups into key group partitions.static voidextractIntersectingState(Collection<? extends KeyedStateHandle> originalSubtaskStateHandles, KeyGroupRange rangeToExtract, List<KeyedStateHandle> extractedStateCollector) Extracts certain key group ranges from the given state handles and adds them to the collector.static List<KeyedStateHandle>getManagedKeyedStateHandles(OperatorState operatorState, KeyGroupRange subtaskKeyGroupRange) CollectmanagedKeyedStateHandleswhich have intersection with givenKeyGroupRangefromoperatorState.static List<KeyedStateHandle>getRawKeyedStateHandles(OperatorState operatorState, KeyGroupRange subtaskKeyGroupRange) voidreDistributeInputChannelStates(org.apache.flink.runtime.checkpoint.TaskStateAssignment stateAssignment) static <T extends StateObject>
voidreDistributePartitionableStates(Map<OperatorID, OperatorState> oldOperatorStates, int newParallelism, Function<OperatorSubtaskState, StateObjectCollection<T>> extractHandle, OperatorStateRepartitioner<T> stateRepartitioner, Map<OperatorInstanceID, List<T>> result) voidreDistributeResultSubpartitionStates(org.apache.flink.runtime.checkpoint.TaskStateAssignment assignment)
-
Constructor Details
-
StateAssignmentOperation
public StateAssignmentOperation(long restoreCheckpointId, Set<ExecutionJobVertex> tasks, Map<OperatorID, OperatorState> operatorStates, boolean allowNonRestoredState)
-
-
Method Details
-
assignStates
public void assignStates() -
checkParallelismPreconditions
public void checkParallelismPreconditions(org.apache.flink.runtime.checkpoint.TaskStateAssignment taskStateAssignment) -
reDistributePartitionableStates
public static <T extends StateObject> void reDistributePartitionableStates(Map<OperatorID, OperatorState> oldOperatorStates, int newParallelism, Function<OperatorSubtaskState, StateObjectCollection<T>> extractHandle, OperatorStateRepartitioner<T> stateRepartitioner, Map<OperatorInstanceID, List<T>> result) -
reDistributeResultSubpartitionStates
public void reDistributeResultSubpartitionStates(org.apache.flink.runtime.checkpoint.TaskStateAssignment assignment) -
reDistributeInputChannelStates
public void reDistributeInputChannelStates(org.apache.flink.runtime.checkpoint.TaskStateAssignment stateAssignment) -
getManagedKeyedStateHandles
public static List<KeyedStateHandle> getManagedKeyedStateHandles(OperatorState operatorState, KeyGroupRange subtaskKeyGroupRange) CollectmanagedKeyedStateHandleswhich have intersection with givenKeyGroupRangefromoperatorState.- Parameters:
operatorState- all state handles of a operatorsubtaskKeyGroupRange- the KeyGroupRange of a subtask- Returns:
- all managedKeyedStateHandles which have intersection with given KeyGroupRange
-
getRawKeyedStateHandles
public static List<KeyedStateHandle> getRawKeyedStateHandles(OperatorState operatorState, KeyGroupRange subtaskKeyGroupRange) - Parameters:
operatorState- all state handles of a operatorsubtaskKeyGroupRange- the KeyGroupRange of a subtask- Returns:
- all rawKeyedStateHandles which have intersection with given KeyGroupRange
-
extractIntersectingState
@VisibleForTesting public static void extractIntersectingState(Collection<? extends KeyedStateHandle> originalSubtaskStateHandles, KeyGroupRange rangeToExtract, List<KeyedStateHandle> extractedStateCollector) Extracts certain key group ranges from the given state handles and adds them to the collector. -
createKeyGroupPartitions
Groups the available set of key groups into key group partitions. A key group partition is the set of key groups which is assigned to the same task. Each set of the returned list constitutes a key group partition.IMPORTANT: The assignment of key groups to partitions has to be in sync with the KeyGroupStreamPartitioner.
- Parameters:
numberKeyGroups- Number of available key groups (indexed from 0 to numberKeyGroups - 1)parallelism- Parallelism to generate the key group partitioning for- Returns:
- List of key group partitions
-
applyRepartitioner
public static <T> Map<OperatorInstanceID,List<T>> applyRepartitioner(OperatorID operatorID, OperatorStateRepartitioner<T> opStateRepartitioner, List<List<T>> chainOpParallelStates, int oldParallelism, int newParallelism) -
applyRepartitioner
public static <T> List<List<T>> applyRepartitioner(OperatorStateRepartitioner<T> opStateRepartitioner, List<List<T>> chainOpParallelStates, int oldParallelism, int newParallelism) Repartitions the given operator state using the givenOperatorStateRepartitionerwith respect to the new parallelism.- Parameters:
opStateRepartitioner- partitioner to usechainOpParallelStates- state to repartitionoldParallelism- parallelism with which the state is currently partitionednewParallelism- parallelism with which the state should be partitioned- Returns:
- repartitioned state
-