use of io.grpc.StatusRuntimeException in project grakn by graknlabs.
the class GrpcGraknService method delete.
@Override
public void delete(DeleteRequest request, StreamObserver<DeleteResponse> responseObserver) {
try {
runAndConvertGraknExceptions(() -> {
try (GraknTx tx = executor.execute(request.getOpen())) {
tx.admin().delete();
}
responseObserver.onNext(GrpcUtil.deleteResponse());
responseObserver.onCompleted();
});
} catch (StatusRuntimeException e) {
responseObserver.onError(e);
}
}
use of io.grpc.StatusRuntimeException in project core-java by SpineEventEngine.
the class RequestValidator method feedToResponse.
private static void feedToResponse(InvalidRequestException cause, StreamObserver<?> responseObserver) {
final StatusRuntimeException validationException = invalidArgumentWithCause(cause);
responseObserver.onError(validationException);
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SpannerExceptionFactoryTest method abortWithRetryInfo.
@Test
public void abortWithRetryInfo() {
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
Metadata trailers = new Metadata();
RetryInfo retryInfo = RetryInfo.newBuilder().setRetryDelay(Duration.newBuilder().setNanos(1000000).setSeconds(1L)).build();
trailers.put(key, retryInfo);
SpannerException e = SpannerExceptionFactory.newSpannerException(new StatusRuntimeException(status, trailers));
assertThat(e).isInstanceOf(AbortedException.class);
assertThat(((AbortedException) e).getRetryDelayInMillis()).isEqualTo(1001L);
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class TransactionRunnerImplTest method createRetryException.
private StatusRuntimeException createRetryException() {
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
Metadata trailers = new Metadata();
RetryInfo retryInfo = RetryInfo.newBuilder().setRetryDelay(Duration.newBuilder().setNanos(1000000).setSeconds(1L)).build();
trailers.put(key, retryInfo);
return new StatusRuntimeException(status, trailers);
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SpannerExceptionFactoryTest method http2InternalErrorIsRetryable.
@Test
public void http2InternalErrorIsRetryable() {
Status status = Status.fromCodeValue(Status.Code.INTERNAL.value()).withDescription("HTTP/2 error code: INTERNAL_ERROR");
SpannerException e = SpannerExceptionFactory.newSpannerException(new StatusRuntimeException(status));
assertThat(e.isRetryable()).isTrue();
}
Aggregations