use of com.facebook.buck.distributed.thrift.CASContainsRequest in project buck by facebook.
the class DistBuildService method uploadMissingFilesFromList.
private ListenableFuture<Void> uploadMissingFilesFromList(final List<FileInfo> fileList, ListeningExecutorService executorService) {
return executorService.submit(() -> {
Map<String, FileInfo> sha1ToFileInfo = new HashMap<>();
for (FileInfo file : fileList) {
sha1ToFileInfo.put(file.getContentHash(), file);
}
List<String> contentHashes = ImmutableList.copyOf(sha1ToFileInfo.keySet());
CASContainsRequest containsReq = new CASContainsRequest();
containsReq.setContentSha1s(contentHashes);
FrontendRequest request = new FrontendRequest();
request.setType(FrontendRequestType.CAS_CONTAINS);
request.setCasContainsRequest(containsReq);
FrontendResponse response = makeRequestChecked(request);
Preconditions.checkState(response.getCasContainsResponse().exists.size() == contentHashes.size());
List<Boolean> isPresent = response.getCasContainsResponse().exists;
List<FileInfo> filesToBeUploaded = new LinkedList<>();
for (int i = 0; i < isPresent.size(); ++i) {
if (isPresent.get(i)) {
continue;
}
filesToBeUploaded.add(sha1ToFileInfo.get(contentHashes.get(i)));
}
LOG.info("%d out of %d files already exist in the cache. Uploading %d files..", sha1ToFileInfo.size() - filesToBeUploaded.size(), sha1ToFileInfo.size(), filesToBeUploaded.size());
request = new FrontendRequest();
StoreLocalChangesRequest storeReq = new StoreLocalChangesRequest();
storeReq.setFiles(filesToBeUploaded);
request.setType(FrontendRequestType.STORE_LOCAL_CHANGES);
request.setStoreLocalChangesRequest(storeReq);
makeRequestChecked(request);
// No response expected.
return null;
});
}
Aggregations