Java Code Examples for org.apache.flink.streaming.api.environment.StreamExecutionEnvironment#executeAsync()
The following examples show how to use
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment#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 |
@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())); }
Example 2
Source File: DataStreamUtils.java From flink with Apache License 2.0 | 6 votes |
/** * Returns an iterator to iterate over the elements of the DataStream. * @return The iterator */ public static <OUT> Iterator<OUT> collect(DataStream<OUT> stream) { TypeSerializer<OUT> serializer = stream.getType().createSerializer( stream.getExecutionEnvironment().getConfig()); String accumulatorName = "dataStreamCollect_" + UUID.randomUUID().toString(); CollectSinkOperatorFactory<OUT> factory = new CollectSinkOperatorFactory<>(serializer, accumulatorName); CollectSinkOperator<OUT> operator = (CollectSinkOperator<OUT>) factory.getOperator(); CollectResultIterator<OUT> iterator = new CollectResultIterator<>( operator.getOperatorIdFuture(), serializer, accumulatorName); CollectStreamSink<OUT> sink = new CollectStreamSink<>(stream, factory); sink.name("Data stream collect sink"); StreamExecutionEnvironment env = stream.getExecutionEnvironment(); env.addOperator(sink.getTransformation()); try { JobClient jobClient = env.executeAsync("Data Stream Collect"); iterator.setJobClient(jobClient); } catch (Exception e) { throw new RuntimeException("Failed to execute data stream", e); } return iterator; }
Example 3
Source File: UnalignedCheckpointCompatibilityITCase.java From flink with Apache License 2.0 | 4 votes |
private static JobClient submitJobInitially(StreamExecutionEnvironment env) throws Exception { return env.executeAsync(dag(FIRST_RUN_EL_COUNT, true, FIRST_RUN_BACKPRESSURE_MS, env)); }