use of build.buildfarm.common.UrlPath.InvalidResourceNameException in project bazel-buildfarm by bazelbuild.
the class ByteStreamService method read.
@Override
public void read(ReadRequest request, StreamObserver<ReadResponse> responseObserver) {
String resourceName = request.getResourceName();
long offset = request.getReadOffset();
long limit = request.getReadLimit();
logger.log(Level.FINER, format("read resource_name=%s offset=%d limit=%d", resourceName, offset, limit));
try {
maybeInstanceRead(resourceName, offset, limit, responseObserver);
} catch (InvalidResourceNameException e) {
responseObserver.onError(INVALID_ARGUMENT.withDescription(e.getMessage()).asException());
}
}
use of build.buildfarm.common.UrlPath.InvalidResourceNameException in project bazel-buildfarm by bazelbuild.
the class ByteStreamService method read.
@Override
public void read(ReadRequest request, StreamObserver<ReadResponse> responseObserver) {
String resourceName = request.getResourceName();
long readLimit = request.getReadLimit();
long readOffset = request.getReadOffset();
if (readLimit < 0 || readOffset < 0) {
responseObserver.onError(Status.OUT_OF_RANGE.asException());
return;
}
try {
ResourceOperation resourceOperation = detectResourceOperation(resourceName);
if (resourceOperation == ResourceOperation.Blob) {
readBlob(request, responseObserver);
} else {
throw new InvalidResourceNameException(resourceName, "Unsupported service");
}
} catch (IllegalArgumentException | InvalidResourceNameException e) {
String description = e.getLocalizedMessage();
responseObserver.onError(Status.INVALID_ARGUMENT.withDescription(description).asException());
}
}
use of build.buildfarm.common.UrlPath.InvalidResourceNameException in project bazel-buildfarm by bazelbuild.
the class ByteStreamService method queryWriteStatus.
@Override
public void queryWriteStatus(QueryWriteStatusRequest request, StreamObserver<QueryWriteStatusResponse> responseObserver) {
String resourceName = request.getResourceName();
Write write;
try {
write = findWrite(resourceName);
} catch (InvalidResourceNameException e) {
String description = e.getLocalizedMessage();
responseObserver.onError(Status.INVALID_ARGUMENT.withDescription(description).asException());
return;
} catch (IOException e) {
responseObserver.onError(Status.fromThrowable(e).asException());
return;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
if (write != null) {
responseObserver.onNext(QueryWriteStatusResponse.newBuilder().setCommittedSize(write.getCommittedSize()).setComplete(write.getComplete()).build());
responseObserver.onCompleted();
} else {
responseObserver.onError(Status.NOT_FOUND.asException());
}
}
use of build.buildfarm.common.UrlPath.InvalidResourceNameException in project bazel-buildfarm by bazelbuild.
the class ByteStreamService method queryWriteStatus.
@Override
public void queryWriteStatus(QueryWriteStatusRequest request, StreamObserver<QueryWriteStatusResponse> responseObserver) {
String resourceName = request.getResourceName();
try {
logger.log(Level.FINE, format("queryWriteStatus(%s)", resourceName));
Write write = getWrite(resourceName);
responseObserver.onNext(QueryWriteStatusResponse.newBuilder().setCommittedSize(write.getCommittedSize()).setComplete(write.isComplete()).build());
responseObserver.onCompleted();
logger.log(Level.FINE, format("queryWriteStatus(%s) => committed_size = %d, complete = %s", resourceName, write.getCommittedSize(), write.isComplete()));
} catch (IllegalArgumentException | InvalidResourceNameException e) {
logger.log(Level.SEVERE, format("queryWriteStatus(%s)", resourceName), e);
responseObserver.onError(INVALID_ARGUMENT.withDescription(e.getMessage()).asException());
} catch (EntryLimitException e) {
logger.log(Level.WARNING, format("queryWriteStatus(%s): %s", resourceName, e.getMessage()));
responseObserver.onNext(QueryWriteStatusResponse.getDefaultInstance());
responseObserver.onCompleted();
} catch (RuntimeException e) {
logger.log(Level.SEVERE, format("queryWriteStatus(%s)", resourceName), e);
responseObserver.onError(Status.fromThrowable(e).asException());
}
}
Aggregations