use of org.apache.beam.vendor.grpc.v1p43p2.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 org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project ballerina by ballerina-lang.
the class HelloClient method greet.
// Call Greet Method in Hello server.
public String greet(String name) {
StringValue stringValue = StringValue.newBuilder().setValue(name).build();
StringValue response;
try {
response = blockingStub.hello(stringValue);
log.info("gRPC >> Response Greetings : " + response);
return response.getValue();
} catch (StatusRuntimeException e) {
log.error("Error sending events to blocking stub.", e);
}
return "";
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project bookkeeper by apache.
the class TestLocationClientImpl method testLocateStorageContainersSucceedAfterRetried.
@Test
public void testLocateStorageContainersSucceedAfterRetried() throws Exception {
serviceRegistry.removeService(locationServiceDefinition);
final AtomicInteger retries = new AtomicInteger(3);
StatusRuntimeException statusException = new StatusRuntimeException(Status.INTERNAL);
StorageContainerServiceImplBase locationServiceWithFailures = new StorageContainerServiceImplBase() {
@Override
public void getStorageContainerEndpoint(GetStorageContainerEndpointRequest request, StreamObserver<GetStorageContainerEndpointResponse> responseObserver) {
if (retries.decrementAndGet() == 0) {
locationService.getStorageContainerEndpoint(request, responseObserver);
return;
}
responseObserver.onError(statusException);
}
};
serviceRegistry.addService(locationServiceWithFailures.bindService());
testLocateStorageContainersSuccess();
assertEquals(0, retries.get());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project bookkeeper by apache.
the class FailRequestStorageContainer method failWrongGroupRequest.
private <T> CompletableFuture<T> failWrongGroupRequest(long scId) {
CompletableFuture<T> future = FutureUtils.createFuture();
scheduler.executeOrdered(scId, () -> {
future.completeExceptionally(new StatusRuntimeException(Status.NOT_FOUND));
});
return future;
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project bookkeeper by apache.
the class TestMetaRangeClientImpl method testGetActiveStreamRangesFailure.
@Test
public void testGetActiveStreamRangesFailure() throws Exception {
CompletableFuture<StorageServerChannel> serviceFuture = FutureUtils.createFuture();
metaRangeClient.getStorageContainerClient().setStorageServerChannelFuture(serviceFuture);
MetaRangeServiceImplBase metaRangeService = new MetaRangeServiceImplBase() {
@Override
public void getActiveRanges(StorageContainerRequest request, StreamObserver<StorageContainerResponse> responseObserver) {
responseObserver.onError(new StatusRuntimeException(Status.INTERNAL));
}
};
serviceRegistry.addService(metaRangeService.bindService());
StorageServerChannel rsChannel = new StorageServerChannel(InProcessChannelBuilder.forName(serverName).directExecutor().build(), Optional.empty());
serviceFuture.complete(rsChannel);
CompletableFuture<HashStreamRanges> getFuture = metaRangeClient.getActiveDataRanges();
try {
getFuture.get();
fail("should fail on rpc failure");
} catch (ExecutionException ee) {
assertNotNull(ee.getCause());
assertTrue(ee.getCause() instanceof StatusRuntimeException);
StatusRuntimeException se = (StatusRuntimeException) ee.getCause();
assertEquals(Status.INTERNAL, se.getStatus());
}
}
Aggregations