Search in sources :

Example 1 with ExecutingOperationMetadata

use of build.buildfarm.v1test.ExecutingOperationMetadata in project bazel-buildfarm by bazelbuild.

the class AbstractServerInstance method expectRequestMetadata.

protected static RequestMetadata expectRequestMetadata(Operation operation) {
    String name = operation.getName();
    Any metadata = operation.getMetadata();
    QueuedOperationMetadata queuedOperationMetadata = maybeQueuedOperationMetadata(name, metadata);
    if (queuedOperationMetadata != null) {
        return queuedOperationMetadata.getRequestMetadata();
    }
    ExecutingOperationMetadata executingOperationMetadata = maybeExecutingOperationMetadata(name, metadata);
    if (executingOperationMetadata != null) {
        return executingOperationMetadata.getRequestMetadata();
    }
    CompletedOperationMetadata completedOperationMetadata = maybeCompletedOperationMetadata(name, metadata);
    if (completedOperationMetadata != null) {
        return completedOperationMetadata.getRequestMetadata();
    }
    return RequestMetadata.getDefaultInstance();
}
Also used : ExecutingOperationMetadata(build.buildfarm.v1test.ExecutingOperationMetadata) ByteString(com.google.protobuf.ByteString) QueuedOperationMetadata(build.buildfarm.v1test.QueuedOperationMetadata) CompletedOperationMetadata(build.buildfarm.v1test.CompletedOperationMetadata) Any(com.google.protobuf.Any)

Example 2 with ExecutingOperationMetadata

use of build.buildfarm.v1test.ExecutingOperationMetadata in project bazel-buildfarm by bazelbuild.

the class Cat method printOperation.

private static void printOperation(Operation operation) {
    System.out.println("Operation: " + operation.getName());
    System.out.println("Done: " + (operation.getDone() ? "true" : "false"));
    System.out.println("Metadata:");
    try {
        ExecuteOperationMetadata metadata;
        RequestMetadata requestMetadata;
        if (operation.getMetadata().is(QueuedOperationMetadata.class)) {
            QueuedOperationMetadata queuedOperationMetadata = operation.getMetadata().unpack(QueuedOperationMetadata.class);
            metadata = queuedOperationMetadata.getExecuteOperationMetadata();
            requestMetadata = queuedOperationMetadata.getRequestMetadata();
        } else if (operation.getMetadata().is(ExecutingOperationMetadata.class)) {
            ExecutingOperationMetadata executingMetadata = operation.getMetadata().unpack(ExecutingOperationMetadata.class);
            System.out.println("  Started At: " + new Date(executingMetadata.getStartedAt()));
            System.out.println("  Executing On: " + executingMetadata.getExecutingOn());
            metadata = executingMetadata.getExecuteOperationMetadata();
            requestMetadata = executingMetadata.getRequestMetadata();
        } else if (operation.getMetadata().is(CompletedOperationMetadata.class)) {
            CompletedOperationMetadata completedMetadata = operation.getMetadata().unpack(CompletedOperationMetadata.class);
            metadata = completedMetadata.getExecuteOperationMetadata();
            requestMetadata = completedMetadata.getRequestMetadata();
        } else {
            metadata = operation.getMetadata().unpack(ExecuteOperationMetadata.class);
            requestMetadata = null;
        }
        System.out.println("  Stage: " + metadata.getStage());
        System.out.println("  Action: " + DigestUtil.toString(metadata.getActionDigest()));
        System.out.println("  Stdout Stream: " + metadata.getStdoutStreamName());
        System.out.println("  Stderr Stream: " + metadata.getStderrStreamName());
        if (requestMetadata != null) {
            printRequestMetadata(requestMetadata);
        }
    } catch (InvalidProtocolBufferException e) {
        System.out.println("  UNKNOWN TYPE: " + e.getMessage());
    }
    if (operation.getDone()) {
        switch(operation.getResultCase()) {
            case RESPONSE:
                System.out.println("Response:");
                try {
                    printExecuteResponse(operation.getResponse().unpack(ExecuteResponse.class));
                } catch (InvalidProtocolBufferException e) {
                    System.out.println("  UNKNOWN RESPONSE TYPE: " + operation.getResponse());
                }
                break;
            case ERROR:
                System.out.println("Error: " + Code.forNumber(operation.getError().getCode()));
                break;
            default:
                System.out.println("  UNKNOWN RESULT!");
                break;
        }
    }
}
Also used : ExecutingOperationMetadata(build.buildfarm.v1test.ExecutingOperationMetadata) ExecuteOperationMetadata(build.bazel.remote.execution.v2.ExecuteOperationMetadata) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ExecuteResponse(build.bazel.remote.execution.v2.ExecuteResponse) QueuedOperationMetadata(build.buildfarm.v1test.QueuedOperationMetadata) CompletedOperationMetadata(build.buildfarm.v1test.CompletedOperationMetadata) Date(java.util.Date) RequestMetadata(build.bazel.remote.execution.v2.RequestMetadata)

