Search in sources :

Example 1 with ExecutionStub

use of build.bazel.remote.execution.v2.ExecutionGrpc.ExecutionStub in project bazel-buildfarm by bazelbuild.

the class Executor method executeActions.

static void executeActions(String instanceName, List<Digest> actionDigests, ExecutionStub execStub) throws InterruptedException {
    ScheduledExecutorService service = newSingleThreadScheduledExecutor();
    AtomicInteger[] statusCounts = new AtomicInteger[18];
    for (int i = 0; i < statusCounts.length; i++) {
        statusCounts[i] = new AtomicInteger(0);
    }
    AtomicLong countdown = new AtomicLong(actionDigests.size());
    for (Digest actionDigest : actionDigests) {
        ExecutionObserver executionObserver = new ExecutionObserver(countdown, statusCounts, execStub, instanceName, actionDigest, service);
        executionObserver.execute();
        MICROSECONDS.sleep(1);
    }
    while (countdown.get() != 0) {
        SECONDS.sleep(1);
    }
    for (int i = 0; i < statusCounts.length; i++) {
        AtomicInteger statusCount = statusCounts[i];
        if (statusCount.get() != 0) {
            System.out.println("Status " + Code.forNumber(i) + " : " + statusCount.get() + " responses");
        }
    }
    shutdownAndAwaitTermination(service, 1, SECONDS);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Digest(build.bazel.remote.execution.v2.Digest)

Example 2 with ExecutionStub

use of build.bazel.remote.execution.v2.ExecutionGrpc.ExecutionStub in project bazel-buildfarm by bazelbuild.

the class Executor method main.

public static void main(String[] args) throws Exception {
    String host = args[0];
    String instanceName = args[1];
    String blobsDir;
    if (args.length == 3) {
        blobsDir = args[2];
    } else {
        blobsDir = null;
    }
    Scanner scanner = new Scanner(System.in);
    ImmutableList.Builder<Digest> actionDigests = ImmutableList.builder();
    while (scanner.hasNext()) {
        actionDigests.add(DigestUtil.parseDigest(scanner.nextLine()));
    }
    ManagedChannel channel = createChannel(host);
    if (blobsDir != null) {
        System.out.println("Loading blobs into cas");
        loadFilesIntoCAS(instanceName, channel, Paths.get(blobsDir));
    }
    ExecutionStub execStub = ExecutionGrpc.newStub(channel);
    executeActions(instanceName, actionDigests.build(), execStub);
    channel.shutdown();
    channel.awaitTermination(1, SECONDS);
}
Also used : Scanner(java.util.Scanner) ExecutionStub(build.bazel.remote.execution.v2.ExecutionGrpc.ExecutionStub) Digest(build.bazel.remote.execution.v2.Digest) ImmutableList(com.google.common.collect.ImmutableList) ManagedChannel(io.grpc.ManagedChannel) ByteString(com.google.protobuf.ByteString)

Aggregations

Digest (build.bazel.remote.execution.v2.Digest)2 ExecutionStub (build.bazel.remote.execution.v2.ExecutionGrpc.ExecutionStub)1 ImmutableList (com.google.common.collect.ImmutableList)1 ByteString (com.google.protobuf.ByteString)1 ManagedChannel (io.grpc.ManagedChannel)1 Scanner (java.util.Scanner)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1