use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method createMetadataTableIfNotExists.
private void createMetadataTableIfNotExists() throws ExecutionException {
if (metadataTableExists()) {
return;
}
List<AttributeDefinition> columnsToAttributeDefinitions = new ArrayList<>();
columnsToAttributeDefinitions.add(AttributeDefinition.builder().attributeName(METADATA_ATTR_TABLE).attributeType(ScalarAttributeType.S).build());
try {
client.createTable(CreateTableRequest.builder().attributeDefinitions(columnsToAttributeDefinitions).keySchema(KeySchemaElement.builder().attributeName(METADATA_ATTR_TABLE).keyType(KeyType.HASH).build()).provisionedThroughput(ProvisionedThroughput.builder().readCapacityUnits(METADATA_TABLE_REQUEST_UNIT).writeCapacityUnits(METADATA_TABLE_REQUEST_UNIT).build()).tableName(getMetadataTable()).build());
} catch (Exception e) {
throw new ExecutionException("creating the metadata table failed", e);
}
waitForTableCreation(getMetadataTable());
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DeleteStatementHandler method handle.
@Nonnull
@Override
public List<Map<String, AttributeValue>> handle(Operation operation) throws ExecutionException {
checkArgument(operation, Delete.class);
Delete delete = (Delete) operation;
TableMetadata tableMetadata = metadataManager.getTableMetadata(operation);
try {
delete(delete, tableMetadata);
} catch (ConditionalCheckFailedException e) {
throw new NoMutationException("no mutation was applied.", e);
} catch (TransactionConflictException e) {
throw new RetriableExecutionException(e.getMessage(), e);
} catch (DynamoDbException e) {
throw new ExecutionException(e.getMessage(), e);
}
return Collections.emptyList();
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class SelectStatementHandler method handle.
@Nonnull
@Override
public List<Map<String, AttributeValue>> handle(Operation operation) throws ExecutionException {
checkArgument(operation, Get.class, Scan.class);
TableMetadata tableMetadata = metadataManager.getTableMetadata(operation);
try {
if (ScalarDbUtils.isSecondaryIndexSpecified(operation, tableMetadata)) {
return executeQueryWithIndex((Selection) operation, tableMetadata);
}
if (operation instanceof Get) {
return executeGet((Get) operation, tableMetadata);
} else {
return executeQuery((Scan) operation, tableMetadata);
}
} catch (DynamoDbException e) {
throw new ExecutionException(e.getMessage(), e);
}
}
Aggregations