Search in sources :

Example 1 with Tree

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);
}
Also used : Context(io.grpc.Context) Digest(build.bazel.remote.execution.v2.Digest) DirectoryNode(build.bazel.remote.execution.v2.DirectoryNode) DirectoryEntry(build.buildfarm.common.TreeIterator.DirectoryEntry) Tree(build.buildfarm.v1test.Tree) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Directory(build.bazel.remote.execution.v2.Directory)

Example 2 with Tree

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();
}
Also used : Tree(build.buildfarm.v1test.Tree) ByteString(com.google.protobuf.ByteString)

Example 3 with Tree

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());
}
Also used : Tree(build.buildfarm.v1test.Tree)

Example 4 with Tree

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());
}
Also used : Tree(build.buildfarm.v1test.Tree)

Example 5 with Tree

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();
}
Also used : Digest(build.bazel.remote.execution.v2.Digest) Tree(build.buildfarm.v1test.Tree) OutputDirectory(build.bazel.remote.execution.v2.OutputDirectory) Directory(build.bazel.remote.execution.v2.Directory)

Aggregations

Tree (build.buildfarm.v1test.Tree)11 Digest (build.bazel.remote.execution.v2.Digest)5 Directory (build.bazel.remote.execution.v2.Directory)4 ByteString (com.google.protobuf.ByteString)4 OutputDirectory (build.bazel.remote.execution.v2.OutputDirectory)3 DirectoryEntry (build.buildfarm.common.TreeIterator.DirectoryEntry)3 Action (build.bazel.remote.execution.v2.Action)2 Command (build.bazel.remote.execution.v2.Command)2 DirectoryNode (build.bazel.remote.execution.v2.DirectoryNode)2 ExecuteOperationMetadata (build.bazel.remote.execution.v2.ExecuteOperationMetadata)2 QueuedOperation (build.buildfarm.v1test.QueuedOperation)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 MoreExecutors.newDirectExecutorService (com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService)2 StatusException (io.grpc.StatusException)2 IOException (java.io.IOException)2 ExecutorService (java.util.concurrent.ExecutorService)2 ActionCacheUpdateCapabilities (build.bazel.remote.execution.v2.ActionCacheUpdateCapabilities)1 ActionResult (build.bazel.remote.execution.v2.ActionResult)1 Response (build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response)1