You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/10/16 19:57:10 UTC

[GitHub] zentol closed pull request #5648: [FLINK-8887][flip-6] ClusterClient.getJobStatus can throw FencingTokenException

zentol closed pull request #5648: [FLINK-8887][flip-6] ClusterClient.getJobStatus can throw FencingTokenException
URL: https://github.com/apache/flink/pull/5648
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
index 9b2411c66b7..1789758a6f1 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
@@ -57,6 +57,7 @@
 import org.apache.flink.runtime.rpc.FencedRpcEndpoint;
 import org.apache.flink.runtime.rpc.RpcService;
 import org.apache.flink.runtime.rpc.RpcUtils;
+import org.apache.flink.runtime.rpc.exceptions.FencingTokenException;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.Preconditions;
@@ -74,6 +75,7 @@
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
 import java.util.stream.Collectors;
 
 /**
@@ -404,7 +406,29 @@ public void start() throws Exception {
 		final JobManagerRunner jobManagerRunner = jobManagerRunners.get(jobId);
 
 		if (jobManagerRunner != null) {
-			return jobManagerRunner.getJobManagerGateway().requestJobStatus(timeout);
+				CompletableFuture<JobStatus> statusFuture = jobManagerRunner.getJobManagerGateway().requestJobStatus(timeout);
+				statusFuture.handle((JobStatus status, Throwable throwable) -> {
+					if (throwable != null) {
+						Throwable error = ExceptionUtils.stripCompletionException(throwable);
+
+						if (error instanceof FencingTokenException) {
+							log.warn("It occurs FencingTokenException may be the job manager runner has no leadership or" +
+								" the job has finished, so we would try to get it from archived execution graph store.");
+							final JobDetails jobDetails = archivedExecutionGraphStore.getAvailableJobDetails(jobId);
+
+							if (jobDetails != null) {
+								return jobDetails.getStatus();
+							} else {
+								throw new CompletionException(new FlinkJobNotFoundException(jobId));
+							}
+						}
+
+					}
+
+					return status;
+				});
+
+				return statusFuture;
 		} else {
 			final JobDetails jobDetails = archivedExecutionGraphStore.getAvailableJobDetails(jobId);
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services