Java Code Examples for org.apache.flink.runtime.executiongraph.ExecutionJobVertex#getJobVertexId()

The following examples show how to use org.apache.flink.runtime.executiongraph.ExecutionJobVertex#getJobVertexId() . 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: BackPressureStatsTrackerImplTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private ExecutionVertex mockExecutionVertex(
		ExecutionJobVertex jobVertex,
		int subTaskIndex) {

	Execution exec = Mockito.mock(Execution.class);
	Mockito.when(exec.getAttemptId()).thenReturn(new ExecutionAttemptID());

	JobVertexID id = jobVertex.getJobVertexId();

	ExecutionVertex vertex = Mockito.mock(ExecutionVertex.class);
	Mockito.when(vertex.getJobvertexId()).thenReturn(id);
	Mockito.when(vertex.getCurrentExecutionAttempt()).thenReturn(exec);
	Mockito.when(vertex.getParallelSubtaskIndex()).thenReturn(subTaskIndex);

	return vertex;
}
 
Example 2
Source File: BackPressureStatsTrackerImplTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private ExecutionVertex mockExecutionVertex(
		ExecutionJobVertex jobVertex,
		int subTaskIndex) {

	Execution exec = Mockito.mock(Execution.class);
	Mockito.when(exec.getAttemptId()).thenReturn(new ExecutionAttemptID());

	JobVertexID id = jobVertex.getJobVertexId();

	ExecutionVertex vertex = Mockito.mock(ExecutionVertex.class);
	Mockito.when(vertex.getJobvertexId()).thenReturn(id);
	Mockito.when(vertex.getCurrentExecutionAttempt()).thenReturn(exec);
	Mockito.when(vertex.getParallelSubtaskIndex()).thenReturn(subTaskIndex);

	return vertex;
}
 
Example 3
Source File: CheckpointStatsTracker.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an empty map with a {@link TaskStateStats} instance per task
 * that is involved in the checkpoint.
 *
 * @return An empty map with an {@link TaskStateStats} entry for each task that is involved in the checkpoint.
 */
private ConcurrentHashMap<JobVertexID, TaskStateStats> createEmptyTaskStateStatsMap() {
	ConcurrentHashMap<JobVertexID, TaskStateStats> taskStatsMap = new ConcurrentHashMap<>(jobVertices.size());
	for (ExecutionJobVertex vertex : jobVertices) {
		TaskStateStats taskStats = new TaskStateStats(vertex.getJobVertexId(), vertex.getParallelism());
		taskStatsMap.put(vertex.getJobVertexId(), taskStats);
	}
	return taskStatsMap;
}
 
Example 4
Source File: StateAssignmentOperation.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies conditions in regards to parallelism and maxParallelism that must be met when restoring state.
 *
 * @param operatorState      state to restore
 * @param executionJobVertex task for which the state should be restored
 */
private static void checkParallelismPreconditions(OperatorState operatorState, ExecutionJobVertex executionJobVertex) {
	//----------------------------------------max parallelism preconditions-------------------------------------

	if (operatorState.getMaxParallelism() < executionJobVertex.getParallelism()) {
		throw new IllegalStateException("The state for task " + executionJobVertex.getJobVertexId() +
			" can not be restored. The maximum parallelism (" + operatorState.getMaxParallelism() +
			") of the restored state is lower than the configured parallelism (" + executionJobVertex.getParallelism() +
			"). Please reduce the parallelism of the task to be lower or equal to the maximum parallelism."
		);
	}

	// check that the number of key groups have not changed or if we need to override it to satisfy the restored state
	if (operatorState.getMaxParallelism() != executionJobVertex.getMaxParallelism()) {

		if (!executionJobVertex.isMaxParallelismConfigured()) {
			// if the max parallelism was not explicitly specified by the user, we derive it from the state

			LOG.debug("Overriding maximum parallelism for JobVertex {} from {} to {}",
				executionJobVertex.getJobVertexId(), executionJobVertex.getMaxParallelism(), operatorState.getMaxParallelism());

			executionJobVertex.setMaxParallelism(operatorState.getMaxParallelism());
		} else {
			// if the max parallelism was explicitly specified, we complain on mismatch
			throw new IllegalStateException("The maximum parallelism (" +
				operatorState.getMaxParallelism() + ") with which the latest " +
				"checkpoint of the execution job vertex " + executionJobVertex +
				" has been taken and the current maximum parallelism (" +
				executionJobVertex.getMaxParallelism() + ") changed. This " +
				"is currently not supported.");
		}
	}
}
 
Example 5
Source File: CheckpointStatsTracker.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an empty map with a {@link TaskStateStats} instance per task
 * that is involved in the checkpoint.
 *
 * @return An empty map with an {@link TaskStateStats} entry for each task that is involved in the checkpoint.
 */
