@Test(expected = CloudConnectorException.class) public void shouldThrowCloudConnectorExceptionInCaseOfSchedulerException() throws InterruptedException, ExecutionException, TimeoutException { ArgumentCaptor<StopDBInstanceRequest> stopDBInstanceRequestArgumentCaptor = ArgumentCaptor.forClass(StopDBInstanceRequest.class); when(amazonRDS.stopDBInstance(stopDBInstanceRequestArgumentCaptor.capture())).thenReturn(null); doThrow(WaiterTimedOutException.class).when(rdsWaiter).run(any()); victim.stop(authenticatedContext, dbStack); }
public void stop(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS 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); }
AwsRdsStopService { public void stop(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS 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); } }
AwsRdsStopService { public void stop(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS 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); }  }
AwsRdsStopService { public void stop(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS 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); }  void stop(AuthenticatedContext ac, DatabaseStack dbStack); }
AwsRdsStopService { public void stop(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS 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); }  void stop(AuthenticatedContext ac, DatabaseStack dbStack);  }