Java Code Examples for org.apache.flink.runtime.executiongraph.AccessExecutionGraph#getState()

The following examples show how to use org.apache.flink.runtime.executiongraph.AccessExecutionGraph#getState() . 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: WebMonitorUtils.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static JobDetails createDetailsForJob(AccessExecutionGraph job) {
	JobStatus status = job.getState();

	long started = job.getStatusTimestamp(JobStatus.CREATED);
	long finished = status.isGloballyTerminalState() ? job.getStatusTimestamp(status) : -1L;
	long duration = (finished >= 0L ? finished : System.currentTimeMillis()) - started;

	int[] countsPerStatus = new int[ExecutionState.values().length];
	long lastChanged = 0;
	int numTotalTasks = 0;

	for (AccessExecutionJobVertex ejv : job.getVerticesTopologically()) {
		AccessExecutionVertex[] vertices = ejv.getTaskVertices();
		numTotalTasks += vertices.length;

		for (AccessExecutionVertex vertex : vertices) {
			ExecutionState state = vertex.getExecutionState();
			countsPerStatus[state.ordinal()]++;
			lastChanged = Math.max(lastChanged, vertex.getStateTimestamp(state));
		}
	}

	lastChanged = Math.max(lastChanged, finished);

	return new JobDetails(
		job.getJobID(),
		job.getJobName(),
		started,
		finished,
		duration,
		status,
		lastChanged,
		countsPerStatus,
		numTotalTasks);
}
 
Example 2
Source File: JobResult.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the {@link JobResult} from the given {@link AccessExecutionGraph} which
 * must be in a globally terminal state.
 *
 * @param accessExecutionGraph to create the JobResult from
 * @return JobResult of the given AccessExecutionGraph
 */
public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) {
	final JobID jobId = accessExecutionGraph.getJobID();
	final JobStatus jobStatus = accessExecutionGraph.getState();

	checkArgument(
		jobStatus.isGloballyTerminalState(),
		"The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a globally " +
			"terminal state. It is in state " + jobStatus + '.');

	final JobResult.Builder builder = new JobResult.Builder();
	builder.jobId(jobId);

	builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState()));

	final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.CREATED);
	// guard against clock changes
	final long guardedNetRuntime = Math.max(netRuntime, 0L);
	builder.netRuntime(guardedNetRuntime);
	builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized());

	if (jobStatus != JobStatus.FINISHED) {
		final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo();

		if (errorInfo != null) {
			builder.serializedThrowable(errorInfo.getException());
		}
	}

	return builder.build();
}
 
Example 3
Source File: WebMonitorUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
public static JobDetails createDetailsForJob(AccessExecutionGraph job) {
	JobStatus status = job.getState();

	long started = job.getStatusTimestamp(JobStatus.CREATED);
	long finished = status.isGloballyTerminalState() ? job.getStatusTimestamp(status) : -1L;
	long duration = (finished >= 0L ? finished : System.currentTimeMillis()) - started;

	int[] countsPerStatus = new int[ExecutionState.values().length];
	long lastChanged = 0;
	int numTotalTasks = 0;

	for (AccessExecutionJobVertex ejv : job.getVerticesTopologically()) {
		AccessExecutionVertex[] vertices = ejv.getTaskVertices();
		numTotalTasks += vertices.length;

		for (AccessExecutionVertex vertex : vertices) {
			ExecutionState state = vertex.getExecutionState();
			countsPerStatus[state.ordinal()]++;
			lastChanged = Math.max(lastChanged, vertex.getStateTimestamp(state));
		}
	}

	lastChanged = Math.max(lastChanged, finished);

	return new JobDetails(
		job.getJobID(),
		job.getJobName(),
		started,
		finished,
		duration,
		status,
		lastChanged,
		countsPerStatus,
		numTotalTasks);
}
 
Example 4
Source File: JobResult.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the {@link JobResult} from the given {@link AccessExecutionGraph} which
 * must be in a globally terminal state.
 *
 * @param accessExecutionGraph to create the JobResult from
 * @return JobResult of the given AccessExecutionGraph
 */
public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) {
	final JobID jobId = accessExecutionGraph.getJobID();
	final JobStatus jobStatus = accessExecutionGraph.getState();

	checkArgument(
		jobStatus.isGloballyTerminalState(),
		"The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a globally " +
			"terminal state. It is in state " + jobStatus + '.');

	final JobResult.Builder builder = new JobResult.Builder();
	builder.jobId(jobId);

	builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState()));

	final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.CREATED);
	// guard against clock changes
	final long guardedNetRuntime = Math.max(netRuntime, 0L);
	builder.netRuntime(guardedNetRuntime);
	builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized());

	if (jobStatus != JobStatus.FINISHED) {
		final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo();

		if (errorInfo != null) {
			builder.serializedThrowable(errorInfo.getException());
		}
	}

	return builder.build();
}
 
