Java Code Examples for com.amazonaws.services.dynamodbv2.model.ListTablesResult#getTableNames()

The following examples show how to use com.amazonaws.services.dynamodbv2.model.ListTablesResult#getTableNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LowLevelTableExample.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
static void listMyTables() {
    String lastEvaluatedTableName = null;
    do {

        ListTablesRequest listTablesRequest = new ListTablesRequest().withLimit(10)
            .withExclusiveStartTableName(lastEvaluatedTableName);

        ListTablesResult result = client.listTables(listTablesRequest);
        lastEvaluatedTableName = result.getLastEvaluatedTableName();

        for (String name : result.getTableNames()) {
            System.out.println(name);
        }

    } while (lastEvaluatedTableName != null);
}
 
Example 2
Source File: LowLevelTableExample.java    From aws-dynamodb-examples with Apache License 2.0 6 votes vote down vote up
static void listMyTables() {
    String lastEvaluatedTableName = null;
    do {
        
        ListTablesRequest listTablesRequest = new ListTablesRequest()
        .withLimit(10)
        .withExclusiveStartTableName(lastEvaluatedTableName);
        
        ListTablesResult result = client.listTables(listTablesRequest);
        lastEvaluatedTableName = result.getLastEvaluatedTableName();
        
        for (String name : result.getTableNames()) {
            System.out.println(name);
        }
        
    } while (lastEvaluatedTableName != null);
}
 
Example 3
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithNpParameters() throws Exception {
  createTable();

  ListTablesResult result = listTables();
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example 4
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithExclusiveStartTableName() throws Exception {
  createTable();

  ListTablesResult result = dynamoDb.listTables(TEST_TABLE_NAME);
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example 5
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithLimit() throws Exception {
  createTable();

  ListTablesResult result = dynamoDb.listTables(new Integer(10));
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example 6
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithAllParameters() throws Exception {
  createTable();

  ListTablesResult result = dynamoDb.listTables(TEST_TABLE_NAME, new Integer(10));
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example 7
Source File: DynamoDBService.java    From Doradus with Apache License 2.0 5 votes vote down vote up
@Override
public void dropNamespace() {
    if (m_tenantPrefix.length() == 0) {
        m_logger.warn("Drop namespace not supported for legacy DynamoDB instances. "+
                      "Tables for tenant {} must be deleted manually", m_tenant.getName());
        return;
    }
    ListTablesResult tables = m_ddbClient.listTables();
    List<String> tableNames = tables.getTableNames();
    for (String tableName : tableNames) {
        if (tableName.startsWith(m_tenantPrefix)) {
            deleteTable(tableName);
        }
    }
}
 
Example 8
Source File: DynamoDBOperations.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteAll() throws Exception {
  final ListTablesResult tables = client.listTables();
  for (final String tableName : tables.getTableNames()) {
    if ((gwNamespace == null) || tableName.startsWith(gwNamespace)) {
      client.deleteTable(new DeleteTableRequest(tableName));
    }
  }
  tableExistsCache.clear();
}
 
Example 9
Source File: ListTables.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args)
{
    System.out.println("Your DynamoDB tables:\n");

    final AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();

    ListTablesRequest request;

    boolean more_tables = true;
    String last_name = null;

    while(more_tables) {
        try {
            if (last_name == null) {
            	request = new ListTablesRequest().withLimit(10);
            }
            else {
            	request = new ListTablesRequest()
            			.withLimit(10)
            			.withExclusiveStartTableName(last_name);
            }

            ListTablesResult table_list = ddb.listTables(request);
            List<String> table_names = table_list.getTableNames();

            if (table_names.size() > 0) {
                for (String cur_name : table_names) {
                    System.out.format("* %s\n", cur_name);
                }
            } else {
                System.out.println("No tables found!");
                System.exit(0);
            }

            last_name = table_list.getLastEvaluatedTableName();
            if (last_name == null) {
                more_tables = false;
            }

        } catch (AmazonServiceException e) {
            System.err.println(e.getErrorMessage());
            System.exit(1);
        }
    }
    System.out.println("\nDone!");
}
 
Example 10
Source File: DynamoDBLocalFixture.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
public static void listTables(ListTablesResult result, String method) {
    System.out.println("found " + Integer.toString(result.getTableNames().size()) + " tables with " + method);
    for (String table : result.getTableNames()) {
        System.out.println(table);
    }
}
 
Example 11
Source File: DynamoDBLocalFixture.java    From aws-dynamodb-examples with Apache License 2.0 4 votes vote down vote up
public static void listTables(ListTablesResult result, String method) {
    System.out.println("found " + Integer.toString(result.getTableNames().size()) + " tables with " + method);
    for(String table : result.getTableNames()) {
        System.out.println(table);
    }
}