Java Code Examples for org.apache.flink.api.java.ExecutionEnvironment#executeAsync()

The following examples show how to use org.apache.flink.api.java.ExecutionEnvironment#executeAsync() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobListenerITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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()));
}
 
Example 2
Source File: MultiExecuteJob.java    From flink with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	int noOfExecutes = Integer.parseInt(args[0]);

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	for (int i = 0; i < noOfExecutes; i++) {
		final List<Integer> input = new ArrayList<>();
		input.add(1);
		input.add(2);
		input.add(3);

		env.fromCollection(input)
				.map(element -> element + 1)
				.output(new DiscardingOutputFormat<>());
		env.executeAsync();
	}
}
 
Example 3
Source File: ClientTest.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	for (int i = 0; i < 2; i++) {
		env.fromElements(1, 2).output(new DiscardingOutputFormat<>());
		JobClient jc = env.executeAsync();

		jc.getJobExecutionResult(TestMultiExecute.class.getClassLoader());
	}
}