Java Code Examples for org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState#emptyNotRestored()

The following examples show how to use org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState#emptyNotRestored() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTaskStateManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public PrioritizedOperatorSubtaskState prioritizedOperatorState(OperatorID operatorID) {
	TaskStateSnapshot jmTaskStateSnapshot = getLastJobManagerTaskStateSnapshot();
	TaskStateSnapshot tmTaskStateSnapshot = getLastTaskManagerTaskStateSnapshot();

	if (jmTaskStateSnapshot == null) {

		return PrioritizedOperatorSubtaskState.emptyNotRestored();
	} else {

		OperatorSubtaskState jmOpState = jmTaskStateSnapshot.getSubtaskStateByOperatorID(operatorID);

		if (jmOpState == null) {

			return PrioritizedOperatorSubtaskState.emptyNotRestored();
		} else {

			List<OperatorSubtaskState> tmStateCollection = Collections.emptyList();

			if (tmTaskStateSnapshot != null) {
				OperatorSubtaskState tmOpState = tmTaskStateSnapshot.getSubtaskStateByOperatorID(operatorID);
				if (tmOpState != null) {
					tmStateCollection = Collections.singletonList(tmOpState);
				}
			}
			PrioritizedOperatorSubtaskState.Builder builder =
				new PrioritizedOperatorSubtaskState.Builder(jmOpState, tmStateCollection);
			return builder.build();
		}
	}
}
 
Example 2
Source File: SavepointEnvironment.java    From flink with Apache License 2.0 5 votes vote down vote up
public Builder(RuntimeContext ctx, int maxParallelism) {
	this.ctx = Preconditions.checkNotNull(ctx);

	Preconditions.checkArgument(maxParallelism > 0);
	this.maxParallelism = maxParallelism;

	this.prioritizedOperatorSubtaskState = PrioritizedOperatorSubtaskState.emptyNotRestored();
	this.configuration = new Configuration();
	this.indexOfSubtask = ctx.getIndexOfThisSubtask();
}
 
Example 3
Source File: TestTaskStateManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public PrioritizedOperatorSubtaskState prioritizedOperatorState(OperatorID operatorID) {
	TaskStateSnapshot jmTaskStateSnapshot = getLastJobManagerTaskStateSnapshot();
	TaskStateSnapshot tmTaskStateSnapshot = getLastTaskManagerTaskStateSnapshot();

	if (jmTaskStateSnapshot == null) {

		return PrioritizedOperatorSubtaskState.emptyNotRestored();
	} else {

		OperatorSubtaskState jmOpState = jmTaskStateSnapshot.getSubtaskStateByOperatorID(operatorID);

		if (jmOpState == null) {

			return PrioritizedOperatorSubtaskState.emptyNotRestored();
		} else {

			List<OperatorSubtaskState> tmStateCollection = Collections.emptyList();

			if (tmTaskStateSnapshot != null) {
				OperatorSubtaskState tmOpState = tmTaskStateSnapshot.getSubtaskStateByOperatorID(operatorID);
				if (tmOpState != null) {
					tmStateCollection = Collections.singletonList(tmOpState);
				}
			}
			PrioritizedOperatorSubtaskState.Builder builder =
				new PrioritizedOperatorSubtaskState.Builder(jmOpState, tmStateCollection);
			return builder.build();
		}
	}
}
 
Example 4
Source File: SavepointEnvironment.java    From flink with Apache License 2.0 5 votes vote down vote up
public Builder(RuntimeContext ctx, int maxParallelism) {
	this.ctx = Preconditions.checkNotNull(ctx);

	Preconditions.checkArgument(maxParallelism > 0);
	this.maxParallelism = maxParallelism;

	this.prioritizedOperatorSubtaskState = PrioritizedOperatorSubtaskState.emptyNotRestored();
	this.configuration = new Configuration();
	this.indexOfSubtask = ctx.getIndexOfThisSubtask();
}
 
Example 5
Source File: TestTaskStateManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public PrioritizedOperatorSubtaskState prioritizedOperatorState(OperatorID operatorID) {
	TaskStateSnapshot jmTaskStateSnapshot = getLastJobManagerTaskStateSnapshot();
	TaskStateSnapshot tmTaskStateSnapshot = getLastTaskManagerTaskStateSnapshot();

	if (jmTaskStateSnapshot == null) {

		return PrioritizedOperatorSubtaskState.emptyNotRestored();
	} else {

		OperatorSubtaskState jmOpState = jmTaskStateSnapshot.getSubtaskStateByOperatorID(operatorID);

		if (jmOpState == null) {

			return PrioritizedOperatorSubtaskState.emptyNotRestored();
		} else {

			List<OperatorSubtaskState> tmStateCollection = Collections.emptyList();

			if (tmTaskStateSnapshot != null) {
				OperatorSubtaskState tmOpState = tmTaskStateSnapshot.getSubtaskStateByOperatorID(operatorID);
				if (tmOpState != null) {
					tmStateCollection = Collections.singletonList(tmOpState);
				}
			}
			PrioritizedOperatorSubtaskState.Builder builder =
				new PrioritizedOperatorSubtaskState.Builder(jmOpState, tmStateCollection);
			return builder.build();
		}
	}
}
 
Example 6
Source File: TaskStateManagerImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Nonnull
@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.emptyNotRestored();
	}

	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,
		true);

	return builder.build();
}
 
Example 7
Source File: TaskStateManagerImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
@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.emptyNotRestored();
	}

	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,
		true);

	return builder.build();
}
 
Example 8
Source File: TaskStateManagerImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
@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.emptyNotRestored();
	}

	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,
		true);

	return builder.build();
}