use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest in project cloudbreak by hortonworks.
the class AwsNoSqlConnectorTest method getNoSqlTableMetaDataOk.
@Test
public void getNoSqlTableMetaDataOk() {
TableDescription tableDescription = new TableDescription().withTableArn(ARN).withTableStatus(ACTIVE_STATUS);
DescribeTableResult describeResult = new DescribeTableResult().withTable(tableDescription);
when(dynamoDb.describeTable(argThat((ArgumentMatcher<String>) argument -> true))).thenReturn(describeResult);
NoSqlTableMetadataResponse result = underTest.getNoSqlTableMetaData(new NoSqlTableMetadataRequest());
assertEquals(ARN, result.getId());
assertEquals(ACTIVE_STATUS, result.getTableStatus());
assertEquals(ResponseStatus.OK, result.getStatus());
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest in project cloudbreak by hortonworks.
the class AwsNoSqlConnectorTest method getNoSqlTableMetaDataResourceNotFound.
@Test
public void getNoSqlTableMetaDataResourceNotFound() {
when(dynamoDb.describeTable(argThat((ArgumentMatcher<String>) argument -> true))).thenThrow(new ResourceNotFoundException("not found"));
NoSqlTableMetadataResponse result = underTest.getNoSqlTableMetaData(new NoSqlTableMetadataRequest());
assertNull(result.getId());
assertNull(result.getTableStatus());
assertEquals(ResponseStatus.RESOURCE_NOT_FOUND, result.getStatus());
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest in project cloudbreak by hortonworks.
the class NoSqlTableCreationModeDeterminerService method getNoSqlTableMetaData.
private NoSqlTableMetadataResponse getNoSqlTableMetaData(LocationAwareCredential locationAwareCredential, String dynamoDbTablename) {
Credential credential = locationAwareCredential.getCredential();
String cloudPlatform = credential.getCloudPlatform();
String location = locationAwareCredential.getLocation();
NoSqlConnector noSqlConnector = getNoSqlConnector(cloudPlatform);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
NoSqlTableMetadataRequest request = NoSqlTableMetadataRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
return noSqlConnector.getNoSqlTableMetaData(request);
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandler method deleteNoSqlTable.
private ResponseStatus deleteNoSqlTable(LocationAwareCredential locationAwareCredential, String dynamoDbTablename) {
Credential credential = locationAwareCredential.getCredential();
String cloudPlatform = credential.getCloudPlatform();
String location = locationAwareCredential.getLocation();
NoSqlConnector noSqlConnector = getNoSqlConnector(cloudPlatform);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
NoSqlTableMetadataRequest noSqlTableMetadataRequest = NoSqlTableMetadataRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
NoSqlTableMetadataResponse noSqlTableMetaData = noSqlConnector.getNoSqlTableMetaData(noSqlTableMetadataRequest);
if (ResponseStatus.OK.equals(noSqlTableMetaData.getStatus())) {
NoSqlTableDeleteRequest request = NoSqlTableDeleteRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
NoSqlTableDeleteResponse response = noSqlConnector.deleteNoSqlTable(request);
return response.getStatus();
} else {
return ResponseStatus.OK;
}
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest in project cloudbreak by hortonworks.
the class AwsNoSqlConnectorTest method getNoSqlTableMetaDataAwsError.
@Test
public void getNoSqlTableMetaDataAwsError() {
when(dynamoDb.describeTable(argThat((ArgumentMatcher<String>) argument -> true))).thenThrow(new AmazonDynamoDBException("provider error"));
thrown.expect(CloudConnectorException.class);
thrown.expectMessage("provider error");
underTest.getNoSqlTableMetaData(new NoSqlTableMetadataRequest());
}
Aggregations