use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class JdbcDatabase method delete.
@Override
public void delete(Delete delete) throws ExecutionException {
delete = copyAndSetTargetToIfNot(delete);
Connection connection = null;
try {
connection = dataSource.getConnection();
if (!jdbcService.delete(delete, connection)) {
throw new NoMutationException("no mutation was applied");
}
} catch (SQLException e) {
throw new ExecutionException("delete operation failed", e);
} finally {
close(connection);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class JdbcDatabase method get.
@Override
public Optional<Result> get(Get get) throws ExecutionException {
get = copyAndSetTargetToIfNot(get);
Connection connection = null;
try {
connection = dataSource.getConnection();
return jdbcService.get(get, connection);
} catch (SQLException e) {
throw new ExecutionException("get operation failed", e);
} finally {
close(connection);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class GrpcScanOnBidirectionalStream method throwIfErrorForNext.
private void throwIfErrorForNext(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 (error instanceof Error) {
throw (Error) error;
}
throw new ExecutionException("failed to next", error);
}
}
use of com.scalar.db.exception.storage.ExecutionException 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.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class CrudHandler method getFromStorage.
private Scanner getFromStorage(Scan scan) throws CrudException {
try {
// get only after image columns
scan.clearProjections();
LinkedHashSet<String> afterImageColumnNames = tableMetadataManager.getTransactionalTableMetadata(scan).getAfterImageColumnNames();
scan.withProjections(afterImageColumnNames);
scan.withConsistency(Consistency.LINEARIZABLE);
return storage.scan(scan);
} catch (ExecutionException e) {
throw new CrudException("scan failed.", e);
}
}
Aggregations