/** * Stages the given artifact files to the staging service. * * @return The artifact staging token returned by the service */ public String stage(String stagingSessionToken, Collection<StagedFile> files) throws IOException, InterruptedException { final Map<StagedFile, CompletionStage<ArtifactMetadata>> futures = new HashMap<>(); LOG.info("Staging {} files (token: {})", files.size(), stagingSessionToken); for (StagedFile file : files) { futures.put( file, MoreFutures.supplyAsync(new StagingCallable(stagingSessionToken, file), executorService)); } CompletionStage<StagingResult> stagingResult = MoreFutures.allAsList(futures.values()) .thenApply(ignored -> new ExtractStagingResultsCallable(futures).call()); return stageManifest(stagingSessionToken, stagingResult); }