use of com.amazonaws.services.dynamodbv2.document.DynamoDB in project aws-doc-sdk-examples by awsdocs.
the class ListTables method main.
public static void main(String[] args) {
System.out.println("Your DynamoDB tables:\n");
final AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
boolean more_tables = true;
while (more_tables) {
String last_name = null;
try {
ListTablesResult table_list = null;
if (last_name == null) {
table_list = ddb.listTables();
}
List<String> table_names = table_list.getTableNames();
if (table_names.size() > 0) {
for (String cur_name : table_names) {
System.out.format("* %s\n", cur_name);
}
} else {
System.out.println("No tables found!");
System.exit(0);
}
last_name = table_list.getLastEvaluatedTableName();
if (last_name == null) {
more_tables = false;
}
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.exit(1);
}
}
System.out.println("\nDone!");
}
use of com.amazonaws.services.dynamodbv2.document.DynamoDB in project tutorials by eugenp.
the class SavePersonHandler method initDynamoDbClient.
private void initDynamoDbClient() {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setRegion(Region.getRegion(REGION));
this.dynamoDb = new DynamoDB(client);
}
use of com.amazonaws.services.dynamodbv2.document.DynamoDB in project jcabi-dynamo by jcabi.
the class MadeTable method exists.
/**
* The table exists?
* @return TRUE if it exists in DynamoDB
* @since 0.9
*/
public boolean exists() {
final AmazonDynamoDB aws = this.region.aws();
final String name = this.request.getTableName();
boolean exists;
try {
aws.describeTable(name);
exists = true;
Logger.info(this, "DynamoDB table '%s' already exists", name);
} catch (final ResourceNotFoundException ex) {
exists = false;
Logger.info(this, "DynamoDB table '%s' doesn't exist: %s", name, ex.getLocalizedMessage());
}
return exists;
}
use of com.amazonaws.services.dynamodbv2.document.DynamoDB 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.document.DynamoDB in project jcabi-dynamo by jcabi.
the class MadeTable method create.
/**
* Create table.
* @throws InterruptedException If something fails
*/
public void create() throws InterruptedException {
final AmazonDynamoDB aws = this.region.aws();
final String name = this.request.getTableName();
aws.createTable(this.request);
Logger.info(this, "DynamoDB table '%s' creation requested...", name);
final DescribeTableRequest req = new DescribeTableRequest().withTableName(name);
while (true) {
final DescribeTableResult result = aws.describeTable(req);
if ("ACTIVE".equals(result.getTable().getTableStatus())) {
Logger.info(this, "DynamoDB table '%s' is %s", name, result.getTable().getTableStatus());
break;
}
Logger.info(this, "waiting for DynamoDB table '%s': %s", name, result.getTable().getTableStatus());
TimeUnit.SECONDS.sleep((long) Tv.TEN);
}
}
Aggregations