use of org.apache.flink.runtime.client.JobExecutionException 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.client.JobExecutionException in project flink by apache.
the class KafkaConsumerTestBase method runFailOnNoBrokerTest.
// ------------------------------------------------------------------------
// Suite of Tests
//
// The tests here are all not activated (by an @Test tag), but need
// to be invoked from the extending classes. That way, the classes can
// select which tests to run.
// ------------------------------------------------------------------------
/**
* Test that ensures the KafkaConsumer is properly failing if the topic doesn't exist and a
* wrong broker was specified.
*
* @throws Exception
*/
public void runFailOnNoBrokerTest() throws Exception {
try {
Properties properties = new Properties();
StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment();
see.setRestartStrategy(RestartStrategies.noRestart());
see.setParallelism(1);
// use wrong ports for the consumers
properties.setProperty("bootstrap.servers", "localhost:80");
properties.setProperty("group.id", "test");
// let the test fail fast
properties.setProperty("request.timeout.ms", "3000");
properties.setProperty("socket.timeout.ms", "3000");
properties.setProperty("session.timeout.ms", "2000");
properties.setProperty("fetch.max.wait.ms", "2000");
properties.setProperty("heartbeat.interval.ms", "1000");
properties.putAll(secureProps);
DataStream<String> stream = getStream(see, "doesntexist", new SimpleStringSchema(), properties);
stream.print();
see.execute("No broker test");
} catch (JobExecutionException jee) {
final Optional<TimeoutException> optionalTimeoutException = ExceptionUtils.findThrowable(jee, TimeoutException.class);
assertTrue(optionalTimeoutException.isPresent());
final TimeoutException timeoutException = optionalTimeoutException.get();
if (useNewSource) {
assertThat(timeoutException.getCause().getMessage(), containsString("Timed out waiting for a node assignment."));
} else {
assertEquals("Timeout expired while fetching topic metadata", timeoutException.getMessage());
}
}
}
use of org.apache.flink.runtime.client.JobExecutionException in project flink by apache.
the class MiniCluster method runDetached.
// ------------------------------------------------------------------------
// running jobs
// ------------------------------------------------------------------------
/**
* This method executes a job in detached mode. The method returns immediately after the job has
* been added to the
*
* @param job The Flink job to execute
* @throws JobExecutionException Thrown if anything went amiss during initial job launch, or if
* the job terminally failed.
*/
public void runDetached(JobGraph job) throws JobExecutionException, InterruptedException {
checkNotNull(job, "job is null");
final CompletableFuture<JobSubmissionResult> submissionFuture = submitJob(job);
try {
submissionFuture.get();
} catch (ExecutionException e) {
throw new JobExecutionException(job.getJobID(), ExceptionUtils.stripExecutionException(e));
}
}
use of org.apache.flink.runtime.client.JobExecutionException in project flink by apache.
the class MiniCluster method executeJobBlocking.
/**
* This method runs a job in blocking mode. The method returns only after the job completed
* successfully, or after it failed terminally.
*
* @param job The Flink job to execute
* @return The result of the job execution
* @throws JobExecutionException Thrown if anything went amiss during initial job launch, or if
* the job terminally failed.
*/
public JobExecutionResult executeJobBlocking(JobGraph job) throws JobExecutionException, InterruptedException {
checkNotNull(job, "job is null");
final CompletableFuture<JobSubmissionResult> submissionFuture = submitJob(job);
final CompletableFuture<JobResult> jobResultFuture = submissionFuture.thenCompose((JobSubmissionResult ignored) -> requestJobResult(job.getJobID()));
final JobResult jobResult;
try {
jobResult = jobResultFuture.get();
} catch (ExecutionException e) {
throw new JobExecutionException(job.getJobID(), "Could not retrieve JobResult.", ExceptionUtils.stripExecutionException(e));
}
try {
return jobResult.toJobExecutionResult(Thread.currentThread().getContextClassLoader());
} catch (IOException | ClassNotFoundException e) {
throw new JobExecutionException(job.getJobID(), e);
}
}
use of org.apache.flink.runtime.client.JobExecutionException in project flink by apache.
the class MiniClusterITCase method testTwoInputJobFailingEdgeMismatch.
@Test
public void testTwoInputJobFailingEdgeMismatch() throws Exception {
final int parallelism = 1;
final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder().setNumTaskManagers(1).setNumSlotsPerTaskManager(6 * parallelism).setConfiguration(getDefaultConfiguration()).build();
try (final MiniCluster miniCluster = new MiniCluster(cfg)) {
miniCluster.start();
final JobVertex sender1 = new JobVertex("Sender1");
sender1.setInvokableClass(Sender.class);
sender1.setParallelism(parallelism);
final JobVertex sender2 = new JobVertex("Sender2");
sender2.setInvokableClass(Sender.class);
sender2.setParallelism(2 * parallelism);
final JobVertex receiver = new JobVertex("Receiver");
receiver.setInvokableClass(AgnosticTertiaryReceiver.class);
receiver.setParallelism(3 * parallelism);
receiver.connectNewDataSetAsInput(sender1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
receiver.connectNewDataSetAsInput(sender2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(sender1, receiver, sender2);
try {
miniCluster.executeJobBlocking(jobGraph);
fail("Job should fail.");
} catch (JobExecutionException e) {
assertTrue(findThrowable(e, ArrayIndexOutOfBoundsException.class).isPresent());
assertTrue(findThrowableWithMessage(e, "2").isPresent());
}
}
}
Aggregations