use of com.google.devtools.build.lib.remote.RemoteProtocol.Output in project bazel by bazelbuild.
the class ConcurrentMapActionCache method downloadAllResults.
@Override
public void downloadAllResults(ActionResult result, Path execRoot) throws IOException, CacheNotFoundException {
for (Output output : result.getOutputList()) {
if (output.getContentCase() == ContentCase.FILE_METADATA) {
FileMetadata m = output.getFileMetadata();
downloadFileContents(m.getDigest(), execRoot.getRelative(output.getPath()), m.getExecutable());
} else {
downloadTree(output.getDigest(), execRoot.getRelative(output.getPath()));
}
}
}
use of com.google.devtools.build.lib.remote.RemoteProtocol.Output in project bazel by bazelbuild.
the class GrpcActionCache method downloadAllResults.
/**
* Download all results of a remotely executed action locally. TODO(olaola): will need to amend to
* include the {@link com.google.devtools.build.lib.remote.TreeNodeRepository} for updating.
*/
@Override
public void downloadAllResults(ActionResult result, Path execRoot) throws IOException, CacheNotFoundException {
// Send all the file requests in a single synchronous batch.
// TODO(olaola): profile to maybe replace with separate concurrent requests.
CasDownloadBlobRequest.Builder request = CasDownloadBlobRequest.newBuilder();
Map<ContentDigest, Pair<Path, FileMetadata>> metadataMap = new HashMap<>();
for (Output output : result.getOutputList()) {
Path path = execRoot.getRelative(output.getPath());
if (output.getContentCase() == ContentCase.FILE_METADATA) {
FileMetadata fileMetadata = output.getFileMetadata();
ContentDigest digest = fileMetadata.getDigest();
if (digest.getSizeBytes() > 0) {
request.addDigest(digest);
metadataMap.put(digest, Pair.of(path, fileMetadata));
} else {
// Handle empty file locally.
FileSystemUtils.createDirectoryAndParents(path.getParentDirectory());
FileSystemUtils.writeContent(path, new byte[0]);
}
} else {
downloadTree(output.getDigest(), path);
}
}
Iterator<CasDownloadReply> replies = getBlockingStub().downloadBlob(request.build());
Set<ContentDigest> results = new HashSet<>();
while (replies.hasNext()) {
results.add(createFileFromStream(metadataMap, replies));
}
for (ContentDigest digest : metadataMap.keySet()) {
if (!results.contains(digest)) {
throw new CacheNotFoundException(digest);
}
}
}
Aggregations