use of org.apache.flink.runtime.jobmaster.JobManagerRunner in project flink by apache.
the class MiniClusterJobDispatcher method startJobRunners.
private JobManagerRunner[] startJobRunners(JobGraph job, OnCompletionActions onCompletion, FatalErrorHandler errorHandler) throws JobExecutionException {
LOG.info("Starting {} JobMaster(s) for job {} ({})", numJobManagers, job.getName(), job.getJobID());
// start all JobManagers
JobManagerRunner[] runners = new JobManagerRunner[numJobManagers];
for (int i = 0; i < numJobManagers; i++) {
try {
runners[i] = new JobManagerRunner(ResourceID.generate(), job, configuration, rpcServices[i], haServices, heartbeatServices, jobManagerServices, metricRegistry, onCompletion, errorHandler);
runners[i].start();
} catch (Throwable t) {
// shut down all the ones so far
for (int k = 0; k <= i; k++) {
try {
if (runners[i] != null) {
runners[i].shutdown();
}
} catch (Throwable ignored) {
// silent shutdown
}
}
// un-register the job from the high.availability services
try {
haServices.getRunningJobsRegistry().setJobFinished(job.getJobID());
} catch (Throwable tt) {
LOG.warn("Could not properly unregister job from high-availability services", tt);
}
throw new JobExecutionException(job.getJobID(), "Could not start the JobManager(s) for the job", t);
}
}
return runners;
}
use of org.apache.flink.runtime.jobmaster.JobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method testGet.
@Test
public void testGet() {
final JobID jobId = new JobID();
final JobManagerRunner jobManagerRunner = TestingJobManagerRunner.newBuilder().setJobId(jobId).build();
testInstance.register(jobManagerRunner);
assertThat(testInstance.get(jobId)).isEqualTo(jobManagerRunner);
}
use of org.apache.flink.runtime.jobmaster.JobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method testGetJobManagerRunners.
@Test
public void testGetJobManagerRunners() {
assertThat(testInstance.getJobManagerRunners()).isEmpty();
final JobManagerRunner jobManagerRunner0 = TestingJobManagerRunner.newBuilder().build();
final JobManagerRunner jobManagerRunner1 = TestingJobManagerRunner.newBuilder().build();
testInstance.register(jobManagerRunner0);
testInstance.register(jobManagerRunner1);
assertThat(testInstance.getJobManagerRunners()).containsExactlyInAnyOrder(jobManagerRunner0, jobManagerRunner1);
}
use of org.apache.flink.runtime.jobmaster.JobManagerRunner 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.runtime.jobmaster.JobManagerRunner in project flink by apache.
the class Dispatcher method queryJobMastersForInformation.
@Nonnull
private <T> List<CompletableFuture<Optional<T>>> queryJobMastersForInformation(Function<JobManagerRunner, CompletableFuture<T>> queryFunction) {
List<CompletableFuture<Optional<T>>> optionalJobInformation = new ArrayList<>(jobManagerRunnerRegistry.size());
for (JobManagerRunner job : jobManagerRunnerRegistry.getJobManagerRunners()) {
final CompletableFuture<Optional<T>> queryResult = queryFunction.apply(job).handle((T value, Throwable t) -> Optional.ofNullable(value));
optionalJobInformation.add(queryResult);
}
return optionalJobInformation;
}
Aggregations