Search in sources :

Example 1 with StubInstance

use of build.buildfarm.instance.stub.StubInstance in project bazel-buildfarm by bazelbuild.

the class IndexWorker method main.

public static void main(String[] args) throws Exception {
    String host = args[0];
    String instanceName = args[1];
    DigestUtil digestUtil = DigestUtil.forHash(args[2]);
    String reindexworker = args[3];
    ManagedChannel channel = createChannel(host);
    Instance instance = new StubInstance(instanceName, digestUtil, channel);
    CasIndexResults results = instance.reindexCas(reindexworker);
    System.out.println(results.toMessage());
    instance.stop();
}
Also used : StubInstance(build.buildfarm.instance.stub.StubInstance) Instance(build.buildfarm.instance.Instance) CasIndexResults(build.buildfarm.common.CasIndexResults) ManagedChannel(io.grpc.ManagedChannel) DigestUtil(build.buildfarm.common.DigestUtil) StubInstance(build.buildfarm.instance.stub.StubInstance)

Example 2 with StubInstance

use of build.buildfarm.instance.stub.StubInstance in project bazel-buildfarm by bazelbuild.

the class Mount method main.

@SuppressWarnings("BusyWait")
public static void main(String[] args) throws Exception {
    String host = args[0];
    String instanceName = args[1];
    DigestUtil digestUtil = DigestUtil.forHash(args[2]);
    ManagedChannel channel = createChannel(host);
    Instance instance = new StubInstance(instanceName, digestUtil, channel);
    Path cwd = Paths.get(".");
    FuseCAS fuse = new FuseCAS(cwd.resolve(args[3]), new InputStreamFactory() {

        final Map<Digest, ByteString> cache = new HashMap<>();

        public synchronized InputStream newInput(Digest blobDigest, long offset) {
            if (cache.containsKey(blobDigest)) {
                return cache.get(blobDigest).substring((int) offset).newInput();
            }
            try {
                ByteString value = getBlob(instance, blobDigest, RequestMetadata.getDefaultInstance());
                if (offset == 0) {
                    cache.put(blobDigest, value);
                }
                return value.newInput();
            } catch (IOException e) {
                return null;
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                return null;
            }
        }
    });
    // FIXME make bettar
    fuse.createInputRoot(args[5], DigestUtil.parseDigest(args[4]));
    try {
        // noinspection InfiniteLoopStatement
        for (; ; ) {
            Thread.sleep(1000);
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } finally {
        fuse.stop();
    }
}
Also used : Path(java.nio.file.Path) StubInstance(build.buildfarm.instance.stub.StubInstance) Instance(build.buildfarm.instance.Instance) Digest(build.bazel.remote.execution.v2.Digest) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) InputStream(java.io.InputStream) FuseCAS(build.buildfarm.worker.FuseCAS) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) DigestUtil(build.buildfarm.common.DigestUtil) InputStreamFactory(build.buildfarm.common.InputStreamFactory) StubInstance(build.buildfarm.instance.stub.StubInstance) ManagedChannel(io.grpc.ManagedChannel)

Example 3 with StubInstance

use of build.buildfarm.instance.stub.StubInstance in project bazel-buildfarm by bazelbuild.

the class Cat method cancellableMain.

private static void cancellableMain(String host, String instanceName, DigestUtil digestUtil, String type, Iterable<String> args) throws Exception {
    ManagedChannel channel = createChannel(host);
    Instance instance = new StubInstance(instanceName, "bf-cat", digestUtil, channel, Durations.fromSeconds(10));
    // should do something to match caps against requested digests
    try {
        for (CatCommand command : commands) {
            if (command.name().equals(type)) {
                command.run(instance, args);
                return;
            }
        }
        System.err.printf("Unrecognized bf-cat type %s%n", type);
        usage();
    } finally {
        instance.stop();
    }
}
Also used : StubInstance(build.buildfarm.instance.stub.StubInstance) Instance(build.buildfarm.instance.Instance) ManagedChannel(io.grpc.ManagedChannel) StubInstance(build.buildfarm.instance.stub.StubInstance)

Example 4 with StubInstance

use of build.buildfarm.instance.stub.StubInstance in project bazel-buildfarm by bazelbuild.

the class Ac method main.

public static void main(String[] args) throws Exception {
    // get arguments for establishing an instance
    String host = args[0];
    String instanceName = args[1];
    DigestUtil digestUtil = DigestUtil.forHash(args[2]);
    // create instance
    ManagedChannel channel = createChannel(host);
    Instance instance = new StubInstance(instanceName, digestUtil, channel);
    // upload fake data to the Action Cache.
    DigestUtil hash = new DigestUtil(HashFunction.SHA256);
    DigestUtil.ActionKey key = DigestUtil.asActionKey(hash.compute(ByteString.copyFromUtf8("Hello, World")));
    ActionResult.Builder result = ActionResult.newBuilder();
    instance.putActionResult(key, result.build());
    instance.stop();
}
Also used : ActionResult(build.bazel.remote.execution.v2.ActionResult) StubInstance(build.buildfarm.instance.stub.StubInstance) Instance(build.buildfarm.instance.Instance) ManagedChannel(io.grpc.ManagedChannel) ByteString(com.google.protobuf.ByteString) DigestUtil(build.buildfarm.common.DigestUtil) StubInstance(build.buildfarm.instance.stub.StubInstance)

Example 5 with StubInstance

use of build.buildfarm.instance.stub.StubInstance in project bazel-buildfarm by bazelbuild.

the class Cancel method main.

public static void main(String[] args) throws Exception {
    String host = args[0];
    String instanceName = args[1];
    DigestUtil digestUtil = DigestUtil.forHash(args[2]);
    ManagedChannel channel = createChannel(host);
    Instance instance = new StubInstance(instanceName, digestUtil, channel);
    for (int i = 3; i < args.length; i++) {
        instance.cancelOperation(args[i]);
    }
    instance.stop();
}
Also used : StubInstance(build.buildfarm.instance.stub.StubInstance) Instance(build.buildfarm.instance.Instance) ManagedChannel(io.grpc.ManagedChannel) DigestUtil(build.buildfarm.common.DigestUtil) StubInstance(build.buildfarm.instance.stub.StubInstance)

Aggregations

Instance (build.buildfarm.instance.Instance)8 StubInstance (build.buildfarm.instance.stub.StubInstance)8 DigestUtil (build.buildfarm.common.DigestUtil)7 ManagedChannel (io.grpc.ManagedChannel)7 ByteString (com.google.protobuf.ByteString)2 HashMap (java.util.HashMap)2 ActionResult (build.bazel.remote.execution.v2.ActionResult)1 Digest (build.bazel.remote.execution.v2.Digest)1 CasIndexResults (build.buildfarm.common.CasIndexResults)1 InputStreamFactory (build.buildfarm.common.InputStreamFactory)1 WorkerProfileMessage (build.buildfarm.v1test.WorkerProfileMessage)1 FuseCAS (build.buildfarm.worker.FuseCAS)1 ImmutableList (com.google.common.collect.ImmutableList)1 Operation (com.google.longrunning.Operation)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 NettyChannelBuilder (io.grpc.netty.NettyChannelBuilder)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 ConfigurationException (javax.naming.ConfigurationException)1