use of build.buildfarm.v1test.Tree in project bazel-buildfarm by bazelbuild.
the class ShardInstance method getTreeFuture.
@Override
protected ListenableFuture<Tree> getTreeFuture(String reason, Digest inputRoot, ExecutorService service, RequestMetadata requestMetadata) {
SettableFuture<Void> future = SettableFuture.create();
Tree.Builder tree = Tree.newBuilder().setRootDigest(inputRoot);
Set<Digest> digests = Sets.newConcurrentHashSet();
Queue<Digest> remaining = new ConcurrentLinkedQueue();
remaining.offer(inputRoot);
Context ctx = Context.current();
TreeCallback callback = new TreeCallback(future) {
@Override
protected void onDirectory(Digest digest, Directory directory) {
tree.putDirectories(digest.getHash(), directory);
for (DirectoryNode childNode : directory.getDirectoriesList()) {
Digest child = childNode.getDigest();
if (digests.add(child)) {
remaining.offer(child);
}
}
}
@Override
boolean next() {
Digest nextDigest = remaining.poll();
if (!future.isDone() && nextDigest != null) {
ctx.run(() -> addCallback(transform(expectDirectory(reason, nextDigest, requestMetadata), directory -> new DirectoryEntry(nextDigest, directory), service), this, service));
return true;
}
return false;
}
};
callback.next();
return transform(future, (result) -> tree.build(), service);
}
use of build.buildfarm.v1test.Tree in project bazel-buildfarm by bazelbuild.
the class MemoryInstance method getCompleteTree.
Tree getCompleteTree(Digest rootDigest) {
Tree.Builder tree = Tree.newBuilder();
String pageToken = "";
do {
pageToken = getTree(rootDigest, 1024, pageToken, tree);
} while (!pageToken.isEmpty());
return tree.build();
}
use of build.buildfarm.v1test.Tree in project bazel-buildfarm by bazelbuild.
the class Cat method printRETreeLayout.
private static void printRETreeLayout(DigestUtil digestUtil, build.bazel.remote.execution.v2.Tree reTree) throws IOException, InterruptedException {
Tree tree = reTreeToTree(digestUtil, reTree);
printTreeLayout(DigestUtil.proxyDirectoriesIndex(tree.getDirectoriesMap()), tree.getRootDigest());
}
use of build.buildfarm.v1test.Tree in project bazel-buildfarm by bazelbuild.
the class Cat method printREDirectoryTree.
private static void printREDirectoryTree(DigestUtil digestUtil, build.bazel.remote.execution.v2.Tree reTree) {
Tree tree = reTreeToTree(digestUtil, reTree);
printTree(0, tree, tree.getRootDigest());
}
use of build.buildfarm.v1test.Tree in project bazel-buildfarm by bazelbuild.
the class Cat method reTreeToTree.
private static Tree reTreeToTree(DigestUtil digestUtil, build.bazel.remote.execution.v2.Tree reTree) {
Digest rootDigest = digestUtil.compute(reTree.getRoot());
Tree.Builder tree = Tree.newBuilder().setRootDigest(rootDigest);
tree.putDirectories(rootDigest.getHash(), reTree.getRoot());
for (Directory directory : reTree.getChildrenList()) {
tree.putDirectories(digestUtil.compute(directory).getHash(), directory);
}
return tree.build();
}
Aggregations