use of com.amazonaws.services.dynamodbv2.model.DeleteTableRequest in project jcabi-dynamo by jcabi.
the class MadeTable method drop.
/**
* Drop table.
* @throws InterruptedException If something fails
*/
public void drop() throws InterruptedException {
final AmazonDynamoDB aws = this.region.aws();
final String name = this.request.getTableName();
aws.deleteTable(new DeleteTableRequest().withTableName(name));
Logger.info(this, "DynamoDB table '%s' deletion requested", name);
while (this.exists()) {
Logger.info(this, "DynamoDB table '%s' still exists", name);
TimeUnit.SECONDS.sleep((long) Tv.TEN);
}
Logger.info(this, "DynamoDB table '%s' deleted", name);
}
use of com.amazonaws.services.dynamodbv2.model.DeleteTableRequest in project camel by apache.
the class DeleteTableCommand method execute.
@Override
public void execute() {
TableDescription tableDescription = ddbClient.deleteTable(new DeleteTableRequest(determineTableName())).getTableDescription();
Map tmp = new HashMap<>();
tmp.put(DdbConstants.PROVISIONED_THROUGHPUT, tableDescription.getProvisionedThroughput());
tmp.put(DdbConstants.CREATION_DATE, tableDescription.getCreationDateTime());
tmp.put(DdbConstants.ITEM_COUNT, tableDescription.getItemCount());
tmp.put(DdbConstants.KEY_SCHEMA, tableDescription.getKeySchema());
tmp.put(DdbConstants.TABLE_NAME, tableDescription.getTableName());
tmp.put(DdbConstants.TABLE_SIZE, tableDescription.getTableSizeBytes());
tmp.put(DdbConstants.TABLE_STATUS, tableDescription.getTableStatus());
addToResults(tmp);
}
use of com.amazonaws.services.dynamodbv2.model.DeleteTableRequest in project cas by apereo.
the class DynamoDbCloudConfigBootstrapConfiguration method createSettingsTable.
@SneakyThrows
private static void createSettingsTable(final AmazonDynamoDB amazonDynamoDBClient, final boolean deleteTables) {
final String name = ColumnNames.ID.getColumnName();
final CreateTableRequest request = new CreateTableRequest().withAttributeDefinitions(new AttributeDefinition(name, ScalarAttributeType.S)).withKeySchema(new KeySchemaElement(name, KeyType.HASH)).withProvisionedThroughput(new ProvisionedThroughput(PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT)).withTableName(TABLE_NAME);
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
}
use of com.amazonaws.services.dynamodbv2.model.DeleteTableRequest in project cas by apereo.
the class DynamoDbServiceRegistryFacilitator method createServicesTable.
/**
* Create tables.
*
* @param deleteTables the delete tables
*/
@SneakyThrows
public void createServicesTable(final boolean deleteTables) {
LOGGER.debug("Attempting to create DynamoDb services table");
final CreateTableRequest request = new CreateTableRequest().withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getColumnName(), ScalarAttributeType.S)).withKeySchema(new KeySchemaElement(ColumnNames.ID.getColumnName(), KeyType.HASH)).withProvisionedThroughput(new ProvisionedThroughput(dynamoDbProperties.getReadCapacity(), dynamoDbProperties.getWriteCapacity())).withTableName(dynamoDbProperties.getTableName());
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
}
use of com.amazonaws.services.dynamodbv2.model.DeleteTableRequest in project amos-ss17-alexa by c-i-ber.
the class DynamoDbMapper method dropTable.
/**
* drops table by a pojo class
*
* @param cl class which will be mapped to drop a table
*/
public void dropTable(Class cl) {
DeleteTableRequest tableRequest = mapper.generateDeleteTableRequest(cl);
Table table = dynamoDB.getTable(tableRequest.getTableName());
try {
dynamoDbClient.deleteTable(tableRequest);
table.waitForDelete();
} catch (ResourceNotFoundException e) {
// Table does not exist
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations