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 2020/04/07 15:01:17 UTC

[GitHub] [flink] tillrohrmann commented on a change in pull request #11649: [FLINK-15812][runtime] Archive jobs asynchronously

tillrohrmann commented on a change in pull request #11649: [FLINK-15812][runtime] Archive jobs asynchronously
URL: https://github.com/apache/flink/pull/11649#discussion_r404879127
 
 

 ##########
 File path: flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/JsonResponseHistoryServerArchivist.java
 ##########
 @@ -39,18 +39,25 @@
 
 	private final Path archivePath;
 
-	JsonResponseHistoryServerArchivist(JsonArchivist jsonArchivist, Path archivePath) {
+	private final Executor ioExecutor;
+
+	JsonResponseHistoryServerArchivist(JsonArchivist jsonArchivist, Path archivePath, Executor ioExecutor) {
 		this.jsonArchivist = Preconditions.checkNotNull(jsonArchivist);
 		this.archivePath = Preconditions.checkNotNull(archivePath);
+		this.ioExecutor = ioExecutor;
 	}
 
 	@Override
 	public CompletableFuture<Acknowledge> archiveExecutionGraph(AccessExecutionGraph executionGraph) {
-		try {
-			FsJobArchivist.archiveJob(archivePath, executionGraph.getJobID(), jsonArchivist.archiveJsonWithPath(executionGraph));
-			return CompletableFuture.completedFuture(Acknowledge.get());
-		} catch (IOException e) {
-			return FutureUtils.completedExceptionally(e);
-		}
+		final CompletableFuture<Acknowledge> ackFuture = new CompletableFuture<>();
+		ioExecutor.execute(() -> {
+			try {
+				FsJobArchivist.archiveJob(archivePath, executionGraph.getJobID(), jsonArchivist.archiveJsonWithPath(executionGraph));
+				ackFuture.complete(Acknowledge.get());
+			} catch (IOException e) {
+				ackFuture.completeExceptionally(e);
+			}
+		});
+		return ackFuture;
 
 Review comment:
   ```suggestion
   return CompletableFuture
   			.runAsync(
   				ThrowingRunnable.unchecked(() -> FsJobArchivist.archiveJob(
   					archivePath,
   					executionGraph.getJobID(),
   					jsonArchivist.archiveJsonWithPath(executionGraph))),
   				ioExecutor)
   			.thenApply(ignored -> Acknowledge.get());
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services