Search in sources :

Example 16 with JobListener

use of org.apache.flink.core.execution.JobListener in project flink by apache.

the class JobListenerITCase method testExecuteAsyncCallsJobListenerOnMainThreadOnStreamEnvironment.

@Test
public void testExecuteAsyncCallsJobListenerOnMainThreadOnStreamEnvironment() throws Exception {
    AtomicReference<Thread> threadReference = new AtomicReference<>();
    StreamExecutionEnvironment env = new StreamExecutionEnvironment(getClientConfiguration());
    env.registerJobListener(new JobListener() {

        @Override
        public void onJobSubmitted(JobClient jobClient, Throwable t) {
            threadReference.set(Thread.currentThread());
        }

        @Override
        public void onJobExecuted(JobExecutionResult jobExecutionResult, Throwable throwable) {
        }
    });
    env.fromElements(1, 2, 3, 4, 5).addSink(new DiscardingSink<>());
    env.executeAsync();
    assertThat(Thread.currentThread(), is(threadReference.get()));
}
Also used : JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) AtomicReference(java.util.concurrent.atomic.AtomicReference) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) JobListener(org.apache.flink.core.execution.JobListener) JobClient(org.apache.flink.core.execution.JobClient) Test(org.junit.Test)

Aggregations

JobListener (org.apache.flink.core.execution.JobListener)16 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)14 JobClient (org.apache.flink.core.execution.JobClient)14 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)9 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 Test (org.junit.Test)8 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)6 List (java.util.List)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 Configuration (org.apache.flink.configuration.Configuration)5 DeploymentOptions (org.apache.flink.configuration.DeploymentOptions)5 DetachedJobExecutionResult (org.apache.flink.core.execution.DetachedJobExecutionResult)5 PipelineExecutorServiceLoader (org.apache.flink.core.execution.PipelineExecutorServiceLoader)5 ExceptionUtils (org.apache.flink.util.ExceptionUtils)5 FlinkException (org.apache.flink.util.FlinkException)5 Preconditions.checkNotNull (org.apache.flink.util.Preconditions.checkNotNull)5 WrappingRuntimeException (org.apache.flink.util.WrappingRuntimeException)5 Serializable (java.io.Serializable)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4