Package org.apache.flink.runtime.state
Class TaskStateManagerImpl
- java.lang.Object
-
- org.apache.flink.runtime.state.TaskStateManagerImpl
-
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,TaskStateManager
public class TaskStateManagerImpl extends Object implements TaskStateManager
This class is the default implementation ofTaskStateManagerand collaborates with the job manager throughCheckpointResponder) as well as a task-manager-local state store. Like this, client code does not have to deal with the differences between remote or local state on recovery because this class handles both cases transparently.Reported state is tagged by clients so that this class can properly forward to the right receiver for the checkpointed state.
-
-
Constructor Summary
Constructors Constructor Description TaskStateManagerImpl(org.apache.flink.api.common.JobID jobId, ExecutionAttemptID executionAttemptID, TaskLocalStateStore localStateStore, FileMergingSnapshotManagerClosableWrapper fileMergingSnapshotManager, StateChangelogStorage<?> stateChangelogStorage, TaskExecutorStateChangelogStoragesManager changelogStoragesManager, JobManagerTaskRestore jobManagerTaskRestore, CheckpointResponder checkpointResponder)TaskStateManagerImpl(org.apache.flink.api.common.JobID jobId, ExecutionAttemptID executionAttemptID, TaskLocalStateStore localStateStore, FileMergingSnapshotManagerClosableWrapper fileMergingSnapshotManager, StateChangelogStorage<?> stateChangelogStorage, TaskExecutorStateChangelogStoragesManager changelogStoragesManager, JobManagerTaskRestore jobManagerTaskRestore, CheckpointResponder checkpointResponder, SequentialChannelStateReaderImpl sequentialChannelStateReader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()LocalRecoveryConfigcreateLocalRecoveryConfig()Returns the configuration for local recovery, i.e. the base directories for all file-based local state of the owning subtask and the general mode for local recovery.FileMergingSnapshotManagergetFileMergingSnapshotManager()InflightDataRescalingDescriptorgetInputRescalingDescriptor()InflightDataRescalingDescriptorgetOutputRescalingDescriptor()Optional<Long>getRestoreCheckpointId()Acquires the checkpoint id to restore from.SequentialChannelStateReadergetSequentialChannelStateReader()StateChangelogStorage<?>getStateChangelogStorage()Returns the configured state changelog storage for this task.StateChangelogStorageView<?>getStateChangelogStorageView(org.apache.flink.configuration.Configuration configuration, ChangelogStateHandle changelogStateHandle)Returns the state changelog storage view of givenChangelogStateHandlefor this task.Optional<OperatorSubtaskState>getSubtaskJobManagerRestoredState(OperatorID operatorID)Get the restored state from jobManager which belongs to an operator running in the owning task.booleanisTaskDeployedAsFinished()Whether all the operators of the task are finished on restore.voidnotifyCheckpointAborted(long checkpointId)Tracking when some local state can be disposed.voidnotifyCheckpointComplete(long checkpointId)Tracking when local state can be confirmed and disposed.PrioritizedOperatorSubtaskStateprioritizedOperatorState(OperatorID operatorID)Returns means to restore previously reported state of an operator running in the owning task.voidreportIncompleteTaskStateSnapshots(CheckpointMetaData checkpointMetaData, CheckpointMetrics checkpointMetrics)Report the stats for state snapshots for an aborted checkpoint.voidreportInitializationMetrics(SubTaskInitializationMetrics subTaskInitializationMetrics)voidreportTaskStateSnapshots(CheckpointMetaData checkpointMetaData, CheckpointMetrics checkpointMetrics, TaskStateSnapshot acknowledgedState, TaskStateSnapshot localState)Report the state snapshots for the operator instances running in the owning task.
-
-
-
Constructor Detail
-
TaskStateManagerImpl
public TaskStateManagerImpl(@Nonnull org.apache.flink.api.common.JobID jobId, @Nonnull ExecutionAttemptID executionAttemptID, @Nonnull TaskLocalStateStore localStateStore, @Nullable FileMergingSnapshotManagerClosableWrapper fileMergingSnapshotManager, @Nullable StateChangelogStorage<?> stateChangelogStorage, @Nonnull TaskExecutorStateChangelogStoragesManager changelogStoragesManager, @Nullable JobManagerTaskRestore jobManagerTaskRestore, @Nonnull CheckpointResponder checkpointResponder)
-
TaskStateManagerImpl
public TaskStateManagerImpl(@Nonnull org.apache.flink.api.common.JobID jobId, @Nonnull ExecutionAttemptID executionAttemptID, @Nonnull TaskLocalStateStore localStateStore, @Nullable FileMergingSnapshotManagerClosableWrapper fileMergingSnapshotManager, @Nullable StateChangelogStorage<?> stateChangelogStorage, @Nonnull TaskExecutorStateChangelogStoragesManager changelogStoragesManager, @Nullable JobManagerTaskRestore jobManagerTaskRestore, @Nonnull CheckpointResponder checkpointResponder, @Nonnull SequentialChannelStateReaderImpl sequentialChannelStateReader)
-
-
Method Detail
-
reportInitializationMetrics
public void reportInitializationMetrics(SubTaskInitializationMetrics subTaskInitializationMetrics)
- Specified by:
reportInitializationMetricsin interfaceTaskStateManager
-
reportTaskStateSnapshots
public void reportTaskStateSnapshots(@Nonnull CheckpointMetaData checkpointMetaData, @Nonnull CheckpointMetrics checkpointMetrics, @Nullable TaskStateSnapshot acknowledgedState, @Nullable TaskStateSnapshot localState)Description copied from interface:TaskStateManagerReport the state snapshots for the operator instances running in the owning task.- Specified by:
reportTaskStateSnapshotsin interfaceTaskStateManager- Parameters:
checkpointMetaData- meta data from the checkpoint request.checkpointMetrics- task level metrics for the checkpoint.acknowledgedState- the reported states to acknowledge to the job manager.localState- the reported states for local recovery.
-
reportIncompleteTaskStateSnapshots
public void reportIncompleteTaskStateSnapshots(CheckpointMetaData checkpointMetaData, CheckpointMetrics checkpointMetrics)
Description copied from interface:TaskStateManagerReport the stats for state snapshots for an aborted checkpoint.- Specified by:
reportIncompleteTaskStateSnapshotsin interfaceTaskStateManager- Parameters:
checkpointMetaData- meta data from the checkpoint request.checkpointMetrics- task level metrics for the checkpoint.
-
getInputRescalingDescriptor
public InflightDataRescalingDescriptor getInputRescalingDescriptor()
- Specified by:
getInputRescalingDescriptorin interfaceTaskStateManager
-
getOutputRescalingDescriptor
public InflightDataRescalingDescriptor getOutputRescalingDescriptor()
- Specified by:
getOutputRescalingDescriptorin interfaceTaskStateManager
-
isTaskDeployedAsFinished
public boolean isTaskDeployedAsFinished()
Description copied from interface:TaskStateManagerWhether all the operators of the task are finished on restore.- Specified by:
isTaskDeployedAsFinishedin interfaceTaskStateManager
-
getRestoreCheckpointId
public Optional<Long> getRestoreCheckpointId()
Description copied from interface:TaskStateManagerAcquires the checkpoint id to restore from.- Specified by:
getRestoreCheckpointIdin interfaceTaskStateManager
-
prioritizedOperatorState
public PrioritizedOperatorSubtaskState prioritizedOperatorState(OperatorID operatorID)
Description copied from interface:TaskStateManagerReturns means to restore previously reported state of an operator running in the owning task.- Specified by:
prioritizedOperatorStatein interfaceTaskStateManager- Parameters:
operatorID- the id of the operator for which we request state.- Returns:
- Previous state for the operator. The previous state can be empty if the operator had no previous state.
-
getSubtaskJobManagerRestoredState
public Optional<OperatorSubtaskState> getSubtaskJobManagerRestoredState(OperatorID operatorID)
Description copied from interface:TaskStateManagerGet the restored state from jobManager which belongs to an operator running in the owning task.- Specified by:
getSubtaskJobManagerRestoredStatein interfaceTaskStateManager- Parameters:
operatorID- the id of the operator for which we request state.- Returns:
- the subtask restored state from jobManager.
-
createLocalRecoveryConfig
@Nonnull public LocalRecoveryConfig createLocalRecoveryConfig()
Description copied from interface:TaskStateManagerReturns the configuration for local recovery, i.e. the base directories for all file-based local state of the owning subtask and the general mode for local recovery.- Specified by:
createLocalRecoveryConfigin interfaceTaskStateManager
-
getSequentialChannelStateReader
public SequentialChannelStateReader getSequentialChannelStateReader()
- Specified by:
getSequentialChannelStateReaderin interfaceTaskStateManager
-
getStateChangelogStorage
@Nullable public StateChangelogStorage<?> getStateChangelogStorage()
Description copied from interface:TaskStateManagerReturns the configured state changelog storage for this task.- Specified by:
getStateChangelogStoragein interfaceTaskStateManager
-
getStateChangelogStorageView
@Nullable public StateChangelogStorageView<?> getStateChangelogStorageView(org.apache.flink.configuration.Configuration configuration, ChangelogStateHandle changelogStateHandle)
Description copied from interface:TaskStateManagerReturns the state changelog storage view of givenChangelogStateHandlefor this task.- Specified by:
getStateChangelogStorageViewin interfaceTaskStateManager
-
getFileMergingSnapshotManager
@Nullable public FileMergingSnapshotManager getFileMergingSnapshotManager()
- Specified by:
getFileMergingSnapshotManagerin interfaceTaskStateManager
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId) throws ExceptionTracking when local state can be confirmed and disposed.- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.common.state.CheckpointListener- Throws:
Exception
-
notifyCheckpointAborted
public void notifyCheckpointAborted(long checkpointId)
Tracking when some local state can be disposed.- Specified by:
notifyCheckpointAbortedin interfaceorg.apache.flink.api.common.state.CheckpointListener
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
-