Class TaskStateSnapshot
- All Implemented Interfaces:
Serializable,CompositeStateHandle,StateObject
One instance of this class contains the information that one task will send to acknowledge a
checkpoint request by the checkpoint coordinator. Tasks run operator instances in parallel, so
the union of all TaskStateSnapshot that are collected by the checkpoint coordinator from
all tasks represent the whole state of a job at the time of the checkpoint.
This class should be called TaskState once the old class with this name that we keep for backwards compatibility goes away.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.StateObject
StateObject.StateObjectLocation, StateObject.StateObjectSizeStatsCollector -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTaskStateSnapshot(int size, boolean isTaskFinished) TaskStateSnapshot(Map<OperatorID, OperatorSubtaskState> subtaskStatesByOperatorID) -
Method Summary
Modifier and TypeMethodDescriptionvoidCollects statistics about state size and location from the state object.static TaskStateSnapshotdeserializeTaskStateSnapshot(org.apache.flink.util.SerializedValue<TaskStateSnapshot> subtaskState, ClassLoader classLoader) voidDiscards the state referred to and solemnly owned by this handle, to free up resources in the persistent storage.booleanlongReturns the persisted data size during checkpoint execution in bytes.Returns the input channel mapping for rescaling with in-flight data orInflightDataRescalingDescriptor.NO_RESCALE.Returns the output channel mapping for rescaling with in-flight data orInflightDataRescalingDescriptor.NO_RESCALE.longReturns the size of the state in bytes.getSubtaskStateByOperatorID(OperatorID operatorID) Returns the subtask state for the given operator id (or null if not contained).Returns the set of all mappings from operator id to the corresponding subtask state.inthashCode()booleanhasState()Returns true if at least oneOperatorSubtaskStatein subtaskStatesByOperatorID has state.booleanReturns whether all the operators of the task are already finished on restoring.booleanReturns whether all the operators of the task have called finished methods.putSubtaskStateByOperatorID(OperatorID operatorID, OperatorSubtaskState state) Maps the given operator id to the given subtask state.voidregisterSharedStates(SharedStateRegistry stateRegistry, long checkpointID) Register both newly created and already referenced shared states in the givenSharedStateRegistry.static org.apache.flink.util.SerializedValue<TaskStateSnapshot>serializeTaskStateSnapshot(TaskStateSnapshot subtaskState) toString()
-
Field Details
-
FINISHED_ON_RESTORE
-
-
Constructor Details
-
TaskStateSnapshot
public TaskStateSnapshot() -
TaskStateSnapshot
public TaskStateSnapshot(int size, boolean isTaskFinished) -
TaskStateSnapshot
-
-
Method Details
-
isTaskDeployedAsFinished
public boolean isTaskDeployedAsFinished()Returns whether all the operators of the task are already finished on restoring. -
isTaskFinished
public boolean isTaskFinished()Returns whether all the operators of the task have called finished methods. -
getSubtaskStateByOperatorID
Returns the subtask state for the given operator id (or null if not contained). -
putSubtaskStateByOperatorID
public OperatorSubtaskState putSubtaskStateByOperatorID(@Nonnull OperatorID operatorID, @Nonnull OperatorSubtaskState state) Maps the given operator id to the given subtask state. Returns the subtask state of a previous mapping, if such a mapping existed or null otherwise. -
getSubtaskStateMappings
Returns the set of all mappings from operator id to the corresponding subtask state. -
hasState
public boolean hasState()Returns true if at least oneOperatorSubtaskStatein subtaskStatesByOperatorID has state. -
getInputRescalingDescriptor
Returns the input channel mapping for rescaling with in-flight data orInflightDataRescalingDescriptor.NO_RESCALE. -
getOutputRescalingDescriptor
Returns the output channel mapping for rescaling with in-flight data orInflightDataRescalingDescriptor.NO_RESCALE. -
discardState
Description copied from interface:StateObjectDiscards the state referred to and solemnly owned by this handle, to free up resources in the persistent storage. This method is called when the state represented by this object will not be used anymore.- Specified by:
discardStatein interfaceStateObject- Throws:
Exception
-
getStateSize
public long getStateSize()Description copied from interface:StateObjectReturns the size of the state in bytes. If the size is not known, this method should return0.The values produced by this method are only used for informational purposes and for metrics/monitoring. If this method returns wrong values, the checkpoints and recovery will still behave correctly. However, efficiency may be impacted (wrong space pre-allocation) and functionality that depends on metrics (like monitoring) will be impacted.
Note for implementors: This method should not perform any I/O operations while obtaining the state size (hence it does not declare throwing an
IOException). Instead, the state size should be stored in the state object, or should be computable from the state stored in this object. The reason is that this method is called frequently by several parts of the checkpointing and issuing I/O requests from this method accumulates a heavy I/O load on the storage system at higher scale.- Specified by:
getStateSizein interfaceStateObject- Returns:
- Size of the state in bytes.
-
collectSizeStats
Description copied from interface:StateObjectCollects statistics about state size and location from the state object.- Specified by:
collectSizeStatsin interfaceStateObject- Parameters:
collector- the statistics collector.
-
getCheckpointedSize
public long getCheckpointedSize()Description copied from interface:CompositeStateHandleReturns the persisted data size during checkpoint execution in bytes. If incremental checkpoint is enabled, this value represents the incremental persisted data size, and usually smaller thanStateObject.getStateSize(). If the size is unknown, this method would return same result asStateObject.getStateSize().- Specified by:
getCheckpointedSizein interfaceCompositeStateHandle- Returns:
- The persisted data size during checkpoint execution in bytes.
-
equals
-
hashCode
public int hashCode() -
toString
-
serializeTaskStateSnapshot
@Nullable public static org.apache.flink.util.SerializedValue<TaskStateSnapshot> serializeTaskStateSnapshot(TaskStateSnapshot subtaskState) -
deserializeTaskStateSnapshot
@Nullable public static TaskStateSnapshot deserializeTaskStateSnapshot(org.apache.flink.util.SerializedValue<TaskStateSnapshot> subtaskState, ClassLoader classLoader)
-