use of com.scalar.db.util.retry.ServiceTemporaryUnavailableException in project scalardb by scalar-labs.
the class GrpcScanOnBidirectionalStream method throwIfErrorForOpenScanner.
private void throwIfErrorForOpenScanner(ResponseOrError responseOrError) throws ExecutionException {
if (responseOrError.isError()) {
hasMoreResults.set(false);
Throwable error = responseOrError.getError();
if (error instanceof StatusRuntimeException) {
StatusRuntimeException e = (StatusRuntimeException) error;
if (e.getStatus().getCode() == Code.INVALID_ARGUMENT) {
throw new IllegalArgumentException(e.getMessage(), e);
}
if (e.getStatus().getCode() == Code.UNAVAILABLE) {
throw new ServiceTemporaryUnavailableException(e.getMessage(), e);
}
}
if (error instanceof Error) {
throw (Error) error;
}
throw new ExecutionException("failed to open scanner", error);
}
}
use of com.scalar.db.util.retry.ServiceTemporaryUnavailableException in project scalardb by scalar-labs.
the class GrpcTransactionOnBidirectionalStream method throwIfErrorForStart.
private void throwIfErrorForStart(ResponseOrError responseOrError) throws TransactionException {
if (responseOrError.isError()) {
finished.set(true);
Throwable error = responseOrError.getError();
if (error instanceof StatusRuntimeException) {
StatusRuntimeException e = (StatusRuntimeException) error;
if (e.getStatus().getCode() == Code.INVALID_ARGUMENT) {
throw new IllegalArgumentException(e.getMessage(), e);
}
if (e.getStatus().getCode() == Code.UNAVAILABLE) {
throw new ServiceTemporaryUnavailableException(e.getMessage(), e);
}
}
if (error instanceof Error) {
throw (Error) error;
}
throw new TransactionException("failed to start", error);
}
}
use of com.scalar.db.util.retry.ServiceTemporaryUnavailableException in project scalardb by scalar-labs.
the class GrpcTwoPhaseCommitTransactionOnBidirectionalStream method throwIfErrorForStartOrJoin.
private void throwIfErrorForStartOrJoin(ResponseOrError responseOrError, boolean start) throws TransactionException {
if (responseOrError.isError()) {
finished.set(true);
Throwable error = responseOrError.getError();
if (error instanceof StatusRuntimeException) {
StatusRuntimeException e = (StatusRuntimeException) error;
if (e.getStatus().getCode() == Code.INVALID_ARGUMENT) {
throw new IllegalArgumentException(e.getMessage(), e);
}
if (e.getStatus().getCode() == Code.UNAVAILABLE) {
throw new ServiceTemporaryUnavailableException(e.getMessage(), e);
}
}
if (error instanceof Error) {
throw (Error) error;
}
throw new TransactionException("failed to " + (start ? "start" : "join"), error);
}
}
Aggregations