List of usage examples for com.amazonaws.services.dynamodbv2.model ListTablesResult getLastEvaluatedTableName
public String getLastEvaluatedTableName()
The name of the last table in the current page of results.
From source file:aws.example.dynamodb.ListTables.java
License:Open Source License
public static void main(String[] args) { System.out.println("Your DynamoDB tables:\n"); final AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(); boolean more_tables = true; while (more_tables) { String last_name = null;// w w w. j a v a 2 s . c o m try { ListTablesResult table_list = null; if (last_name == null) { table_list = ddb.listTables(); } else { table_list = ddb.listTables(last_name); } 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!"); }
From source file:com.amazon.janusgraph.diskstorage.dynamodb.ListTablesWorker.java
License:Open Source License
@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();//from w w w. j a v a 2 s . c o m } // c add scanned items tableNames.addAll(result.getTableNames()); return result; }
From source file:com.erudika.para.persistence.AWSDynamoUtils.java
License:Apache License
/** * Lists all table names for this account. * @return a list of DynamoDB tables/* w ww . j a va 2s . c om*/ */ public static List<String> listAllTables() { int items = 100; ListTablesResult ltr = getClient().listTables(items); List<String> tables = new LinkedList<String>(); 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; }
From source file:com.intuit.tank.persistence.databases.AmazonDynamoDatabaseDocApi.java
License:Open Source License
/** * //ww w. ja v a 2s.c o m * @{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; }
From source file:com.intuit.tank.persistence.databases.AmazonDynamoDatabaseDocApi.java
License:Open Source License
/** * /*from w ww .j av a 2 s. c om*/ * @{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; }
From source file:com.makariev.dynamodb.data.tables.ModifyTablesService.java
License:Apache License
public List<TableDescription> showTables() { final List<TableDescription> result = new ArrayList<>(); String lastEvaluatedTableName = null; do {/*from www .jav a 2 s .c o m*/ final ListTablesRequest listTablesRequest = new ListTablesRequest().withLimit(10) .withExclusiveStartTableName(lastEvaluatedTableName); final ListTablesResult requestResult = client.listTables(listTablesRequest); lastEvaluatedTableName = requestResult.getLastEvaluatedTableName(); for (String tableName : requestResult.getTableNames()) { final DescribeTableResult describeResult = client.describeTable(tableName); final TableDescription tableDescription = describeResult.getTable(); result.add(tableDescription); } } while (lastEvaluatedTableName != null); return result; }
From source file:Database.TableFunctions.java
public static String listMyTables() { ArrayList nameList = new ArrayList(); String lastEvaluatedTableName = null; do {//from w ww. j a v a 2 s . c o m ListTablesRequest listTablesRequest = new ListTablesRequest().withLimit(10) .withExclusiveStartTableName(lastEvaluatedTableName); ListTablesResult result = dynamoDB.listTables(listTablesRequest); lastEvaluatedTableName = result.getLastEvaluatedTableName(); for (String name : result.getTableNames()) { System.out.println(name); nameList.add(name); } } while (lastEvaluatedTableName != null); return nameList.toString(); }
From source file:dynamok.source.DynamoDbSourceConnector.java
License:Apache License
@Override public void start(Map<String, String> props) { config = new ConnectorConfig(props); streamShards = new HashMap<>(); final AmazonDynamoDBClient client; final AmazonDynamoDBStreamsClient streamsClient; if (config.accessKeyId.value().isEmpty() || config.secretKeyId.value().isEmpty()) { client = new AmazonDynamoDBClient(); streamsClient = new AmazonDynamoDBStreamsClient(); log.debug("AmazonDynamoDB clients created with default credentials"); } else {//from w w w . j a v a2 s . c om BasicAWSCredentials awsCreds = new BasicAWSCredentials(config.accessKeyId.value(), config.secretKeyId.value()); client = new AmazonDynamoDBClient(awsCreds); streamsClient = new AmazonDynamoDBStreamsClient(awsCreds); log.debug("AmazonDynamoDB clients created with AWS credentials from connector configuration"); } client.configureRegion(config.region); streamsClient.configureRegion(config.region); final Set<String> ignoredTables = new HashSet<>(); final Set<String> consumeTables = new HashSet<>(); String lastEvaluatedTableName = null; do { final ListTablesResult listResult = client.listTables(lastEvaluatedTableName); for (String tableName : listResult.getTableNames()) { if (!acceptTable(tableName)) { ignoredTables.add(tableName); continue; } final TableDescription tableDesc = client.describeTable(tableName).getTable(); final StreamSpecification streamSpec = tableDesc.getStreamSpecification(); if (streamSpec == null || !streamSpec.isStreamEnabled()) { throw new ConnectException( String.format("DynamoDB table `%s` does not have streams enabled", tableName)); } final String streamViewType = streamSpec.getStreamViewType(); if (!streamViewType.equals(StreamViewType.NEW_IMAGE.name()) && !streamViewType.equals(StreamViewType.NEW_AND_OLD_IMAGES.name())) { throw new ConnectException(String.format("DynamoDB stream view type for table `%s` is %s", tableName, streamViewType)); } final DescribeStreamResult describeStreamResult = streamsClient .describeStream(new DescribeStreamRequest().withStreamArn(tableDesc.getLatestStreamArn())); for (Shard shard : describeStreamResult.getStreamDescription().getShards()) { streamShards.put(shard, tableDesc); } consumeTables.add(tableName); } lastEvaluatedTableName = listResult.getLastEvaluatedTableName(); } while (lastEvaluatedTableName != null); log.info("Tables to ignore: {}", ignoredTables); log.info("Tables to ingest: {}", consumeTables); client.shutdown(); streamsClient.shutdown(); }