Java 类com.amazonaws.services.dynamodb.model.TableStatus 实例源码

项目:gora-boot    文件:DynamoDBStore.java   
/**
 * Waits up to 6 minutes to confirm if a table has been created or not
 * @param pTableName
 */
private void waitForTableToBecomeAvailable(String tableName) {
  LOG.debug("Waiting for " + tableName + " to become available");
  long startTime = System.currentTimeMillis();
  long endTime = startTime + waitTime;
  while (System.currentTimeMillis() < endTime) {
    try {Thread.sleep(sleepTime);} catch (Exception e) {}
    try {
      DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
      TableDescription tableDescription = dynamoDBClient.describeTable(request).getTable();
      String tableStatus = tableDescription.getTableStatus();
      LOG.debug(tableName + " - 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 became active");
}
项目:gora-oraclenosql    文件:DynamoDBStore.java   
/**
 * Waits up to 6 minutes to confirm if a table has been created or not
 * @param pTableName
 */
private void waitForTableToBecomeAvailable(String tableName) {
  LOG.debug("Waiting for " + tableName + " to become available");
  long startTime = System.currentTimeMillis();
  long endTime = startTime + waitTime;
  while (System.currentTimeMillis() < endTime) {
    try {Thread.sleep(sleepTime);} catch (Exception e) {}
    try {
      DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
      TableDescription tableDescription = dynamoDBClient.describeTable(request).getTable();
      String tableStatus = tableDescription.getTableStatus();
      LOG.debug(tableName + " - 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 became active");
}