use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonDynamoDBClient in project cloudbreak by hortonworks.
the class AwsPlatformResources method noSqlTables.
@Override
public CloudNoSqlTables noSqlTables(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters) {
List<CloudNoSqlTable> noSqlTables = new ArrayList<>();
AmazonDynamoDBClient dynamoDbClient = getAmazonDynamoDBClient(cloudCredential, region);
ListTablesRequest listTablesRequest = new ListTablesRequest();
ListTablesResult listTablesResult = null;
boolean first = true;
while (first || !isNullOrEmpty(listTablesResult.getLastEvaluatedTableName())) {
first = false;
listTablesRequest.setExclusiveStartTableName(listTablesResult == null ? null : listTablesResult.getLastEvaluatedTableName());
listTablesResult = dynamoDbClient.listTables(listTablesRequest);
List<String> partialTableNames = listTablesResult.getTableNames();
List<CloudNoSqlTable> partialResult = partialTableNames.stream().map(CloudNoSqlTable::new).collect(Collectors.toList());
noSqlTables.addAll(partialResult);
}
return new CloudNoSqlTables(noSqlTables);
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonDynamoDBClient in project cloudbreak by hortonworks.
the class AwsNoSqlConnector method deleteNoSqlTable.
@Override
public NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request) {
try {
LOGGER.debug("Calling DynamoDB.deleteTable('{}')", request.getTableName());
AmazonDynamoDBClient dynamoDbClient = getAmazonDynamoDB(request);
DeleteTableResult deleteTableResult = dynamoDbClient.deleteTable(request.getTableName());
LOGGER.debug("Successfully called DynamoDB.deleteTable('{}')", request.getTableName());
TableDescription tableDescription = deleteTableResult.getTableDescription();
return NoSqlTableDeleteResponse.builder().withStatus(ResponseStatus.OK).withId(tableDescription.getTableArn()).withTableStatus(tableDescription.getTableStatus()).build();
} catch (ResourceNotFoundException e) {
LOGGER.info("DynamoDB table not found '{}'", request.getTableName());
return NoSqlTableDeleteResponse.builder().withStatus(ResponseStatus.RESOURCE_NOT_FOUND).build();
} catch (AmazonDynamoDBException e) {
LOGGER.error(String.format("DynamoDB exception on deleteTable '%s'", request.getTableName()), e);
throw new CloudConnectorException(String.format("Cannot delete NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e);
}
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonDynamoDBClient in project cloudbreak by hortonworks.
the class AwsNoSqlConnector method getNoSqlTableMetaData.
@Override
public NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request) {
try {
LOGGER.debug("Calling DynamoDB.describeTable('{}')", request.getTableName());
AmazonDynamoDBClient dynamoDbClient = getAmazonDynamoDB(request);
DescribeTableResult describeTableResult = dynamoDbClient.describeTable(request.getTableName());
LOGGER.debug("Successfully called DynamoDB.describeTable('{}')", request.getTableName());
return NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.OK).withId(describeTableResult.getTable().getTableArn()).withTableStatus(describeTableResult.getTable().getTableStatus()).build();
} catch (ResourceNotFoundException e) {
LOGGER.info("DynamoDB table not found '{}'", request.getTableName());
return NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.RESOURCE_NOT_FOUND).build();
} catch (AmazonDynamoDBException e) {
LOGGER.error(String.format("DynamoDB exception on describeTAble '%s'", request.getTableName()), e);
throw new CloudConnectorException(String.format("Cannot get metadata for NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e);
}
}
Aggregations