Example 3 with ExecutingOperationMetadata

use of build.buildfarm.v1test.ExecutingOperationMetadata in project bazel-buildfarm by bazelbuild.

the class AbstractServerInstance method expectExecuteOperationMetadata.

protected static ExecuteOperationMetadata expectExecuteOperationMetadata(Operation operation) {
    String name = operation.getName();
    Any metadata = operation.getMetadata();
    QueuedOperationMetadata queuedOperationMetadata = maybeQueuedOperationMetadata(name, metadata);
    if (queuedOperationMetadata != null) {
        return queuedOperationMetadata.getExecuteOperationMetadata();
    }
    ExecutingOperationMetadata executingOperationMetadata = maybeExecutingOperationMetadata(name, metadata);
    if (executingOperationMetadata != null) {
        return executingOperationMetadata.getExecuteOperationMetadata();
    }
    CompletedOperationMetadata completedOperationMetadata = maybeCompletedOperationMetadata(name, metadata);
    if (completedOperationMetadata != null) {
        return completedOperationMetadata.getExecuteOperationMetadata();
    }
    try {
        return operation.getMetadata().unpack(ExecuteOperationMetadata.class);
    } catch (InvalidProtocolBufferException e) {
        logger.log(Level.SEVERE, format("invalid execute operation metadata %s", operation.getName()), e);
    }
    return null;
}
Also used : ExecutingOperationMetadata(build.buildfarm.v1test.ExecutingOperationMetadata) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ByteString(com.google.protobuf.ByteString) QueuedOperationMetadata(build.buildfarm.v1test.QueuedOperationMetadata) CompletedOperationMetadata(build.buildfarm.v1test.CompletedOperationMetadata) Any(com.google.protobuf.Any)

Example 4 with ExecutingOperationMetadata

use of build.buildfarm.v1test.ExecutingOperationMetadata in project bazel-buildfarm by bazelbuild.

the class EnrichedOperationBuilder method operationToActionDigest.

/**
 * @brief Get the action digest of the operation.
 * @details Extracted out of the relevant operation metadata.
 * @param operation The operation.
 * @return The extracted digest.
 * @note Suggested return identifier: digest.
 */
@SuppressWarnings("ConstantConditions")
private static Digest operationToActionDigest(Operation operation) {
    ExecuteOperationMetadata metadata;
    try {
        if (operation.getMetadata().is(QueuedOperationMetadata.class)) {
            QueuedOperationMetadata queuedOperationMetadata = operation.getMetadata().unpack(QueuedOperationMetadata.class);
            metadata = queuedOperationMetadata.getExecuteOperationMetadata();
        } else if (operation.getMetadata().is(ExecutingOperationMetadata.class)) {
            ExecutingOperationMetadata executingMetadata = operation.getMetadata().unpack(ExecutingOperationMetadata.class);
            metadata = executingMetadata.getExecuteOperationMetadata();
        } else if (operation.getMetadata().is(CompletedOperationMetadata.class)) {
            CompletedOperationMetadata completedMetadata = operation.getMetadata().unpack(CompletedOperationMetadata.class);
            metadata = completedMetadata.getExecuteOperationMetadata();
        } else {
            metadata = operation.getMetadata().unpack(ExecuteOperationMetadata.class);
        }
    } catch (InvalidProtocolBufferException e) {
        logger.log(Level.WARNING, "InvalidProtocolBufferException while building an operation.", e);
        metadata = null;
    }
    return metadata.getActionDigest();
}
Also used : ExecutingOperationMetadata(build.buildfarm.v1test.ExecutingOperationMetadata) ExecuteOperationMetadata(build.bazel.remote.execution.v2.ExecuteOperationMetadata) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) QueuedOperationMetadata(build.buildfarm.v1test.QueuedOperationMetadata) CompletedOperationMetadata(build.buildfarm.v1test.CompletedOperationMetadata)

Aggregations

CompletedOperationMetadata (build.buildfarm.v1test.CompletedOperationMetadata)4 ExecutingOperationMetadata (build.buildfarm.v1test.ExecutingOperationMetadata)4 QueuedOperationMetadata (build.buildfarm.v1test.QueuedOperationMetadata)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 ExecuteOperationMetadata (build.bazel.remote.execution.v2.ExecuteOperationMetadata)2 Any (com.google.protobuf.Any)2 ByteString (com.google.protobuf.ByteString)2 ExecuteResponse (build.bazel.remote.execution.v2.ExecuteResponse)1 RequestMetadata (build.bazel.remote.execution.v2.RequestMetadata)1 Date (java.util.Date)1