use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class ReactiveModeITCase method testScaleDownOnTaskManagerLoss.
@Test
public void testScaleDownOnTaskManagerLoss() throws Exception {
// test preparation: ensure we have 2 TaskManagers running
startAdditionalTaskManager();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// configure exactly one restart to avoid restart loops in error cases
env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
final DataStream<String> input = env.addSource(new DummySource());
input.addSink(new DiscardingSink<>());
final JobClient jobClient = env.executeAsync();
waitUntilParallelismForVertexReached(miniClusterResource.getRestClusterClient(), jobClient.getJobID(), NUMBER_SLOTS_PER_TASK_MANAGER * (INITIAL_NUMBER_TASK_MANAGERS + 1));
// scale down to 1 TaskManagers:
miniClusterResource.getMiniCluster().terminateTaskManager(0).get();
waitUntilParallelismForVertexReached(miniClusterResource.getRestClusterClient(), jobClient.getJobID(), NUMBER_SLOTS_PER_TASK_MANAGER * NUMBER_SLOTS_PER_TASK_MANAGER);
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteCallsJobListenerOnStreamingEnvironment.
@Test
public void testExecuteCallsJobListenerOnStreamingEnvironment() throws Exception {
AtomicReference<JobID> jobIdReference = new AtomicReference<>();
OneShotLatch submissionLatch = new OneShotLatch();
OneShotLatch executionLatch = 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) {
executionLatch.trigger();
}
});
env.fromElements(1, 2, 3, 4, 5).addSink(new DiscardingSink<>());
JobExecutionResult jobExecutionResult = env.execute();
submissionLatch.await(2000L, TimeUnit.MILLISECONDS);
executionLatch.await(2000L, TimeUnit.MILLISECONDS);
assertThat(jobExecutionResult.getJobID(), is(jobIdReference.get()));
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteAsyncCallsJobListenerOnMainThreadOnBatchEnvironment.
@Test
public void testExecuteAsyncCallsJobListenerOnMainThreadOnBatchEnvironment() 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.executeAsync();
assertThat(Thread.currentThread(), is(threadReference.get()));
}
use of org.apache.flink.core.execution.JobClient in project flink by apache.
the class JobListenerITCase method testExecuteCallsJobListenerOnBatchEnvironment.
@Test
public void testExecuteCallsJobListenerOnBatchEnvironment() throws Exception {
AtomicReference<JobID> jobIdReference = new AtomicReference<>();
OneShotLatch submissionLatch = new OneShotLatch();
OneShotLatch executionLatch = 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) {
executionLatch.trigger();
}
});
env.fromElements(1, 2, 3, 4, 5).output(new DiscardingOutputFormat<>());
JobExecutionResult jobExecutionResult = env.execute();
submissionLatch.await(2000L, TimeUnit.MILLISECONDS);
executionLatch.await(2000L, TimeUnit.MILLISECONDS);
assertThat(jobExecutionResult.getJobID(), is(jobIdReference.get()));
}
use of org.apache.flink.core.execution.JobClient 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()));
}
Aggregations