@Override public ListTablesResult listTables() { return listTables(new ListTablesRequest()); }
@Override public ListTablesResult listTables(String exclusiveStartTableName) { return listTables(new ListTablesRequest().withExclusiveStartTableName(exclusiveStartTableName)); }
@Override public ListTablesResult listTables(Integer limit) { return listTables(new ListTablesRequest().withLimit(limit)); }
@Override public ListTablesResult listTables(String exclusiveStartTableName, Integer limit) { return listTables(new ListTablesRequest().withExclusiveStartTableName(exclusiveStartTableName).withLimit(limit)); }
AWSCredentialsProvider aWSCredentialsProvider = new SystemPropertiesCredentialsProvider(); //substitute the above line for any valid *Provider implementation AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(aWSCredentialsProvider); //the above line is now passing an instance of AWSCredentialsProvider //as opposed to AWSCredentials ... amazonDynamoDBClient.listTables(); //the above line is now enabled, via the AWSCredentialsProvider, to //automatically refresh the AWSCredentials if/when they have expired
/** * <p> * Returns an array of table names associated with the current account and * endpoint. The output from <code>ListTables</code> is paginated, with each * page returning a maximum of 100 table names. * </p> * * @return listTablesResult The response from the ListTables service method, * as returned by Amazon DynamoDB. * @throws InternalServerErrorException * @throws AmazonClientException If any internal errors are encountered * inside the client while attempting to make the request or * handle the response. For example if a network connection is * not available. * @throws AmazonServiceException If an error response is returned by Amazon * DynamoDB indicating either a problem with the data in the * request, or a server side issue. */ public ListTablesResult listTables() throws AmazonServiceException, AmazonClientException { ListTablesRequest listTablesRequest = new ListTablesRequest(); return listTables(listTablesRequest); }
AWSCredentialsProvider aWSCredentialsProvider = new SystemPropertiesCredentialsProvider(); //the above line may be substituted for any valid //*Provider implementation AWSCredentials aWSCredentials = aWSCredentialsProvider.getCredentials(); AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(aWSCredentials); ... amazonDynamoDBClient.listTables(); //the above line is where the ExpiredTokenException is eventually thrown
/** * <p> * Returns an array of table names associated with the current account and * endpoint. The output from <code>ListTables</code> is paginated, with each * page returning a maximum of 100 table names. * </p> * * @param limit <p> * A maximum number of table names to return. If this parameter * is not specified, the limit is 100. * </p> * @return listTablesResult The response from the ListTables service method, * as returned by Amazon DynamoDB. * @throws InternalServerErrorException * @throws AmazonClientException If any internal errors are encountered * inside the client while attempting to make the request or * handle the response. For example if a network connection is * not available. * @throws AmazonServiceException If an error response is returned by Amazon * DynamoDB indicating either a problem with the data in the * request, or a server side issue. */ public ListTablesResult listTables(Integer limit) throws AmazonServiceException, AmazonClientException { ListTablesRequest listTablesRequest = new ListTablesRequest(); listTablesRequest.setLimit(limit); return listTables(listTablesRequest); }
/** * <p> * Returns an array of table names associated with the current account and * endpoint. The output from <code>ListTables</code> is paginated, with each * page returning a maximum of 100 table names. * </p> * * @param exclusiveStartTableName <p> * The first table name that this operation will evaluate. Use * the value that was returned for * <code>LastEvaluatedTableName</code> in a previous operation, * so that you can obtain the next page of results. * </p> * @return listTablesResult The response from the ListTables service method, * as returned by Amazon DynamoDB. * @throws InternalServerErrorException * @throws AmazonClientException If any internal errors are encountered * inside the client while attempting to make the request or * handle the response. For example if a network connection is * not available. * @throws AmazonServiceException If an error response is returned by Amazon * DynamoDB indicating either a problem with the data in the * request, or a server side issue. */ public ListTablesResult listTables(String exclusiveStartTableName) throws AmazonServiceException, AmazonClientException { ListTablesRequest listTablesRequest = new ListTablesRequest(); listTablesRequest.setExclusiveStartTableName(exclusiveStartTableName); return listTables(listTablesRequest); }
listTablesRequest.setExclusiveStartTableName(exclusiveStartTableName); listTablesRequest.setLimit(limit); return listTables(listTablesRequest);
@Override public ListTablesResult listTables() { return listTables(new ListTablesRequest()); }
@Override public ListTablesResult listTables(String exclusiveStartTableName) { return listTables(new ListTablesRequest().withExclusiveStartTableName(exclusiveStartTableName)); }
/** * Lists all table names for this account. * @return a list of DynamoDB tables */ public static List<String> listAllTables() { ListTablesResult ltr = getClient().listTables(100); List<String> tables = new LinkedList<String>(); String lastKey; do { tables.addAll(ltr.getTableNames()); lastKey = ltr.getLastEvaluatedTableName(); } while (!(ltr = getClient().listTables(lastKey, 100)).getTableNames().isEmpty()); return tables; }
@Override public ListTablesResult listTables(Integer limit) { return listTables(new ListTablesRequest().withLimit(limit)); }
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()); }
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 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); } } }
@Override public ListTablesResult listTables(String exclusiveStartTableName, Integer limit) { return listTables(new ListTablesRequest().withExclusiveStartTableName(exclusiveStartTableName).withLimit(limit)); }
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); }
public DynamoDBService2(Tenant tenant) { super(tenant); String accessKey = getParamString("ddb-access-key"); String secretKey = getParamString("ddb-secret-key"); String endpoint = getParamString("ddb-endpoint"); m_readCapacityUnits = getParamInt("ddb-read-capacity-units", 1); m_writeCapacityUnits = getParamInt("ddb-write-capacity-units", 1); BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); m_client = new AmazonDynamoDBClient(awsCredentials); m_client.setEndpoint(endpoint); // try to connect to check the connection m_client.listTables(); m_logger.info("Started DynamoDB service. Endpoint: {}, read/write capacity units for new namespaces: {}/{}", new Object[] {endpoint, m_readCapacityUnits, m_writeCapacityUnits}); }