azagrebin 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_r244325175
########## 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 @klion26 , I think this could work: ``` futures.put(stateHandleID, CompletableFuture.supplyAsync(CheckedSupplier.unchecked( () -> uploadLocalFileToCheckpointFs(path)), executorService)) ``` `CompletableFuture.supplyAsync` seems to do already internally what you suggest. Also I would run parallel upload separately for `sstFilePaths` and `miscFilePaths`, one after another, so that `RocksDbStateDataTransfer` does not need to know about file structure. ---------------------------------------------------------------- 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