Search in sources :

Example 31 with JobExecutionException

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;
}
Also used : JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) JobManagerRunner(org.apache.flink.runtime.jobmaster.JobManagerRunner)

Example 32 with JobExecutionException

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());
        }
    }
}
Also used : JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Optional(java.util.Optional) SimpleStringSchema(org.apache.flink.api.common.serialization.SimpleStringSchema) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Properties(java.util.Properties) TimeoutException(org.apache.kafka.common.errors.TimeoutException)

Example 33 with JobExecutionException

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));
    }
}
Also used : JobSubmissionResult(org.apache.flink.api.common.JobSubmissionResult) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 34 with JobExecutionException

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);
    }
}
Also used : JobSubmissionResult(org.apache.flink.api.common.JobSubmissionResult) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) JobResult(org.apache.flink.runtime.jobmaster.JobResult) IOException(java.io.IOException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 35 with JobExecutionException

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());
        }
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Test(org.junit.Test)

Aggregations

JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)43 Test (org.junit.Test)27 IOException (java.io.IOException)19 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)17 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)15 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)9 ExecutionException (java.util.concurrent.ExecutionException)8 Optional (java.util.Optional)6 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)6 JobID (org.apache.flink.api.common.JobID)5 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)5 NoResourceAvailableException (org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException)5 JobException (org.apache.flink.runtime.JobException)4 URISyntaxException (java.net.URISyntaxException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)3 JobSubmissionResult (org.apache.flink.api.common.JobSubmissionResult)3 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)3 JobSubmissionException (org.apache.flink.runtime.client.JobSubmissionException)3