Refine search
while (System.currentTimeMillis() < endTime) { try { table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable(); if (desiredStatus == null || table.getTableStatus().equals(desiredStatus.toString())) { return table;
/** * Simplified method form for invoking the DescribeTable operation. * * @see #describeTableAsync(DescribeTableRequest) */ @Override public java.util.concurrent.Future<DescribeTableResult> describeTableAsync(String tableName) { return describeTableAsync(new DescribeTableRequest().withTableName(tableName)); }
/** * Constructs a new DescribeTableRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table to describe. */ public DescribeTableRequest(String tableName) { setTableName(tableName); }
.appendDynamoDBDocumentUserAgentString(new DescribeTableRequest(this.tableName)); .describeTable(request); this.tableDescription = result.getTable(); for (final KeySchemaElement element : this.tableDescription.getKeySchema()) { final String keyName = element.getAttributeName(); for (final AttributeDefinition ad : this.tableDescription.getAttributeDefinitions()) { if (ad.getAttributeName().equals(keyName)) { final KeyDescription kd = new KeyDescription(); if (this.tableDescription.getLocalSecondaryIndexes() != null) { for (final LocalSecondaryIndexDescription index : this.tableDescription .getLocalSecondaryIndexes()) {
List<LocalSecondaryIndex> localIndexes) { DescribeTableResult describe = client.describeTable(new DescribeTableRequest().withTableName(tableName)); if(! new HashSet<AttributeDefinition>(definitions).equals(new HashSet<AttributeDefinition>(describe.getTable().getAttributeDefinitions()))) { throw new ResourceInUseException("Table " + tableName + " had the wrong AttributesToGet." + " Expected: " + definitions + " " + " Was: " + describe.getTable().getAttributeDefinitions()); if(! keySchema.equals(describe.getTable().getKeySchema())) { throw new ResourceInUseException("Table " + tableName + " had the wrong KeySchema." + " Expected: " + keySchema + " "
private TableDescription describeTable(final String tableName) throws BackendException { return describeTable(new DescribeTableRequest().withTableName(tableName)).getTable(); }
static void getTableInformation() { TableDescription tableDescription = client.describeTable( new DescribeTableRequest().withTableName(tableName)).getTable(); 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()); }
/** * Retrieves the table description from DynamoDB. Involves network calls. * Meant to be called as infrequently as possible to avoid throttling * exception from the server side. * * @return a non-null table description * * @throws ResourceNotFoundException if the table doesn't exist */ public TableDescription describe() { DescribeTableResult result = client.describeTable( InternalUtils.applyUserAgent(new DescribeTableRequest(tableName))); return tableDescription = result.getTable(); }
@Test public void get_whenTableDoesNotExist_createsTable() { CreateDynamoDBTable createDynamoDBTable = new CreateDynamoDBTable(dynamoDB, "asdf", "asdf", 1, 1); //setup when(dynamoDB.describeTable("asdf")).thenThrow(new ResourceNotFoundException("asdf")); when(dynamoDB.createTable(any(CreateTableRequest.class))) .thenReturn(new CreateTableResult().withTableDescription(new TableDescription())); when(dynamoDB.describeTable(new DescribeTableRequest().withTableName("asdf"))) .thenReturn(new DescribeTableResult().withTable(new TableDescription().withTableStatus(TableStatus.ACTIVE))); //test createDynamoDBTable.get(); //verify verify(dynamoDB).describeTable("asdf"); verify(dynamoDB).createTable(any(CreateTableRequest.class)); } }
DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(tableName); TableDescription tableDescription = dynamoDB.describeTable(describeTableRequest).getTable(); System.out.println("Table Description: " + tableDescription);
/** * A convenient blocking call that can be used, typically during table * deletion, to wait for the table to become deleted. This method uses * {@link com.amazonaws.services.dynamodbv2.waiters.AmazonDynamoDBWaiters} * to poll the status of the table every 5 seconds. */ public void waitForDelete() throws InterruptedException { Waiter waiter = client.waiters().tableNotExists(); try { waiter.run(new WaiterParameters<DescribeTableRequest>(new DescribeTableRequest(tableName)) .withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(25), new FixedDelayStrategy(5)))); } catch (Exception exception) { throw new IllegalArgumentException("Table " + tableName + " is not deleted.", exception); } }
DescribeTableRequest describeTableRequest = new DescribeTableRequest(); describeTableRequest.setTableName(tableName); return describeTable(describeTableRequest);
private DescribeTableResult describeTable(final DescribeTableRequest request) throws BackendException { controlPlaneRateLimiter.acquire(); final Timer.Context apiTimerContext = getTimerContext(DESCRIBE_TABLE, request.getTableName()); DescribeTableResult result; try { result = client.describeTable(request); } catch (final Exception e) { throw processDynamoDbApiException(e, DESCRIBE_TABLE, request.getTableName()); } finally { apiTimerContext.stop(); } return result; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); return hashCode; }
private static void describeTable() { DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(TABLENAME); TableDescription tableDescription = dynamoDBClient.describeTable(describeTableRequest).getTable(); logger.info("Table Description: " + tableDescription); }
/** * Retrieves the table description from DynamoDB. Involves network calls. * Meant to be called as infrequently as possible to avoid throttling * exception from the server side. * * @return a non-null table description * * @throws ResourceNotFoundException if the table doesn't exist */ public TableDescription describe() { DescribeTableResult result = client.describeTable( InternalUtils.applyUserAgent(new DescribeTableRequest(tableName))); return tableDescription = result.getTable(); }
@Override public void onSuccess(CreateTableRequest request, CreateTableResult createTableResult) { Waiter<DescribeTableRequest> waiter = DynamoDbMetadataStore.this.dynamoDB.waiters() .tableExists(); WaiterParameters<DescribeTableRequest> waiterParameters = new WaiterParameters<>( new DescribeTableRequest(DynamoDbMetadataStore.this.table.getTableName())) .withPollingStrategy( new PollingStrategy( new MaxAttemptsRetryStrategy(DynamoDbMetadataStore.this.createTableRetries), new FixedDelayStrategy(DynamoDbMetadataStore.this.createTableDelay))); waiter.runAsync(waiterParameters, new WaiterHandler<DescribeTableRequest>() { @Override public void onWaitSuccess(DescribeTableRequest request) { updateTimeToLiveIfAny(); DynamoDbMetadataStore.this.createTableLatch.countDown(); DynamoDbMetadataStore.this.table.describe(); } @Override public void onWaitFailure(Exception e) { logger.error("Cannot describe DynamoDb table: " + DynamoDbMetadataStore.this.table.getTableName(), e); DynamoDbMetadataStore.this.createTableLatch.countDown(); } }); }
/** * 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); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeTableRequest == false) return false; DescribeTableRequest other = (DescribeTableRequest) obj; if (other.getTableName() == null ^ this.getTableName() == null) return false; if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; return true; }
/** * Checks if a specified table exists and is in <code>ACTIVE</code> state. * * @param dynamo The AWS DynamoDB client to use to make requests. * @param tableName The name of the table being searched for. * @return True if a table already exists with the specified name, otherwise * false. */ public static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) { try { TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)) .getTable(); return TableStatus.ACTIVE.toString().equals(table.getTableStatus()); } catch (ResourceNotFoundException rnfe) { // This means the table doesn't exist in the account yet return false; } }