use of build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response in project bazel-buildfarm by bazelbuild.
the class ContentAddressableStorageService method instanceFindMissingBlobs.
void instanceFindMissingBlobs(Instance instance, FindMissingBlobsRequest request, StreamObserver<FindMissingBlobsResponse> responseObserver) {
Stopwatch stopwatch = Stopwatch.createStarted();
FindMissingBlobsResponse.Builder builder = FindMissingBlobsResponse.newBuilder();
ListenableFuture<FindMissingBlobsResponse.Builder> responseFuture = transform(instance.findMissingBlobs(request.getBlobDigestsList(), TracingMetadataUtils.fromCurrentContext()), builder::addAllMissingBlobDigests, directExecutor());
addCallback(responseFuture, new FutureCallback<FindMissingBlobsResponse.Builder>() {
@Override
public void onSuccess(FindMissingBlobsResponse.Builder builder) {
try {
FindMissingBlobsResponse response = builder.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
long elapsedMicros = stopwatch.elapsed(MICROSECONDS);
missingBlobs.observe(request.getBlobDigestsList().size());
logger.log(Level.FINE, "FindMissingBlobs(" + instance.getName() + ") for " + request.getBlobDigestsList().size() + " blobs in " + elapsedMicros / 1000.0);
} catch (Throwable t) {
onFailure(t);
}
}
@SuppressWarnings("NullableProblems")
@Override
public void onFailure(Throwable t) {
Status status = Status.fromThrowable(t);
if (status.getCode() != Code.CANCELLED) {
logger.log(Level.SEVERE, format("findMissingBlobs(%s): %d", request.getInstanceName(), request.getBlobDigestsCount()), t);
responseObserver.onError(t);
}
}
}, directExecutor());
}
use of build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response in project bazel-buildfarm by bazelbuild.
the class StubInstance method putAllBlobs.
@Override
public Iterable<Digest> putAllBlobs(Iterable<ByteString> blobs, RequestMetadata requestMetadata) {
long totalSize = 0;
ImmutableList.Builder<Request> requests = ImmutableList.builder();
for (ByteString blob : blobs) {
checkState(totalSize + blob.size() <= maxBatchUpdateBlobsSize);
requests.add(Request.newBuilder().setDigest(digestUtil.compute(blob)).setData(blob).build());
totalSize += blob.size();
}
BatchUpdateBlobsRequest batchRequest = BatchUpdateBlobsRequest.newBuilder().setInstanceName(getName()).addAllRequests(requests.build()).build();
BatchUpdateBlobsResponse batchResponse = deadlined(casBlockingStub).withInterceptors(attachMetadataInterceptor(requestMetadata)).batchUpdateBlobs(batchRequest);
PutAllBlobsException exception = null;
for (BatchUpdateBlobsResponse.Response response : batchResponse.getResponsesList()) {
com.google.rpc.Status status = response.getStatus();
if (Code.forNumber(status.getCode()) != Code.OK) {
if (exception == null) {
exception = new PutAllBlobsException();
}
exception.addFailedResponse(response);
}
}
if (exception != null) {
throw exception;
}
return Iterables.transform(batchResponse.getResponsesList(), BatchUpdateBlobsResponse.Response::getDigest);
}
use of build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response in project bazel-buildfarm by bazelbuild.
the class AbstractServerInstance method expireOperation.
protected void expireOperation(Operation operation) throws InterruptedException {
ActionResult actionResult = ActionResult.newBuilder().setExitCode(-1).setStderrRaw(ByteString.copyFromUtf8("[BUILDFARM]: Action timed out with no response from worker")).build();
ExecuteResponse executeResponse = ExecuteResponse.newBuilder().setResult(actionResult).setStatus(com.google.rpc.Status.newBuilder().setCode(Code.DEADLINE_EXCEEDED.getNumber())).build();
ExecuteOperationMetadata metadata = expectExecuteOperationMetadata(operation);
if (metadata == null) {
throw new IllegalStateException("Operation " + operation.getName() + " did not contain valid metadata");
}
metadata = metadata.toBuilder().setStage(ExecutionStage.Value.COMPLETED).build();
putOperation(operation.toBuilder().setDone(true).setMetadata(Any.pack(metadata)).setResponse(Any.pack(executeResponse)).build());
}
use of build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response in project tools_remote by bazelbuild.
the class ActionGroupingTest method makeExecute.
private RpcCallDetails makeExecute(ActionResult result) {
ExecuteResponse response = ExecuteResponse.newBuilder().setResult(result).build();
Operation operation = Operation.newBuilder().setResponse(Any.pack(response)).setDone(true).build();
ExecuteDetails execute = ExecuteDetails.newBuilder().addResponses(operation).build();
return RpcCallDetails.newBuilder().setExecute(execute).build();
}
use of build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response in project tools_remote by bazelbuild.
the class LogParserUtils method extractExecuteResponse.
private static List<ExecuteResponse> extractExecuteResponse(List<Operation> operations) throws IOException {
ArrayList<ExecuteResponse> result = new ArrayList<>();
for (Operation o : operations) {
StringBuilder error = new StringBuilder();
ExecuteResponse response = getExecuteResponse(o, ExecuteResponse.class, error);
if (response != null && (response.hasResult() || (response.hasStatus()) && response.getStatus().getCode() != Code.OK.value())) {
result.add(response);
}
}
return result;
}
Aggregations