use of com.amazonaws.services.dynamodbv2.model.TableStatus in project aws-doc-sdk-examples by awsdocs.
the class LowLevelParallelScan method waitForTableToBecomeAvailable.
private static void waitForTableToBecomeAvailable(String tableName) {
System.out.println("Waiting for " + tableName + " to become ACTIVE...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
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;
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
}
}
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 LowLevelGlobalSecondaryIndexExample method waitForTableToBecomeAvailable.
private static void waitForTableToBecomeAvailable(String tableName) {
System.out.println("Waiting for " + tableName + " to become ACTIVE...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
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;
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
e.printStackTrace();
}
}
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 LowLevelLocalSecondaryIndexExample 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 LowLevelLocalSecondaryIndexExample method waitForTableToBecomeAvailable.
private static void waitForTableToBecomeAvailable(String tableName) {
System.out.println("Waiting for " + tableName + " to become ACTIVE...");
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
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;
try {
Thread.sleep(1000 * 20);
} catch (Exception e) {
}
}
throw new RuntimeException("Table " + tableName + " never went active");
}
use of com.amazonaws.services.dynamodbv2.model.TableStatus in project gora by apache.
the class DynamoDBStore method waitForTableToBeDeleted.
/**
* Waits up to 6 minutes to confirm if a table has been deleted or not
*
* @param pTableName
*/
private void waitForTableToBeDeleted(String pTableName) {
LOG.debug("Waiting for " + pTableName + " to be deleted.");
long startTime = System.currentTimeMillis();
long endTime = startTime + WAIT_TIME;
while (System.currentTimeMillis() < endTime) {
try {
Thread.sleep(SLEEP_DELETE_TIME);
} catch (Exception e) {
}
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(pTableName);
TableDescription tableDescription = getDynamoDBClient().describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
LOG.debug(pTableName + " - current state: " + tableStatus);
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == true)
return;
LOG.error(ase.getMessage());
}
}
LOG.debug(pTableName + " deleted.");
}
Aggregations