Search in sources :

Example 6 with AmazonRdsClient

use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient in project cloudbreak by hortonworks.

the class AwsRdsStopService method stop.

public void stop(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException {
    AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential());
    String regionName = ac.getCloudContext().getLocation().getRegion().value();
    AmazonRdsClient rdsClient = awsClient.createRdsClient(credentialView, regionName);
    String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId();
    StopDBInstanceRequest stopDBInstanceRequest = new StopDBInstanceRequest();
    stopDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier);
    LOGGER.debug("RDS stop request");
    try {
        rdsClient.stopDBInstance(stopDBInstanceRequest);
    } catch (RuntimeException ex) {
        throw new CloudConnectorException(ex.getMessage(), ex);
    }
    Waiter<DescribeDBInstancesRequest> rdsWaiter = customAmazonWaiterProvider.getDbInstanceStopWaiter(rdsClient);
    DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier);
    StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId());
    run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck, "RDS stop failed");
    LOGGER.debug("RDS stop process finished. DB Instance ID: {}", dbInstanceIdentifier);
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) StopDBInstanceRequest(com.amazonaws.services.rds.model.StopDBInstanceRequest) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) StackCancellationCheck(com.sequenceiq.cloudbreak.cloud.aws.scheduler.StackCancellationCheck) AmazonRdsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient) DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest)

Aggregations

AmazonRdsClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient)6 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)6 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)5 DescribeDBInstancesRequest (com.amazonaws.services.rds.model.DescribeDBInstancesRequest)4 StackCancellationCheck (com.sequenceiq.cloudbreak.cloud.aws.scheduler.StackCancellationCheck)3 AmazonServiceException (com.amazonaws.AmazonServiceException)1 SdkClientException (com.amazonaws.SdkClientException)1 ListTablesRequest (com.amazonaws.services.dynamodbv2.model.ListTablesRequest)1 ListTablesResult (com.amazonaws.services.dynamodbv2.model.ListTablesResult)1 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)1 DescribeAvailabilityZonesRequest (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest)1 DescribeInstanceTypeOfferingsRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypeOfferingsRequest)1 DescribeInstanceTypesRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest)1 DescribeInstanceTypesResult (com.amazonaws.services.ec2.model.DescribeInstanceTypesResult)1 DescribeInternetGatewaysRequest (com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest)1 DescribeInternetGatewaysResult (com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult)1 DescribeKeyPairsRequest (com.amazonaws.services.ec2.model.DescribeKeyPairsRequest)1 DescribeRegionsRequest (com.amazonaws.services.ec2.model.DescribeRegionsRequest)1 DescribeRegionsResult (com.amazonaws.services.ec2.model.DescribeRegionsResult)1 DescribeRouteTablesRequest (com.amazonaws.services.ec2.model.DescribeRouteTablesRequest)1