void (@NotNull String commitId) { long startTime = System.nanoTime(); // Loading metadata for commit Map<String, Map<String, BuildTargetState>> commitSourcesState = myMetadataLoader.loadMetadataForCommit(myNettyClient, commitId); if (commitSourcesState == null) { LOG.warn("Couldn't load metadata for commit: " + commitId); return; } // Calculate downloads Map<String, Map<String, BuildTargetState>> currentSourcesState = myMetadataLoader.loadCurrentProjectMetadata(); int totalDownloads = getLoaders().stream().mapToInt(loader -> loader.calculateDownloads(commitSourcesState, currentSourcesState)).sum(); try { // Computation with loaders results. If at least one of them failed rollback all job initLoaders(commitId, totalDownloads, commitSourcesState, currentSourcesState).thenAccept(loaderStatus -> { LOG.info("Loading finished with " + loaderStatus + " status"); try { CompletableFuture.allOf(getLoaders().stream() .map(loader -> applyChanges(loaderStatus, loader)) .toArray(CompletableFuture[]::new)) .thenRun(() -> saveStateAndNotify(loaderStatus, commitId, startTime)) .get(); } catch (InterruptedException | ExecutionException e) { LOG.warn("Unexpected exception rollback all progress", e); onFail(); getLoaders().forEach(loader -> loader.rollback()); myNettyClient.sendDescriptionStatusMessage(JpsBuildBundle.message("progress.text.rolling.back.downloaded.caches")); } }).handle((result, ex) -> handleExceptions(result, ex)).get(); } catch (InterruptedException | ExecutionException e) { LOG.warn("Couldn't fetch jps compilation caches", e); onFail(); } }