use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteCallsJobListenerOnMainThreadOnBatchEnvironment.
@Test
public void testExecuteCallsJobListenerOnMainThreadOnBatchEnvironment() throws Exception {
AtomicReference<Thread> threadReference = new AtomicReference<>();
ExecutionEnvironment env = new ExecutionEnvironment(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).output(new DiscardingOutputFormat<>());
env.execute();
assertThat(Thread.currentThread(), is(threadReference.get()));
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteAsyncCallsJobListenerOnStreamingEnvironment.
@Test
public void testExecuteAsyncCallsJobListenerOnStreamingEnvironment() throws Exception {
AtomicReference<JobID> jobIdReference = new AtomicReference<>();
OneShotLatch submissionLatch = new OneShotLatch();
StreamExecutionEnvironment env = new StreamExecutionEnvironment(getClientConfiguration());
env.registerJobListener(new JobListener() {
@Override
public void onJobSubmitted(JobClient jobClient, Throwable t) {
jobIdReference.set(jobClient.getJobID());
submissionLatch.trigger();
}
@Override
public void onJobExecuted(JobExecutionResult jobExecutionResult, Throwable throwable) {
}
});
env.fromElements(1, 2, 3, 4, 5).addSink(new DiscardingSink<>());
JobClient jobClient = env.executeAsync();
submissionLatch.await(2000L, TimeUnit.MILLISECONDS);
// when executing asynchronously we don't get an "executed" callback
assertThat(jobClient.getJobID(), is(jobIdReference.get()));
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteCallsJobListenerOnMainThreadOnStreamEnvironment.
@Test
public void testExecuteCallsJobListenerOnMainThreadOnStreamEnvironment() 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.execute();
assertThat(Thread.currentThread(), is(threadReference.get()));
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteAsyncCallsJobListenerOnBatchEnvironment.
@Test
public void testExecuteAsyncCallsJobListenerOnBatchEnvironment() throws Exception {
AtomicReference<JobID> jobIdReference = new AtomicReference<>();
OneShotLatch submissionLatch = new OneShotLatch();
ExecutionEnvironment env = new ExecutionEnvironment(getClientConfiguration());
env.registerJobListener(new JobListener() {
@Override
public void onJobSubmitted(JobClient jobClient, Throwable t) {
jobIdReference.set(jobClient.getJobID());
submissionLatch.trigger();
}
@Override
public void onJobExecuted(JobExecutionResult jobExecutionResult, Throwable throwable) {
}
});
env.fromElements(1, 2, 3, 4, 5).output(new DiscardingOutputFormat<>());
JobClient jobClient = env.executeAsync();
submissionLatch.await(2000L, TimeUnit.MILLISECONDS);
// when executing asynchronously we don't get an "executed" callback
assertThat(jobClient.getJobID(), is(jobIdReference.get()));
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class LocalExecutorITCase method testMiniClusterShutdownOnErrors.
@Test(timeout = 60_000)
public void testMiniClusterShutdownOnErrors() throws Exception {
Plan runtimeExceptionPlan = getRuntimeExceptionPlan();
runtimeExceptionPlan.setExecutionConfig(new ExecutionConfig());
Configuration config = new Configuration();
config.setBoolean(DeploymentOptions.ATTACHED, true);
JobClient jobClient = executor.execute(runtimeExceptionPlan, config, ClassLoader.getSystemClassLoader()).get();
assertThrows("Job execution failed.", Exception.class, () -> jobClient.getJobExecutionResult().get());
assertThat(miniCluster.isRunning(), is(false));
}
Aggregations