/** * 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; }
try { retry: for (;;) { TableDescription desc = describe(); String status = desc.getTableStatus(); if (TableStatus.fromValue(status) == TableStatus.ACTIVE) {
/** * A convenient blocking call that can be used, typically during table * creation, to wait for the table to become active. This method uses * {@link com.amazonaws.services.dynamodbv2.waiters.AmazonDynamoDBWaiters} * to poll the status of the table every 5 seconds. * * @return the table description when the table has become active * * @throws IllegalArgumentException if the table is being deleted * @throws ResourceNotFoundException if the table doesn't exist */ public TableDescription waitForActive() throws InterruptedException { Waiter waiter = client.waiters().tableExists(); try { waiter.run(new WaiterParameters<DescribeTableRequest>(new DescribeTableRequest(tableName)) .withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(25), new FixedDelayStrategy(5)))); return describe(); } catch (Exception exception) { // The additional describe call is to return ResourceNotFoundException if the table doesn't exist. // This is to preserve backwards compatibility. describe(); throw new IllegalArgumentException("Table " + tableName + " did not transition into ACTIVE state.", exception); } }
@Retries.OnceRaw private TableDescription getTableDescription(boolean forceUpdate) { TableDescription desc = table.getDescription(); if (desc == null || forceUpdate) { desc = table.describe(); } return desc; }
AmazonDynamoDB dynamoClient = new AmazonDynamoDBClient(); DynamoDB dynamoDB = new DynamoDB(dynamoClient); Table table = dynamoDB.getTable("MyTable"); Long readCapacityUnits = table.describe() .getProvisionedThroughput().getReadCapacityUnits();
@Override public int size() { // Infinispan code analysis on 8.2 shows that this method is never called in practice, and // is not wired to the data / cache container API // TODO inaccurate when a range key is applied! Loggers.DYNAMODB_LOG.trace("[DS0120] DynamoDB store: Counting {} records", getCacheName()); final int count; try { count = table.describe().getItemCount().intValue(); } catch (Exception e) { Loggers.DYNAMODB_LOG.error("[DS0121] {}: {}", e.getMessage(), e); throw new PersistenceException(e.getMessage(), e); } Loggers.DYNAMODB_LOG.trace("[DS0122] DynamoDB store: Reported approximately {} {} items", count, getCacheName()); return count; }
/** * 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; }
static void getTableInformation() { System.out.println("Describing " + tableName); TableDescription tableDescription = dynamoDB.getTable(tableName).describe(); System.out.format("Name: %s:\n" + "Status: %s \n" + "Provisioned Throughput (read capacity units/sec): %d \n" + "Provisioned Throughput (write capacity units/sec): %d \n", tableDescription.getTableName(), tableDescription.getTableStatus(), tableDescription.getProvisionedThroughput().getReadCapacityUnits(), tableDescription.getProvisionedThroughput().getWriteCapacityUnits()); }
try { retry: for (;;) { TableDescription desc = describe(); String status = desc.getTableStatus(); if (TableStatus.fromValue(status) == TableStatus.ACTIVE) {
try { LOG.debug("Binding to table {}", tableName); TableDescription description = table.describe(); LOG.debug("Table state: {}", description); final String status = description.getTableStatus();
/** * A convenient blocking call that can be used, typically during table * creation, to wait for the table to become active. This method uses * {@link com.amazonaws.services.dynamodbv2.waiters.AmazonDynamoDBWaiters} * to poll the status of the table every 5 seconds. * * @return the table description when the table has become active * * @throws IllegalArgumentException if the table is being deleted * @throws ResourceNotFoundException if the table doesn't exist */ public TableDescription waitForActive() throws InterruptedException { Waiter waiter = client.waiters().tableExists(); try { waiter.run(new WaiterParameters<DescribeTableRequest>(new DescribeTableRequest(tableName)) .withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(25), new FixedDelayStrategy(5)))); return describe(); } catch (Exception exception) { // The additional describe call is to return ResourceNotFoundException if the table doesn't exist. // This is to preserve backwards compatibility. describe(); throw new IllegalArgumentException("Table " + tableName + " did not transition into ACTIVE state.", exception); } }
private boolean validateOrCreateTable(Integer readUnits, Integer writeUnits) { try { Table table = dynamoDB.getTable(tableName); TableDescription tableDescription = table.describe(); TableDescription tableDescription = table.describe(); LOG.info( String.format("Created table '%s'(%s) with throughput %d read, %d write units/sec",
try { try { this.table.describe(); updateTimeToLiveIfAny(); this.createTableLatch.countDown();
try { try { this.table.describe(); updateTimeToLiveIfAny(); this.createTableLatch.countDown();
public DynamoTable(Table table) { table.describe(); tableName = table.getTableName(); attributeDefinitions = table.getDescription().getAttributeDefinitions().toString(); tableStatus = table.getDescription().getTableStatus(); keySchema = table.getDescription().getKeySchema().toString(); creationDateTime = new DateTime(table.getDescription().getCreationDateTime()); numberOfDecreasesToday = table.getDescription().getProvisionedThroughput().getNumberOfDecreasesToday(); readCapacityUnits = table.getDescription().getProvisionedThroughput().getReadCapacityUnits(); writeCapacityUnits = table.getDescription().getProvisionedThroughput().getWriteCapacityUnits(); tableSizeBytes = table.getDescription().getTableSizeBytes(); itemCount = table.getDescription().getItemCount(); tableArn = table.getDescription().getTableArn(); provisionedThroughput = table.getDescription().getProvisionedThroughput().toString(); globalSecondaryIndexes = new ArrayList<>(); if (table.getDescription().getGlobalSecondaryIndexes() != null) { for (GlobalSecondaryIndexDescription gsiDesc : table .getDescription() .getGlobalSecondaryIndexes()) { globalSecondaryIndexes.add(new DynamoGSI(gsiDesc)); } } }