Example 5
Source File: WebMonitorUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
public static JobDetails createDetailsForJob(AccessExecutionGraph job) {
	JobStatus status = job.getState();

	long started = job.getStatusTimestamp(JobStatus.CREATED);
	long finished = status.isGloballyTerminalState() ? job.getStatusTimestamp(status) : -1L;
	long duration = (finished >= 0L ? finished : System.currentTimeMillis()) - started;

	int[] countsPerStatus = new int[ExecutionState.values().length];
	long lastChanged = 0;
	int numTotalTasks = 0;

	for (AccessExecutionJobVertex ejv : job.getVerticesTopologically()) {
		AccessExecutionVertex[] vertices = ejv.getTaskVertices();
		numTotalTasks += vertices.length;

		for (AccessExecutionVertex vertex : vertices) {
			ExecutionState state = vertex.getExecutionState();
			countsPerStatus[state.ordinal()]++;
			lastChanged = Math.max(lastChanged, vertex.getStateTimestamp(state));
		}
	}

	lastChanged = Math.max(lastChanged, finished);

	return new JobDetails(
		job.getJobID(),
		job.getJobName(),
		started,
		finished,
		duration,
		status,
		lastChanged,
		countsPerStatus,
		numTotalTasks);
}
 
Example 6
Source File: JobResult.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the {@link JobResult} from the given {@link AccessExecutionGraph} which
 * must be in a globally terminal state.
 *
 * @param accessExecutionGraph to create the JobResult from
 * @return JobResult of the given AccessExecutionGraph
 */
public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) {
	final JobID jobId = accessExecutionGraph.getJobID();
	final JobStatus jobStatus = accessExecutionGraph.getState();

	checkArgument(
		jobStatus.isGloballyTerminalState(),
		"The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a globally " +
			"terminal state. It is in state " + jobStatus + '.');

	final JobResult.Builder builder = new JobResult.Builder();
	builder.jobId(jobId);

	builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState()));

	final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.CREATED);
	// guard against clock changes
	final long guardedNetRuntime = Math.max(netRuntime, 0L);
	builder.netRuntime(guardedNetRuntime);
	builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized());

	if (jobStatus == JobStatus.FAILED) {
		final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo();
		checkNotNull(errorInfo, "No root cause is found for the job failure.");

		builder.serializedThrowable(errorInfo.getException());
	}

	return builder.build();
}
 
Example 7
Source File: JobDetailsHandler.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static JobDetailsInfo createJobDetailsInfo(AccessExecutionGraph executionGraph, @Nullable MetricFetcher metricFetcher) {
	final long now = System.currentTimeMillis();
	final long startTime = executionGraph.getStatusTimestamp(JobStatus.CREATED);
	final long endTime = executionGraph.getState().isGloballyTerminalState() ?
		executionGraph.getStatusTimestamp(executionGraph.getState()) : -1L;
	final long duration = (endTime > 0L ? endTime : now) - startTime;

	final Map<JobStatus, Long> timestamps = new HashMap<>(JobStatus.values().length);

	for (JobStatus jobStatus : JobStatus.values()) {
		timestamps.put(jobStatus, executionGraph.getStatusTimestamp(jobStatus));
	}

	Collection<JobDetailsInfo.JobVertexDetailsInfo> jobVertexInfos = new ArrayList<>(executionGraph.getAllVertices().size());
	int[] jobVerticesPerState = new int[ExecutionState.values().length];

	for (AccessExecutionJobVertex accessExecutionJobVertex : executionGraph.getVerticesTopologically()) {
		final JobDetailsInfo.JobVertexDetailsInfo vertexDetailsInfo = createJobVertexDetailsInfo(
			accessExecutionJobVertex,
			now,
			executionGraph.getJobID(),
			metricFetcher);

		jobVertexInfos.add(vertexDetailsInfo);
		jobVerticesPerState[vertexDetailsInfo.getExecutionState().ordinal()]++;
	}

	Map<ExecutionState, Integer> jobVerticesPerStateMap = new HashMap<>(ExecutionState.values().length);

	for (ExecutionState executionState : ExecutionState.values()) {
		jobVerticesPerStateMap.put(executionState, jobVerticesPerState[executionState.ordinal()]);
	}

	return new JobDetailsInfo(
		executionGraph.getJobID(),
		executionGraph.getJobName(),
		executionGraph.isStoppable(),
		executionGraph.getState(),
		startTime,
		endTime,
		duration,
		now,
		timestamps,
		jobVertexInfos,
		jobVerticesPerStateMap,
		executionGraph.getJsonPlan());
}
 
