use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class AbstractHAJobRunITCase method testJobExecutionInHaMode.
@Test
public void testJobExecutionInHaMode(@InjectMiniCluster MiniCluster flinkCluster) throws Exception {
final JobGraph jobGraph = JobGraphTestUtils.singleNoOpJobGraph();
// providing a timeout helps making the test fail in case some issue occurred while
// initializing the cluster
flinkCluster.submitJob(jobGraph).get(30, TimeUnit.SECONDS);
final Deadline deadline = Deadline.fromNow(Duration.ofSeconds(30));
final JobStatus jobStatus = FutureUtils.retrySuccessfulWithDelay(() -> flinkCluster.getJobStatus(jobGraph.getJobID()), Time.milliseconds(10), deadline, status -> flinkCluster.isRunning() && status == JobStatus.FINISHED, TestingUtils.defaultScheduledExecutor()).get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS);
assertThat(jobStatus).isEqualTo(JobStatus.FINISHED);
runAfterJobTermination();
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class WebMonitorMessagesTest method testJobDetailsMessage.
@Test
public void testJobDetailsMessage() {
try {
final Random rnd = new Random();
int[] numVerticesPerState = new int[ExecutionState.values().length];
int numTotal = 0;
for (int i = 0; i < numVerticesPerState.length; i++) {
int count = rnd.nextInt(55);
numVerticesPerState[i] = count;
numTotal += count;
}
long time = rnd.nextLong();
long endTime = rnd.nextBoolean() ? -1L : time + rnd.nextInt();
long lastModified = endTime == -1 ? time + rnd.nextInt() : endTime;
String name = GenericMessageTester.randomString(rnd);
JobID jid = GenericMessageTester.randomJobId(rnd);
JobStatus status = GenericMessageTester.randomJobStatus(rnd);
JobDetails msg1 = new JobDetails(jid, name, time, endTime, endTime - time, status, lastModified, numVerticesPerState, numTotal);
JobDetails msg2 = new JobDetails(jid, name, time, endTime, endTime - time, status, lastModified, numVerticesPerState, numTotal);
GenericMessageTester.testMessageInstances(msg1, msg2);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class Dispatcher method requestClusterOverview.
@Override
public CompletableFuture<ClusterOverview> requestClusterOverview(Time timeout) {
CompletableFuture<ResourceOverview> taskManagerOverviewFuture = runResourceManagerCommand(resourceManagerGateway -> resourceManagerGateway.requestResourceOverview(timeout));
final List<CompletableFuture<Optional<JobStatus>>> optionalJobInformation = queryJobMastersForInformation(jobManagerRunner -> jobManagerRunner.requestJobStatus(timeout));
CompletableFuture<Collection<Optional<JobStatus>>> allOptionalJobsFuture = FutureUtils.combineAll(optionalJobInformation);
CompletableFuture<Collection<JobStatus>> allJobsFuture = allOptionalJobsFuture.thenApply(this::flattenOptionalCollection);
final JobsOverview completedJobsOverview = executionGraphInfoStore.getStoredJobsOverview();
return allJobsFuture.thenCombine(taskManagerOverviewFuture, (Collection<JobStatus> runningJobsStatus, ResourceOverview resourceOverview) -> {
final JobsOverview allJobsOverview = JobsOverview.create(runningJobsStatus).combine(completedJobsOverview);
return new ClusterOverview(resourceOverview, allJobsOverview);
});
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class Dispatcher method cancelJob.
@Override
public CompletableFuture<Acknowledge> cancelJob(JobID jobId, Time timeout) {
Optional<JobManagerRunner> maybeJob = getJobManagerRunner(jobId);
if (maybeJob.isPresent()) {
return maybeJob.get().cancel(timeout);
}
final ExecutionGraphInfo executionGraphInfo = executionGraphInfoStore.get(jobId);
if (executionGraphInfo != null) {
final JobStatus jobStatus = executionGraphInfo.getArchivedExecutionGraph().getState();
if (jobStatus == JobStatus.CANCELED) {
return CompletableFuture.completedFuture(Acknowledge.get());
} else {
return FutureUtils.completedExceptionally(new FlinkJobTerminatedWithoutCancellationException(jobId, jobStatus));
}
}
log.debug("Dispatcher is unable to cancel job {}: not found", jobId);
return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
}
use of org.apache.flink.api.common.JobStatus in project flink by apache.
the class FileExecutionGraphInfoStore method put.
@Override
public void put(ExecutionGraphInfo executionGraphInfo) throws IOException {
final JobID jobId = executionGraphInfo.getJobId();
final ArchivedExecutionGraph archivedExecutionGraph = executionGraphInfo.getArchivedExecutionGraph();
final JobStatus jobStatus = archivedExecutionGraph.getState();
final String jobName = archivedExecutionGraph.getJobName();
Preconditions.checkArgument(jobStatus.isTerminalState(), "The job " + jobName + '(' + jobId + ") is not in a terminal state. Instead it is in state " + jobStatus + '.');
switch(jobStatus) {
case FINISHED:
numFinishedJobs++;
break;
case CANCELED:
numCanceledJobs++;
break;
case FAILED:
numFailedJobs++;
break;
case SUSPENDED:
break;
default:
throw new IllegalStateException("The job " + jobName + '(' + jobId + ") should have been in a known terminal state. " + "Instead it was in state " + jobStatus + '.');
}
// write the ArchivedExecutionGraph to disk
storeExecutionGraphInfo(executionGraphInfo);
final JobDetails detailsForJob = JobDetails.createDetailsForJob(archivedExecutionGraph);
jobDetailsCache.put(jobId, detailsForJob);
executionGraphInfoCache.put(jobId, executionGraphInfo);
}
Aggregations