List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDB describeTable
DescribeTableResult describeTable(String tableName);
From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.DbTableDetail.java
License:Open Source License
@Override public String retrieveDetails(ResourceDetailRequest detailRequest) { String response = null;//w w w . j a v a2 s. c om try { AmazonDynamoDB client = new AmazonDynamoDBClient(credentials); client.setRegion(Region.getRegion(Regions.fromName(detailRequest.getRegion()))); DescribeTableRequest request = new DescribeTableRequest(); request.setTableName(detailRequest.getResourceName()); DescribeTableResult result = client.describeTable(request); buildUI(result); } catch (IllegalArgumentException | AmazonClientException e) { response = e.getMessage(); LOGGER.log(Level.WARNING, "Problem retrieving DynamoDb details from AWS", e); } return response; }
From source file:com.netflix.config.sources.DynamoDbIntegrationTestHelper.java
License:Apache License
static void createTable(AmazonDynamoDB dbClient, String tableName) throws InterruptedException { //TODO check to make sure the table isn't being created or deleted. KeySchemaElement hashKey = new KeySchemaElement() .withAttributeName(DynamoDbConfigurationSource.defaultKeyAttribute).withKeyType(KeyType.HASH); ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput().withReadCapacityUnits(1L) .withWriteCapacityUnits(1L); dbClient.createTable(new CreateTableRequest().withTableName(tableName).withKeySchema(hashKey) .withProvisionedThroughput(provisionedThroughput)); while (!dbClient.describeTable(new DescribeTableRequest().withTableName(tableName)).getTable() .getTableStatus().equalsIgnoreCase("active")) { Thread.sleep(10000);// w w w. j a v a2s . c o m } }
From source file:io.venable.amazonaws.dynamo.table.TableHelper.java
License:Apache License
private static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) { try {//w ww. j a va 2 s. c o m TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable(); return TableStatus.ACTIVE.toString().equals(table.getTableStatus()); } catch (ResourceNotFoundException ex) { return false; } }
From source file:io.venable.amazonaws.dynamo.test.TableTestUtils.java
License:Apache License
public static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) { try {/*from w w w . j a v a 2 s. c o m*/ TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable(); return TableStatus.ACTIVE.toString().equals(table.getTableStatus()); } catch (ResourceNotFoundException ex) { return false; } }
From source file:kinesisadaptersample.StreamsAdapterDemoHelper.java
License:Open Source License
public static DescribeTableResult describeTable(AmazonDynamoDB client, String tableName) { return client.describeTable(new DescribeTableRequest().withTableName(tableName)); }
From source file:org.apache.gora.dynamodb.store.DynamoDBUtils.java
License:Apache License
/** * Waits up to 6 minutes to confirm if a table has been created or not * // w w w.j a v a2 s. co m * @param awsClient * @param tableName */ public static void waitForTableToBecomeAvailable(AmazonDynamoDB awsClient, String tableName) { LOG.debug("Waiting for {} to become available", tableName); long startTime = System.currentTimeMillis(); long endTime = startTime + WAIT_TIME; while (System.currentTimeMillis() < endTime) { try { Thread.sleep(SLEEP_TIME); } catch (Exception e) { } try { DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName); TableDescription tableDescription = awsClient.describeTable(request).getTable(); String tableStatus = tableDescription.getTableStatus(); LOG.debug("{} - current state: {}", tableName, 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"); }
From source file:org.apache.metamodel.dynamodb.DynamoDbTableCreationBuilder.java
License:Apache License
@Override public Table execute() throws MetaModelException { final MutableTable table = getTable(); final String tableName = table.getName(); final Collection<AttributeDefinition> attributes = new ArrayList<>(); final Collection<KeySchemaElement> keySchema = new ArrayList<>(); final Collection<GlobalSecondaryIndex> globalSecondaryIndices = new ArrayList<>(); final long readCapacity = Long .parseLong(System.getProperty(DynamoDbDataContext.SYSTEM_PROPERTY_THROUGHPUT_READ_CAPACITY, "5")); final long writeCapacity = Long .parseLong(System.getProperty(DynamoDbDataContext.SYSTEM_PROPERTY_THROUGHPUT_WRITE_CAPACITY, "5")); final ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput(readCapacity, writeCapacity); for (Column column : table.getColumns()) { if (column.isPrimaryKey()) { final KeyType keyType = getKeyType(column.getRemarks()); keySchema.add(new KeySchemaElement(column.getName(), keyType)); attributes.add(/*from w ww. j av a 2 s . com*/ new AttributeDefinition(column.getName(), DynamoDbUtils.toAttributeType(column.getType()))); } } final CreateTableRequest createTableRequest = new CreateTableRequest(); createTableRequest.setTableName(tableName); createTableRequest.setAttributeDefinitions(attributes); createTableRequest.setGlobalSecondaryIndexes(globalSecondaryIndices); createTableRequest.setKeySchema(keySchema); createTableRequest.setProvisionedThroughput(provisionedThroughput); final AmazonDynamoDB client = getUpdateCallback().getDataContext().getDynamoDb(); final CreateTableResult createTableResult = client.createTable(createTableRequest); // await the table creation to be "done". { String tableStatus = createTableResult.getTableDescription().getTableStatus(); while (TableStatus.CREATING.name().equals(tableStatus)) { logger.debug("Waiting for table status to be ACTIVE. Currently: {}", tableStatus); try { Thread.sleep(300); } catch (InterruptedException e) { getUpdateCallback().setInterrupted(true); } tableStatus = client.describeTable(tableName).getTable().getTableStatus(); } } return table; }