use of com.amazonaws.services.dynamodbv2.model.TableStatus in project gora by apache.
the class DynamoDBUtils method waitForTableToBecomeAvailable.
/**
* Waits up to 6 minutes to confirm if a table has been created or not
*
* @param awsClient
* @param tableName
*/
public static void waitForTableToBecomeAvailable(AmazonDynamoDB awsClient, String tableName) {
LOG.debug("Waiting for {} to become available", tableName);
long startTime = System.currentTimeMillis();
long endTime = startTime + WAIT_TIME;
while (System.currentTimeMillis() < endTime) {
try {
Thread.sleep(SLEEP_TIME);
} catch (Exception e) {
}
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
TableDescription tableDescription = awsClient.describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
LOG.debug("{} - current state: {}", tableName, tableStatus);
if (tableStatus.equals(TableStatus.ACTIVE.toString()))
return;
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == false)
throw ase;
}
}
throw new RuntimeException("Table " + tableName + " never became active");
}
use of com.amazonaws.services.dynamodbv2.model.TableStatus in project aws-doc-sdk-examples by awsdocs.
the class LowLevelGlobalSecondaryIndexExample method waitForTableToBeDeleted.
private static void waitForTableToBeDeleted(String tableName) {
System.out.println("Waiting for " + tableName + " while status DELETING...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
TableDescription tableDescription = client.describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
System.out.println(" - current state: " + tableStatus);
if (tableStatus.equals(TableStatus.ACTIVE.toString()))
return;
} catch (ResourceNotFoundException e) {
System.out.println("Table " + tableName + " is not found. It was deleted.");
return;
}
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
e.printStackTrace();
}
}
throw new RuntimeException("Table " + tableName + " was never deleted");
}
use of com.amazonaws.services.dynamodbv2.model.TableStatus in project aws-doc-sdk-examples by awsdocs.
the class LowLevelParallelScan method waitForTableToBeDeleted.
private static void waitForTableToBeDeleted(String tableName) {
System.out.println("Waiting for " + tableName + " while status DELETING...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
TableDescription tableDescription = client.describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
System.out.println(" - current state: " + tableStatus);
if (tableStatus.equals(TableStatus.ACTIVE.toString()))
return;
} catch (ResourceNotFoundException e) {
System.out.println("Table " + tableName + " is not found. It was deleted.");
return;
}
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
}
}
throw new RuntimeException("Table " + tableName + " was never deleted");
}
use of com.amazonaws.services.dynamodbv2.model.TableStatus in project aws-doc-sdk-examples by awsdocs.
the class DynamoDBDynamicFaultInjection method waitForTableToBecomeAvailable.
/*
* Waits for the table to become ACTIVE Times out after 10 minutes
*/
private static void waitForTableToBecomeAvailable(String tableName) {
logger.info("Waiting for " + tableName + " to become ACTIVE...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
}
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
TableDescription tableDescription = dynamoDBClient.describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
logger.info(" - current state: " + tableStatus);
if (tableStatus.equals(TableStatus.ACTIVE.toString()))
return;
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == false)
throw ase;
}
}
throw new RuntimeException("Table " + tableName + " never went active");
}
use of com.amazonaws.services.dynamodbv2.model.TableStatus in project aws-doc-sdk-examples by awsdocs.
the class LowLevelTableExample method waitForTableToBeDeleted.
private static void waitForTableToBeDeleted(String tableName) {
System.out.println("Waiting for " + tableName + " while status DELETING...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
TableDescription tableDescription = client.describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
System.out.println(" - current state: " + tableStatus);
if (tableStatus.equals(TableStatus.ACTIVE.toString()))
return;
} catch (ResourceNotFoundException e) {
System.out.println("Table " + tableName + " is not found. It was deleted.");
return;
}
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
}
}
throw new RuntimeException("Table " + tableName + " was never deleted");
}
Aggregations