use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class MutateStatementHandler method throwException.
private void throwException(CosmosException exception) throws ExecutionException {
LOGGER.error(exception.getMessage());
int statusCode = exception.getSubStatusCode();
if (statusCode == CosmosErrorCode.PRECONDITION_FAILED.get()) {
throw new NoMutationException("no mutation was applied.");
} else if (statusCode == CosmosErrorCode.RETRY_WITH.get()) {
throw new RetriableExecutionException(exception.getMessage(), exception);
}
throw new ExecutionException(exception.getMessage(), exception);
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class JdbcTransaction method delete.
@Override
public void delete(Delete delete) throws CrudException {
delete = copyAndSetTargetToIfNot(delete);
// Ignore the condition in the delete
if (delete.getCondition().isPresent()) {
LOGGER.warn("ignoring the condition of the mutation: {}", delete);
delete.withCondition(null);
}
try {
jdbcService.delete(delete, connection);
} catch (SQLException e) {
throw createCrudException(e, "delete operation failed");
} catch (ExecutionException e) {
throw new CrudException("delete operation failed", e);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class GrpcScanOnBidirectionalStream method closeScanner.
public void closeScanner() throws ExecutionException {
try {
if (!hasMoreResults.get()) {
return;
}
hasMoreResults.set(false);
requestStream.onCompleted();
} catch (StatusRuntimeException e) {
throw new ExecutionException("failed to close the scanner", e);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class CrudHandler method getFromStorage.
private Optional<TransactionResult> getFromStorage(Get get) throws CrudException {
try {
// get only after image columns
get.clearProjections();
LinkedHashSet<String> afterImageColumnNames = tableMetadataManager.getTransactionalTableMetadata(get).getAfterImageColumnNames();
get.withProjections(afterImageColumnNames);
get.withConsistency(Consistency.LINEARIZABLE);
return storage.get(get).map(TransactionResult::new);
} catch (ExecutionException e) {
throw new CrudException("get failed.", e);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method createTable.
@Override
public void createTable(String namespace, String table, TableMetadata metadata, Map<String, String> options) throws ExecutionException {
checkMetadata(metadata);
long ru = Long.parseLong(options.getOrDefault(REQUEST_UNIT, DEFAULT_REQUEST_UNIT));
CreateTableRequest.Builder requestBuilder = CreateTableRequest.builder();
buildAttributeDefinitions(requestBuilder, metadata);
buildPrimaryKey(requestBuilder, metadata);
buildSecondaryIndexes(namespace, table, requestBuilder, metadata, ru);
requestBuilder.provisionedThroughput(ProvisionedThroughput.builder().readCapacityUnits(ru).writeCapacityUnits(ru).build());
requestBuilder.tableName(getFullTableName(namespace, table));
try {
client.createTable(requestBuilder.build());
} catch (Exception e) {
throw new ExecutionException("creating the table failed", e);
}
waitForTableCreation(namespace, table);
boolean noScaling = Boolean.parseBoolean(options.getOrDefault(NO_SCALING, DEFAULT_NO_SCALING));
if (!noScaling) {
enableAutoScaling(namespace, table, metadata.getSecondaryIndexNames(), ru);
}
boolean noBackup = Boolean.parseBoolean(options.getOrDefault(NO_BACKUP, DEFAULT_NO_BACKUP));
if (!noBackup) {
enableContinuousBackup(namespace, table);
}
createMetadataTableIfNotExists(noBackup);
putTableMetadata(namespace, table, metadata);
}
Aggregations