Example 8
Source File: JobDetailsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static JobDetailsInfo createJobDetailsInfo(AccessExecutionGraph executionGraph, @Nullable MetricFetcher metricFetcher) {
	final long now = System.currentTimeMillis();
	final long startTime = executionGraph.getStatusTimestamp(JobStatus.CREATED);
	final long endTime = executionGraph.getState().isGloballyTerminalState() ?
		executionGraph.getStatusTimestamp(executionGraph.getState()) : -1L;
	final long duration = (endTime > 0L ? endTime : now) - startTime;

	final Map<JobStatus, Long> timestamps = new HashMap<>(JobStatus.values().length);

	for (JobStatus jobStatus : JobStatus.values()) {
		timestamps.put(jobStatus, executionGraph.getStatusTimestamp(jobStatus));
	}

	Collection<JobDetailsInfo.JobVertexDetailsInfo> jobVertexInfos = new ArrayList<>(executionGraph.getAllVertices().size());
	int[] jobVerticesPerState = new int[ExecutionState.values().length];

	for (AccessExecutionJobVertex accessExecutionJobVertex : executionGraph.getVerticesTopologically()) {
		final JobDetailsInfo.JobVertexDetailsInfo vertexDetailsInfo = createJobVertexDetailsInfo(
			accessExecutionJobVertex,
			now,
			executionGraph.getJobID(),
			metricFetcher);

		jobVertexInfos.add(vertexDetailsInfo);
		jobVerticesPerState[vertexDetailsInfo.getExecutionState().ordinal()]++;
	}

	Map<ExecutionState, Integer> jobVerticesPerStateMap = new HashMap<>(ExecutionState.values().length);

	for (ExecutionState executionState : ExecutionState.values()) {
		jobVerticesPerStateMap.put(executionState, jobVerticesPerState[executionState.ordinal()]);
	}

	return new JobDetailsInfo(
		executionGraph.getJobID(),
		executionGraph.getJobName(),
		executionGraph.isStoppable(),
		executionGraph.getState(),
		startTime,
		endTime,
		duration,
		now,
		timestamps,
		jobVertexInfos,
		jobVerticesPerStateMap,
		executionGraph.getJsonPlan());
}
 
Example 9
Source File: JobDetailsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static JobDetailsInfo createJobDetailsInfo(AccessExecutionGraph executionGraph, @Nullable MetricFetcher metricFetcher) {
	final long now = System.currentTimeMillis();
	final long startTime = executionGraph.getStatusTimestamp(JobStatus.CREATED);
	final long endTime = executionGraph.getState().isGloballyTerminalState() ?
		executionGraph.getStatusTimestamp(executionGraph.getState()) : -1L;
	final long duration = (endTime > 0L ? endTime : now) - startTime;

	final Map<JobStatus, Long> timestamps = new HashMap<>(JobStatus.values().length);

	for (JobStatus jobStatus : JobStatus.values()) {
		timestamps.put(jobStatus, executionGraph.getStatusTimestamp(jobStatus));
	}

	Collection<JobDetailsInfo.JobVertexDetailsInfo> jobVertexInfos = new ArrayList<>(executionGraph.getAllVertices().size());
	int[] jobVerticesPerState = new int[ExecutionState.values().length];

	for (AccessExecutionJobVertex accessExecutionJobVertex : executionGraph.getVerticesTopologically()) {
		final JobDetailsInfo.JobVertexDetailsInfo vertexDetailsInfo = createJobVertexDetailsInfo(
			accessExecutionJobVertex,
			now,
			executionGraph.getJobID(),
			metricFetcher);

		jobVertexInfos.add(vertexDetailsInfo);
		jobVerticesPerState[vertexDetailsInfo.getExecutionState().ordinal()]++;
	}

	Map<ExecutionState, Integer> jobVerticesPerStateMap = new HashMap<>(ExecutionState.values().length);

	for (ExecutionState executionState : ExecutionState.values()) {
		jobVerticesPerStateMap.put(executionState, jobVerticesPerState[executionState.ordinal()]);
	}

	return new JobDetailsInfo(
		executionGraph.getJobID(),
		executionGraph.getJobName(),
		executionGraph.isStoppable(),
		executionGraph.getState(),
		startTime,
		endTime,
		duration,
		now,
		timestamps,
		jobVertexInfos,
		jobVerticesPerStateMap,
		executionGraph.getJsonPlan());
}