Search in sources :

Example 41 with JobExecutionException

use of org.apache.flink.runtime.client.JobExecutionException in project flink by apache.

the class StateBackendITCase method testStateBackendWithoutCheckpointing.

/**
 * Verify that the user-specified state backend is used even if checkpointing is disabled.
 */
@Test
public void testStateBackendWithoutCheckpointing() throws Exception {
    StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment();
    see.setParallelism(1);
    see.getConfig().setRestartStrategy(RestartStrategies.noRestart());
    see.setStateBackend(new FailingStateBackend());
    see.fromElements(new Tuple2<>("Hello", 1)).keyBy(0).map(new RichMapFunction<Tuple2<String, Integer>, String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public void open(Configuration parameters) throws Exception {
            super.open(parameters);
            getRuntimeContext().getState(new ValueStateDescriptor<>("Test", Integer.class));
        }

        @Override
        public String map(Tuple2<String, Integer> value) throws Exception {
            return value.f0;
        }
    }).print();
    try {
        see.execute();
        fail();
    } catch (JobExecutionException e) {
        assertTrue(ExceptionUtils.findThrowable(e, SuccessException.class).isPresent());
    }
}
Also used : JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Configuration(org.apache.flink.configuration.Configuration) Tuple2(org.apache.flink.api.java.tuple.Tuple2) RichMapFunction(org.apache.flink.api.common.functions.RichMapFunction) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 42 with JobExecutionException

use of org.apache.flink.runtime.client.JobExecutionException in project flink by apache.

the class StreamTaskTimerITCase method testOperatorChainedToSource.

/**
 * Note: this test fails if we don't check for exceptions in the source contexts and do not
 * synchronize in the source contexts.
 */
@Test
public void testOperatorChainedToSource() throws Exception {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setStreamTimeCharacteristic(timeCharacteristic);
    env.setParallelism(1);
    DataStream<String> source = env.addSource(new InfiniteTestSource());
    source.transform("Custom Operator", BasicTypeInfo.STRING_TYPE_INFO, new TimerOperator(ChainingStrategy.ALWAYS));
    try {
        env.execute("Timer test");
    } catch (JobExecutionException e) {
        verifyJobExecutionException(e);
    }
}
Also used : JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 43 with JobExecutionException

use of org.apache.flink.runtime.client.JobExecutionException in project flink by apache.

the class StreamTaskTimerITCase method testOneInputOperatorWithoutChaining.

/**
 * Note: this test fails if we don't check for exceptions in the source contexts and do not
 * synchronize in the source contexts.
 */
@Test
public void testOneInputOperatorWithoutChaining() throws Exception {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setStreamTimeCharacteristic(timeCharacteristic);
    env.setParallelism(1);
    DataStream<String> source = env.addSource(new InfiniteTestSource());
    source.transform("Custom Operator", BasicTypeInfo.STRING_TYPE_INFO, new TimerOperator(ChainingStrategy.NEVER));
    try {
        env.execute("Timer test");
    } catch (JobExecutionException e) {
        verifyJobExecutionException(e);
    }
}
Also used : JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) 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