/** * A convenient blocking call that can be used to wait on a table until it * has either become active or deleted (ie no longer exists) by polling the * table every 5 seconds. * * @return the table description if the table has become active; or null * if the table has been deleted. * * @deprecated If this method is called immediately after * {@link AmazonDynamoDB#createTable(CreateTableRequest)} or * {@link AmazonDynamoDB#deleteTable(DeleteTableRequest)} operation, * the result might be incorrect as all {@link com.amazonaws.services.dynamodbv2.AmazonDynamoDB} * operations are eventually consistent and might have a few seconds delay before the status is changed. */ @Deprecated public TableDescription waitForActiveOrDelete() throws InterruptedException { try { for (;;) { TableDescription desc = describe(); final String status = desc.getTableStatus(); if (TableStatus.fromValue(status) == TableStatus.ACTIVE) return desc; else Thread.sleep(SLEEP_TIME_MILLIS); } } catch(ResourceNotFoundException deleted) { } return null; }
TableDescription desc = describe(); String status = desc.getTableStatus(); if (TableStatus.fromValue(status) == TableStatus.ACTIVE) { List<GlobalSecondaryIndexDescription> descriptions = desc.getGlobalSecondaryIndexes();
/** * A convenient blocking call that can be used to wait on a table until it * has either become active or deleted (ie no longer exists) by polling the * table every 5 seconds. * * @return the table description if the table has become active; or null * if the table has been deleted. * * @deprecated If this method is called immediately after * {@link AmazonDynamoDB#createTable(CreateTableRequest)} or * {@link AmazonDynamoDB#deleteTable(DeleteTableRequest)} operation, * the result might be incorrect as all {@link com.amazonaws.services.dynamodbv2.AmazonDynamoDB} * operations are eventually consistent and might have a few seconds delay before the status is changed. */ @Deprecated public TableDescription waitForActiveOrDelete() throws InterruptedException { try { for (;;) { TableDescription desc = describe(); final String status = desc.getTableStatus(); if (TableStatus.fromValue(status) == TableStatus.ACTIVE) return desc; else Thread.sleep(SLEEP_TIME_MILLIS); } } catch(ResourceNotFoundException deleted) { } return null; }
private TableStatus tableStatus(String tableName) { DescribeTableRequest request = new DescribeTableRequest(); request.setTableName(tableName); try { DescribeTableResult result = amazonDynamoDB.describeTable(request); TableStatus tableStatus = TableStatus.fromValue(result.getTable().getTableStatus()); logger.debug("table status {} ", tableStatus); return tableStatus; } catch (ResourceNotFoundException e) { logger.debug("ResourceNotFound is TableName {}", tableName); return null; } catch (AmazonClientException e) { logger.error("Unknown error ", e); throw new IllegalStateException("Unknown Exception", e); } }
private TableStatus tableStatus() throws DependencyException { DescribeTableRequest request = new DescribeTableRequest(); request.setTableName(table); DescribeTableResult result; try { result = dynamoDBClient.describeTable(request); } catch (ResourceNotFoundException e) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Got ResourceNotFoundException for table %s in leaseTableExists, returning false.", table)); } return null; } catch (AmazonClientException e) { throw new DependencyException(e); } TableStatus tableStatus = TableStatus.fromValue(result.getTable().getTableStatus()); if (LOG.isDebugEnabled()) { LOG.debug("Lease table exists and is in status " + tableStatus); } return tableStatus; }
TableDescription desc = describe(); String status = desc.getTableStatus(); if (TableStatus.fromValue(status) == TableStatus.ACTIVE) { List<GlobalSecondaryIndexDescription> descriptions = desc.getGlobalSecondaryIndexes();