use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method waitForTableDeletion.
private void waitForTableDeletion(String namespace, String tableName) throws ExecutionException {
try {
while (true) {
Uninterruptibles.sleepUninterruptibly(WAITING_DURATION_SECS, TimeUnit.SECONDS);
Set<String> tableSet = getNamespaceTableNames(namespace);
if (!tableSet.contains(tableName)) {
break;
}
}
} catch (Exception e) {
throw new ExecutionException("waiting for the table deletion failed", e);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method waitForIndexCreation.
private void waitForIndexCreation(String namespace, String table, String columnName) throws ExecutionException {
try {
String indexName = getGlobalIndexName(namespace, table, columnName);
while (true) {
Uninterruptibles.sleepUninterruptibly(WAITING_DURATION_SECS, TimeUnit.SECONDS);
DescribeTableResponse response = client.describeTable(DescribeTableRequest.builder().tableName(getFullTableName(namespace, table)).build());
for (GlobalSecondaryIndexDescription globalSecondaryIndex : response.table().globalSecondaryIndexes()) {
if (globalSecondaryIndex.indexName().equals(indexName)) {
if (globalSecondaryIndex.indexStatus() == IndexStatus.ACTIVE) {
return;
}
}
}
}
} catch (Exception e) {
throw new ExecutionException("waiting for the secondary index creation failed", e);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method waitForTableBackupEnabledAtCreation.
private void waitForTableBackupEnabledAtCreation(String namespace, String table) throws ExecutionException {
try {
while (true) {
Uninterruptibles.sleepUninterruptibly(WAITING_DURATION_SECS, TimeUnit.SECONDS);
DescribeContinuousBackupsResponse describeContinuousBackupsResponse = client.describeContinuousBackups(DescribeContinuousBackupsRequest.builder().tableName(getFullTableName(namespace, table)).build());
if (describeContinuousBackupsResponse.continuousBackupsDescription().continuousBackupsStatus() == ContinuousBackupsStatus.ENABLED) {
break;
}
}
} catch (Exception e) {
throw new ExecutionException("waiting for the table backup enabled at creation failed", e);
}
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method dropTable.
@Override
public void dropTable(String namespace, String table) throws ExecutionException {
disableAutoScaling(namespace, table);
String fullTableName = getFullTableName(namespace, table);
try {
client.deleteTable(DeleteTableRequest.builder().tableName(fullTableName).build());
} catch (Exception e) {
throw new ExecutionException("deleting table " + fullTableName + " failed", e);
}
waitForTableDeletion(namespace, table);
deleteTableMetadata(namespace, table);
}
use of com.scalar.db.exception.storage.ExecutionException in project scalardb by scalar-labs.
the class DynamoAdmin method readMetadata.
private TableMetadata readMetadata(String fullName) throws ExecutionException {
Map<String, AttributeValue> key = new HashMap<>();
key.put(METADATA_ATTR_TABLE, AttributeValue.builder().s(fullName).build());
try {
Map<String, AttributeValue> metadata = client.getItem(GetItemRequest.builder().tableName(getFullTableName(metadataNamespace, METADATA_TABLE)).key(key).consistentRead(true).build()).item();
if (metadata.isEmpty()) {
// The specified table is not found
return null;
}
return createTableMetadata(metadata);
} catch (Exception e) {
throw new ExecutionException("Failed to read the table metadata", e);
}
}
Aggregations