TisonKun commented on a change in pull request #10408: [FLINK-14992][client]
Add job listener to execution environments
URL: https://github.com/apache/flink/pull/10408#discussion_r354202101
##########
File path:
flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java
##########
@@ -809,10 +814,40 @@ public JobExecutionResult execute(String jobName) throws
Exception {
?
jobClient.getJobExecutionResult(userClassloader).get()
: new
DetachedJobExecutionResult(jobClient.getJobID());
+ CompletableFuture.runAsync(() ->
jobListeners.forEach(jobListener ->
jobListener.onJobExecuted(lastJobExecutionResult, null)));
+
return lastJobExecutionResult;
+ } catch (Throwable t) {
+ CompletableFuture.runAsync(() -> {
+ jobListeners.forEach(jobListener -> {
+ jobListener.onJobExecuted(null,
ExceptionUtils.stripExecutionException(t));
+ });
+ });
+ ExceptionUtils.rethrowException(t);
+
+ // never reached, only make javac happy
+ return null;
}
}
+ /**
+ * Register a {@link JobListener} in this environment. The {@link
JobListener} will be
+ * notified on specific job status changed.
+ */
+ @PublicEvolving
+ public void registerJobListener(JobListener jobListener) {
+ checkNotNull(jobListener, "JobListener cannot be null");
+ jobListeners.add(jobListener);
+ }
+
+ /**
+ * Clear all registered {@link JobListener}s.
+ */
+ @PublicEvolving
+ public void clearJobListener() {
Review comment:
👌
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services