@Override public DescribeTableResult describeTable(String tableName) { return describeTable(new DescribeTableRequest().withTableName(tableName)); }
@PostConstruct public void setup() { try { DescribeTableResult table = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!table.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid key schema"); } if (!ImmutableSet.copyOf(table.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid attribute schema"); } } catch (ResourceNotFoundException e) { createTable(); } }
@PostConstruct public void setup() { try { DescribeTableResult table = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!table.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid key schema"); } if (!ImmutableSet.copyOf(table.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid attribute schema"); } } catch (ResourceNotFoundException e) { createTable(); } }
@PostConstruct public void setup() { try { DescribeTableResult table = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!table.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA)) { throw new IllegalStateException("Dynamodb table for config manager has invalid key schema"); } if (!ImmutableSet.copyOf(table.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Dynamodb table for config manager has invalid attribute schema."); } } catch (ResourceNotFoundException e) { createTable(); } }
DescribeTableRequest describeTableRequest = new DescribeTableRequest(); describeTableRequest.setTableName(tableName); return describeTable(describeTableRequest);
@PostConstruct public void setup() { try { DescribeTableResult result = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!result.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA) || !ImmutableSet.copyOf(result.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Invalid schema for user storage dynamodb table. " + "Please remove existing table or change dynamodb table."); } } catch (ResourceNotFoundException e) { dynamoDBClient.createTable(new CreateTableRequest().withTableName(tableConfig.getTableName()) .withKeySchema(PROJECT_KEYSCHEMA) .withAttributeDefinitions(ATTRIBUTES) .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(3L) .withWriteCapacityUnits(3L))); } }
@Override public DescribeTableResult call() { DescribeTableResult result = dynamoDB.describeTable(describeTablesRequest); log.info("Describe table output: " + result); return result; } }, null, null);
@Override public DescribeTableResult call() { DescribeTableResult result = dynamoDB.describeTable(describeTablesRequest); log.info("Describe table output: " + result); return result; } }, null, null);
AmazonDynamoDBClient client = new AmazonDynamoDBClient(); client.describeTable("tableName").getTable().getProvisionedThroughput();
private void deleteTable(String tableName) { m_logger.info("Deleting table: {}", tableName); try { m_ddbClient.deleteTable(new DeleteTableRequest(tableName)); for (int seconds = 0; seconds < 10; seconds++) { try { m_ddbClient.describeTable(tableName); Thread.sleep(1000); } catch (ResourceNotFoundException e) { break; // Success } // All other exceptions passed to outer try/catch } } catch (ResourceNotFoundException e) { // Already deleted. } catch (Exception e) { throw new RuntimeException("Error deleting table: " + tableName, e); } }
public static void assertNoStaleTables(AmazonDynamoDBClient client, String when) { /* Get the list of tables without the ones in the deleting state */ List<String> tables = client.listTables().getTableNames().stream() .filter(t -> System.currentTimeMillis() - AWSUtils.toEpochMillis(t) > AWSUtils.HOUR || !"DELETING".equals(client.describeTable(t).getTable().getTableStatus())) .collect(Collectors.toList()); Assert.assertEquals(String.format("Found stale DynamoDB tables %s running the test: %s", when, tables), 0, tables.size()); }
@Override public DescribeTableResult describeTable(String tableName) { return describeTable(new DescribeTableRequest().withTableName(tableName)); }
public static void assertNoStaleTables(AmazonDynamoDBClient client, String when) { /* Get the list of tables without the ones in the deleting state */ List<String> tables = client.listTables().getTableNames().stream() .filter(t -> System.currentTimeMillis() - AWSUtils.toEpochMillis(t) > AWSUtils.HOUR || !"DELETING".equals(client.describeTable(t).getTable().getTableStatus())) .collect(Collectors.toList()); Assert.assertEquals(String.format("Found stale DynamoDB tables %s running the test: %s", when, tables), 0, tables.size()); }
private static void waitForTableToBecomeAvailable(String tableName) { System.out.println("Waiting for " + tableName + " to become ACTIVE..."); long startTime = System.currentTimeMillis(); long endTime = startTime + (10 * 60 * 1000); while (System.currentTimeMillis() < endTime) { DescribeTableRequest request = new DescribeTableRequest() .withTableName(tableName); TableDescription tableDescription = client.describeTable( request).getTable(); String tableStatus = tableDescription.getTableStatus(); System.out.println(" - current state: " + tableStatus); if (tableStatus.equals(TableStatus.ACTIVE.toString())) return; try { Thread.sleep(1000 * 20); } catch (Exception e) { } } throw new RuntimeException("Table " + tableName + " never went active"); }
private static void waitForTableToBeDeleted(String tableName) { System.out.println("Waiting for " + tableName + " while status DELETING..."); long startTime = System.currentTimeMillis(); long endTime = startTime + (10 * 60 * 1000); while (System.currentTimeMillis() < endTime) { try { DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName); TableDescription tableDescription = client.describeTable(request).getTable(); String tableStatus = tableDescription.getTableStatus(); System.out.println(" - current state: " + tableStatus); if (tableStatus.equals(TableStatus.ACTIVE.toString())) return; } catch (ResourceNotFoundException e) { System.out.println("Table " + tableName + " is not found. It was deleted."); return; } try {Thread.sleep(1000 * 20);} catch (Exception e) {} } throw new RuntimeException("Table " + tableName + " was never deleted"); }
public static DescribeTableResult describeTable(AmazonDynamoDBClient client, String tableName) { return client.describeTable(new DescribeTableRequest().withTableName(tableName)); }
private static void describeTable() { DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(TABLENAME); TableDescription tableDescription = dynamoDBClient.describeTable(describeTableRequest).getTable(); logger.info("Table Description: " + tableDescription); }
private static void waitForTableToBecomeAvailable(String tableName) { System.out.println("Waiting for " + tableName + " to become ACTIVE..."); long startTime = System.currentTimeMillis(); long endTime = startTime + (10 * 60 * 1000); while (System.currentTimeMillis() < endTime) { DescribeTableRequest request = new DescribeTableRequest() .withTableName(tableName); TableDescription tableDescription = client.describeTable( request).getTable(); String tableStatus = tableDescription.getTableStatus(); System.out.println(" - current state: " + tableStatus); if (tableStatus.equals(TableStatus.ACTIVE.toString())) return; try { Thread.sleep(1000 * 20); } catch (Exception e) { } } throw new RuntimeException("Table " + tableName + " never went active"); }
private static void waitForTableToBecomeAvailable(String tableName) { System.out.println("Waiting for " + tableName + " to become ACTIVE..."); long startTime = System.currentTimeMillis(); long endTime = startTime + (10 * 60 * 1000); while (System.currentTimeMillis() < endTime) { DescribeTableRequest request = new DescribeTableRequest() .withTableName(tableName); TableDescription tableDescription = client.describeTable( request).getTable(); String tableStatus = tableDescription.getTableStatus(); System.out.println(" - current state: " + tableStatus); if (tableStatus.equals(TableStatus.ACTIVE.toString())) return; try { Thread.sleep(1000 * 20); } catch (Exception e) { } } throw new RuntimeException("Table " + tableName + " never went active"); }
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()); }