From 23ecdb1462b3138a58f902333597fe47bd65256a Mon Sep 17 00:00:00 2001 From: tison Date: Wed, 25 Dec 2019 15:59:46 +0800 Subject: [PATCH] [FLINK-15279][doc] Document new executeAsync() method and the newly introduced JobClient This closes #10684 . --- docs/dev/api_concepts.md | 13 ++++++++++++- docs/dev/api_concepts.zh.md | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/dev/api_concepts.md b/docs/dev/api_concepts.md index 0da12faf23fcb..234b074562cab 100644 --- a/docs/dev/api_concepts.md +++ b/docs/dev/api_concepts.md @@ -216,9 +216,20 @@ Once you specified the complete program you need to **trigger the program execut Depending on the type of the `ExecutionEnvironment` the execution will be triggered on your local machine or submit your program for execution on a cluster. -The `execute()` method is returning a `JobExecutionResult`, this contains execution +The `execute()` method will wait for the job to finish and then return a `JobExecutionResult`, this contains execution times and accumulator results. +If you don't want to wait for the job to finish, you can trigger asynchronous job execution by calling +`executeAysnc()` on the `StreamExecutionEnvironment`. It will return a `JobClient` with which you can +communicate with the job you just submitted. For instance, here is how to implement the semantics +of `execute()` by using `executeAsync()`. + +{% highlight java %} +final JobClient jobClient = env.executeAsync(); + +final JobExecutionResult jobExecutionResult = jobClient.getJobExecutionResult(userClassloader).get(); +{% endhighlight %} + Please see the [Streaming Guide]({{ site.baseurl }}/dev/datastream_api.html) for information about streaming data sources and sink and for more in-depths information about the supported transformations on DataStream. diff --git a/docs/dev/api_concepts.zh.md b/docs/dev/api_concepts.zh.md index 9bdbf5dc6b699..c71d635a871e4 100644 --- a/docs/dev/api_concepts.zh.md +++ b/docs/dev/api_concepts.zh.md @@ -160,6 +160,14 @@ print() `execute()` 方法返回 `JobExecutionResult`,它包括执行耗时和一个累加器的结果。 +如果你不需要等待作业的结束,只是想要触发程序执行,你可以调用 `StreamExecutionEnvironment` 的 `executeAsync()` 方法。这个方法将返回一个 `JobClient` 对象,通过 `JobClient` 能够与程序对应的作业进行交互。作为例子,这里介绍通过 `executeAsync()` 实现与 `execute()` 相同行为的方法。 + +{% highlight java %} +final JobClient jobClient = env.executeAsync(); + +final JobExecutionResult jobExecutionResult = jobClient.getJobExecutionResult(userClassloader).get(); +{% endhighlight %} + 有关流数据的 source 和 sink 以及有关 DataStream 支持的转换操作的详细信息请参阅[流处理指南]({{ site.baseurl }}/zh/dev/datastream_api.html)。 有关批数据的 source 和 sink 以及有关 DataSet 支持的转换操作的详细信息请参阅[批处理指南]({{ site.baseurl }}/zh/dev/batch/index.html)。