klion26 commented on a change in pull request #7351: [FLINK-11008][State Backends, Checkpointing]SpeedUp upload state files using multithread URL: https://github.com/apache/flink/pull/7351#discussion_r244318378
########## File path: flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDbStateDataTransfer.java ########## @@ -61,6 +74,144 @@ static void transferAllStateDataToDirectory( downloadDataForAllStateHandles(miscFiles, dest, restoringThreadNum, closeableRegistry); } + public static void uploadStateFiles( + CheckpointStreamFactory checkpointStreamFactory, + SnapshotDirectory localBackupDirectory, + Set<StateHandleID> baseSstFiles, + int uploadingThreadNum, + CloseableRegistry snapshotCloseableRegistry, + @Nonnull ConcurrentHashMap<StateHandleID, StreamStateHandle> sstFiles, + @Nonnull ConcurrentHashMap<StateHandleID, StreamStateHandle> miscFiles) throws Exception { + + Preconditions.checkState(localBackupDirectory.exists()); + + FileStatus[] fileStatuses = localBackupDirectory.listStatus(); + if (fileStatuses != null) { + ExecutorService executorService = createExecutorService(uploadingThreadNum); + + try { + List<Runnable> runnables = createUploadRunnables( Review comment: Hi @azagrebin, when I want to implement this by using `Callable`, I can not find `java.util.concurrent.CompletableFuture.callAsync` function(JDK 8), after searching in flink project, I just find `org.apache.flink.runtime.rpc.MainThreadExecutable#callAsync`, Did I miss something? In other words, If I use `Callable` instead of `Runnable`, should I implement a `ThrowingCallable` just as `ThrowingRunnable`. If I use `Runnable` to implement this, how about create a `CompletableFuture<StreamStateHandle>` instance and pass to the called function `uploadLocalFileToCheckpointFs(Path, CompletableFuture)`, in `uploadLocalFileToCheckpointFs` we complete the passed in `CompletableFuture<StreamStateHandle>`, such as below ``` Map<StateHandleID, CompletableFuture<StreamStateHandle>> futures = new HashMap(); // futures will update in createUploadRunnables List<Runnable> runnables = createUploadRunnables(sstFilePaths, miscFilePaths, futures); for (Runnable runnable : runnables) { CompletableFuture.runAsync(runnable, executorService); } FutureUtils.waitForAll(futures.values()).get(); .... private static StreamStateHandle uploadLocalFileToCheckpointFs(Path path, CompletableFuture future) { try { ... future.complete(...) } finally { .... } } ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services