/** * * @{inheritDoc */ @Override public boolean hasTable(String tableName) { String nextTableName = null; do { ListTablesResult listTables = dynamoDb.listTables(new ListTablesRequest() .withExclusiveStartTableName(nextTableName)); for (String name : listTables.getTableNames()) { if (tableName.equalsIgnoreCase(name)) { return true; } } nextTableName = listTables.getLastEvaluatedTableName(); } while (nextTableName != null); return false; }
/** * * @{inheritDoc */ @Override public Set<String> getTables(String regex) { Set<String> result = new HashSet<String>(); String nextTableName = null; do { ListTablesResult listTables = dynamoDb.listTables(new ListTablesRequest() .withExclusiveStartTableName(nextTableName)); for (String s : listTables.getTableNames()) { if (s.matches(regex)) { result.add(s); } } nextTableName = listTables.getLastEvaluatedTableName(); } while (nextTableName != null); return result; }
@Test public void test_updateTable() throws Exception { createTable(); DescribeTableResult describeResult = dynamoDb.describeTable(TEST_TABLE_NAME); Long readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits(); assertThat(readUnits, equalTo(UNITS)); UpdateTableResult updateResult = dynamoDb.updateTable(TEST_TABLE_NAME, new ProvisionedThroughput() .withReadCapacityUnits(new Long(200)) .withWriteCapacityUnits(new Long(200))); String tableName = updateResult.getTableDescription().getTableName(); assertThat(tableName, equalTo(TEST_TABLE_NAME)); ListTablesResult listResult = listTables(); describeResult = dynamoDb.describeTable(TEST_TABLE_NAME); readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits(); assertThat(readUnits, equalTo(new Long(200))); }
/** * Lists all table names for this account. * @return a list of DynamoDB tables */ public static List<String> listAllTables() { int items = 100; ListTablesResult ltr = getClient().listTables(items); List<String> tables = new LinkedList<>(); String lastKey; do { tables.addAll(ltr.getTableNames()); lastKey = ltr.getLastEvaluatedTableName(); logger.info("Found {} tables. Total found: {}.", ltr.getTableNames().size(), tables.size()); if (lastKey == null) { break; } ltr = getClient().listTables(lastKey, items); } while (!ltr.getTableNames().isEmpty()); return tables; }
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); }
@Test public void createTableTest() { AmazonDynamoDB ddb = DynamoDBEmbedded.create().amazonDynamoDB(); try { String tableName = "Movies"; String hashKeyName = "film_id"; CreateTableResult res = createTable(ddb, tableName, hashKeyName); TableDescription tableDesc = res.getTableDescription(); assertEquals(tableName, tableDesc.getTableName()); assertEquals("[{AttributeName: " + hashKeyName + ",KeyType: HASH}]", tableDesc.getKeySchema().toString()); assertEquals("[{AttributeName: " + hashKeyName + ",AttributeType: S}]", tableDesc.getAttributeDefinitions().toString()); assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getReadCapacityUnits()); assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getWriteCapacityUnits()); assertEquals("ACTIVE", tableDesc.getTableStatus()); assertEquals("arn:aws:dynamodb:ddblocal:000000000000:table/Movies", tableDesc.getTableArn()); ListTablesResult tables = ddb.listTables(); assertEquals(1, tables.getTableNames().size()); } finally { ddb.shutdown(); } }
@Test(groups = TestGroups.EXPERIMENTAL) public void testListTables() { ListTablesResult listTables = dynamoDb.listTables(); for (String s : listTables.getTableNames()) { System.out.println(s); } }
@Override public ListTablesResult next() throws BackendException { final ListTablesResult result = delegate.listTables(request); if (result.getLastEvaluatedTableName() != null && !result.getLastEvaluatedTableName().isEmpty()) { request.setExclusiveStartTableName(result.getLastEvaluatedTableName()); } else { //done markComplete(); } // c add scanned items tableNames.addAll(result.getTableNames()); return result; }
ListTablesResult listTables(final ListTablesRequest request) throws BackendException { controlPlaneRateLimiter.acquire(); final Timer.Context apiTimerContext = getTimerContext(listTablesApiName, null /*tableName*/); ListTablesResult result; try { result = client.listTables(request); } catch (final Exception e) { throw processDynamoDbApiException(e, LIST_TABLES, null /*tableName*/); } finally { apiTimerContext.stop(); } return result; }
@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)); }
@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)); }
@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)); }
@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)); }
@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); } } }
static void listMyTables() { TableCollection<ListTablesResult> tables = dynamoDB.listTables(); Iterator<Table> iterator = tables.iterator(); System.out.println("Listing table names"); while (iterator.hasNext()) { Table table = iterator.next(); System.out.println(table.getTableName()); } }
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!"); }
@Override protected ListTablesResult getMergedPages() { return new ListTablesResult().withTableNames(tableNames); }
public ListTablesResult listAllTables() throws BackendException { final ListTablesWorker worker = new ListTablesWorker(this); worker.call(); return worker.getMergedPages(); }
private ListTablesResult listTables() throws Exception { ListTablesResult result = dynamoDb.listTables(); return result; }
public static ListTablesResult listTables() { return DynamoDbHandler.CLIENT.listTables(); }
@Override public List<String> getTableNames() { ListTablesResult result = DynamoDbQueryHandler.listTables(); return result.getTableNames(); }
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); } }
@Test public void test_deleteTable() throws Exception { createTable(); DeleteTableResult deleteResult = dynamoDb.deleteTable(TEST_TABLE_NAME); String tableName = deleteResult.getTableDescription().getTableName(); assertThat(tableName, equalTo(TEST_TABLE_NAME)); ListTablesResult listResult = listTables(); assertThat(listResult.getTableNames().size(), equalTo(0)); }