Search in sources :

Example 6 with PrioritizedOperatorSubtaskState

use of org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState in project flink by apache.

the class TaskStateManagerImpl method prioritizedOperatorState.

@Override
public PrioritizedOperatorSubtaskState prioritizedOperatorState(OperatorID operatorID) {
    if (jobManagerTaskRestore == null) {
        return PrioritizedOperatorSubtaskState.emptyNotRestored();
    }
    TaskStateSnapshot jobManagerStateSnapshot = jobManagerTaskRestore.getTaskStateSnapshot();
    OperatorSubtaskState jobManagerSubtaskState = jobManagerStateSnapshot.getSubtaskStateByOperatorID(operatorID);
    if (jobManagerSubtaskState == null) {
        return PrioritizedOperatorSubtaskState.empty(jobManagerTaskRestore.getRestoreCheckpointId());
    }
    long restoreCheckpointId = jobManagerTaskRestore.getRestoreCheckpointId();
    TaskStateSnapshot localStateSnapshot = localStateStore.retrieveLocalState(restoreCheckpointId);
    localStateStore.pruneMatchingCheckpoints((long checkpointId) -> checkpointId != restoreCheckpointId);
    List<OperatorSubtaskState> alternativesByPriority = Collections.emptyList();
    if (localStateSnapshot != null) {
        OperatorSubtaskState localSubtaskState = localStateSnapshot.getSubtaskStateByOperatorID(operatorID);
        if (localSubtaskState != null) {
            alternativesByPriority = Collections.singletonList(localSubtaskState);
        }
    }
    LOG.debug("Operator {} has remote state {} from job manager and local state alternatives {} from local " + "state store {}.", operatorID, jobManagerSubtaskState, alternativesByPriority, localStateStore);
    PrioritizedOperatorSubtaskState.Builder builder = new PrioritizedOperatorSubtaskState.Builder(jobManagerSubtaskState, alternativesByPriority, jobManagerTaskRestore.getRestoreCheckpointId());
    return builder.build();
}
Also used : TaskStateSnapshot(org.apache.flink.runtime.checkpoint.TaskStateSnapshot) PrioritizedOperatorSubtaskState(org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState) PrioritizedOperatorSubtaskState(org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState) OperatorSubtaskState(org.apache.flink.runtime.checkpoint.OperatorSubtaskState)

Aggregations

PrioritizedOperatorSubtaskState (org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState)6 OperatorSubtaskState (org.apache.flink.runtime.checkpoint.OperatorSubtaskState)3 TaskStateSnapshot (org.apache.flink.runtime.checkpoint.TaskStateSnapshot)3 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 JobID (org.apache.flink.api.common.JobID)1 TaskInfo (org.apache.flink.api.common.TaskInfo)1 Configuration (org.apache.flink.configuration.Configuration)1 CloseableRegistry (org.apache.flink.core.fs.CloseableRegistry)1 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)1 CheckpointMetrics (org.apache.flink.runtime.checkpoint.CheckpointMetrics)1 JobManagerTaskRestore (org.apache.flink.runtime.checkpoint.JobManagerTaskRestore)1 OperatorState (org.apache.flink.runtime.checkpoint.OperatorState)1 StateObjectCollection (org.apache.flink.runtime.checkpoint.StateObjectCollection)1 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)1 DefaultOperatorStateBackend (org.apache.flink.runtime.state.DefaultOperatorStateBackend)1