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();
}
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;
}
}
}
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;
}
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();
}
Aggregations