private ConcurrentHashMap<JobVertexID, TaskStateStats> createEmptyTaskStateStatsMap() {
	ConcurrentHashMap<JobVertexID, TaskStateStats> taskStatsMap = new ConcurrentHashMap<>(jobVertices.size());
	for (ExecutionJobVertex vertex : jobVertices) {
		TaskStateStats taskStats = new TaskStateStats(vertex.getJobVertexId(), vertex.getParallelism());
		taskStatsMap.put(vertex.getJobVertexId(), taskStats);
	}
	return taskStatsMap;
}
 
Example 6
Source File: StateAssignmentOperation.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies conditions in regards to parallelism and maxParallelism that must be met when restoring state.
 *
 * @param operatorState      state to restore
 * @param executionJobVertex task for which the state should be restored
 */
private static void checkParallelismPreconditions(OperatorState operatorState, ExecutionJobVertex executionJobVertex) {
	//----------------------------------------max parallelism preconditions-------------------------------------

	if (operatorState.getMaxParallelism() < executionJobVertex.getParallelism()) {
		throw new IllegalStateException("The state for task " + executionJobVertex.getJobVertexId() +
			" can not be restored. The maximum parallelism (" + operatorState.getMaxParallelism() +
			") of the restored state is lower than the configured parallelism (" + executionJobVertex.getParallelism() +
			"). Please reduce the parallelism of the task to be lower or equal to the maximum parallelism."
		);
	}

	// check that the number of key groups have not changed or if we need to override it to satisfy the restored state
	if (operatorState.getMaxParallelism() != executionJobVertex.getMaxParallelism()) {

		if (!executionJobVertex.isMaxParallelismConfigured()) {
			// if the max parallelism was not explicitly specified by the user, we derive it from the state

			LOG.debug("Overriding maximum parallelism for JobVertex {} from {} to {}",
				executionJobVertex.getJobVertexId(), executionJobVertex.getMaxParallelism(), operatorState.getMaxParallelism());

			executionJobVertex.setMaxParallelism(operatorState.getMaxParallelism());
		} else {
			// if the max parallelism was explicitly specified, we complain on mismatch
			throw new IllegalStateException("The maximum parallelism (" +
				operatorState.getMaxParallelism() + ") with which the latest " +
				"checkpoint of the execution job vertex " + executionJobVertex +
				" has been taken and the current maximum parallelism (" +
				executionJobVertex.getMaxParallelism() + ") changed. This " +
				"is currently not supported.");
		}
	}
}
 
Example 7
Source File: CheckpointStatsTracker.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an empty map with a {@link TaskStateStats} instance per task
 * that is involved in the checkpoint.
 *
 * @return An empty map with an {@link TaskStateStats} entry for each task that is involved in the checkpoint.
 */
private ConcurrentHashMap<JobVertexID, TaskStateStats> createEmptyTaskStateStatsMap() {
	ConcurrentHashMap<JobVertexID, TaskStateStats> taskStatsMap = new ConcurrentHashMap<>(jobVertices.size());
	for (ExecutionJobVertex vertex : jobVertices) {
		TaskStateStats taskStats = new TaskStateStats(vertex.getJobVertexId(), vertex.getParallelism());
		taskStatsMap.put(vertex.getJobVertexId(), taskStats);
	}
	return taskStatsMap;
}
 
Example 8
Source File: StateAssignmentOperation.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies conditions in regards to parallelism and maxParallelism that must be met when restoring state.
 *
 * @param operatorState      state to restore
 * @param executionJobVertex task for which the state should be restored
 */
private static void checkParallelismPreconditions(OperatorState operatorState, ExecutionJobVertex executionJobVertex) {
	//----------------------------------------max parallelism preconditions-------------------------------------

	if (operatorState.getMaxParallelism() < executionJobVertex.getParallelism()) {
		throw new IllegalStateException("The state for task " + executionJobVertex.getJobVertexId() +
			" can not be restored. The maximum parallelism (" + operatorState.getMaxParallelism() +
			") of the restored state is lower than the configured parallelism (" + executionJobVertex.getParallelism() +
			"). Please reduce the parallelism of the task to be lower or equal to the maximum parallelism."
		);
	}

	// check that the number of key groups have not changed or if we need to override it to satisfy the restored state
	if (operatorState.getMaxParallelism() != executionJobVertex.getMaxParallelism()) {

		if (!executionJobVertex.isMaxParallelismConfigured()) {
			// if the max parallelism was not explicitly specified by the user, we derive it from the state

			LOG.debug("Overriding maximum parallelism for JobVertex {} from {} to {}",
				executionJobVertex.getJobVertexId(), executionJobVertex.getMaxParallelism(), operatorState.getMaxParallelism());

			executionJobVertex.setMaxParallelism(operatorState.getMaxParallelism());
		} else {
			// if the max parallelism was explicitly specified, we complain on mismatch
			throw new IllegalStateException("The maximum parallelism (" +
				operatorState.getMaxParallelism() + ") with which the latest " +
				"checkpoint of the execution job vertex " + executionJobVertex +
				" has been taken and the current maximum parallelism (" +
				executionJobVertex.getMaxParallelism() + ") changed. This " +
				"is currently not supported.");
		}
	}
}