use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class JobStatusMetrics method registerMetrics.
@Override
public void registerMetrics(MetricGroup metricGroup) {
for (JobStatus jobStatus : JobStatus.values()) {
if (!jobStatus.isTerminalState() && jobStatus != JobStatus.RECONCILING) {
final StateTimeMetric stateTimeMetric = createTimeMetric(jobStatus);
StateTimeMetric.register(jobStatusMetricsSettings, metricGroup, stateTimeMetric, getBaseMetricName(jobStatus));
}
}
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class DefaultSchedulerTest method cancelWhileRestartingShouldWaitForRunningTasks.
@Test
public void cancelWhileRestartingShouldWaitForRunningTasks() {
final JobGraph jobGraph = singleJobVertexJobGraph(2);
final DefaultScheduler scheduler = createSchedulerAndStartScheduling(jobGraph);
final SchedulingTopology topology = scheduler.getSchedulingTopology();
final Iterator<ArchivedExecutionVertex> vertexIterator = scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices().iterator();
final ExecutionAttemptID attemptId1 = vertexIterator.next().getCurrentExecutionAttempt().getAttemptId();
final ExecutionAttemptID attemptId2 = vertexIterator.next().getCurrentExecutionAttempt().getAttemptId();
final ExecutionVertexID executionVertex2 = scheduler.getExecutionVertexIdOrThrow(attemptId2);
scheduler.updateTaskExecutionState(new TaskExecutionState(attemptId1, ExecutionState.FAILED, new RuntimeException("expected")));
scheduler.cancel();
final ExecutionState vertex2StateAfterCancel = topology.getVertex(executionVertex2).getState();
final JobStatus statusAfterCancelWhileRestarting = scheduler.requestJobStatus();
scheduler.updateTaskExecutionState(new TaskExecutionState(attemptId2, ExecutionState.CANCELED, new RuntimeException("expected")));
assertThat(vertex2StateAfterCancel, is(equalTo(ExecutionState.CANCELING)));
assertThat(statusAfterCancelWhileRestarting, is(equalTo(JobStatus.CANCELLING)));
assertThat(scheduler.requestJobStatus(), is(equalTo(JobStatus.CANCELED)));
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class DownTimeGauge method getValue.
// ------------------------------------------------------------------------
@Override
public Long getValue() {
final JobStatus status = jobStatusProvider.getState();
// not running any more -> finished or not on leader
if (status.isTerminalState()) {
return NO_LONGER_RUNNING;
}
final long runningTimestamp = jobStatusProvider.getStatusTimestamp(JobStatus.RUNNING);
final long failingTimestamp = jobStatusProvider.getStatusTimestamp(JobStatus.FAILING);
if (failingTimestamp <= runningTimestamp) {
return NOT_FAILING;
} else {
// we use 'Math.max' here to avoid negative timestamps when clocks change
return Math.max(System.currentTimeMillis() - failingTimestamp, 0);
}
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class JobMaster method jobStatusChanged.
private void jobStatusChanged(final JobStatus newJobStatus) {
validateRunsInMainThread();
if (newJobStatus.isGloballyTerminalState()) {
runAsync(() -> {
Collection<ResultPartitionID> allTracked = partitionTracker.getAllTrackedPartitions().stream().map(d -> d.getShuffleDescriptor().getResultPartitionID()).collect(Collectors.toList());
if (newJobStatus == JobStatus.FINISHED) {
partitionTracker.stopTrackingAndReleaseOrPromotePartitions(allTracked);
} else {
partitionTracker.stopTrackingAndReleasePartitions(allTracked);
}
});
final ExecutionGraphInfo executionGraphInfo = schedulerNG.requestJob();
futureExecutor.execute(() -> jobCompletionActions.jobReachedGloballyTerminalState(executionGraphInfo));
}
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class DispatcherTest method testCacheJobExecutionResult.
/**
* Test that {@link JobResult} is cached when the job finishes.
*/
@Test
public void testCacheJobExecutionResult() throws Exception {
dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(jobId, createdJobManagerRunnerLatch));
final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
final JobID failedJobId = new JobID();
final JobStatus expectedState = JobStatus.FAILED;
final ExecutionGraphInfo failedExecutionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(failedJobId).setState(expectedState).setFailureCause(new ErrorInfo(new RuntimeException("expected"), 1L)).build());
dispatcher.completeJobExecution(failedExecutionGraphInfo);
assertThat(dispatcherGateway.requestJobStatus(failedJobId, TIMEOUT).get(), equalTo(expectedState));
assertThat(dispatcherGateway.requestExecutionGraphInfo(failedJobId, TIMEOUT).get(), equalTo(failedExecutionGraphInfo));
}
Aggregations