Search in sources :

Example 1 with DescribeDBInstancesRequest

use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class MySqlDatabaseSetup method describeResources.

public void describeResources() {
    DescribeDBInstancesRequest req;
    DescribeDBInstancesResult res;
    req = buildIdGeneratorDescribeDBInstanceRequest();
    res = client.describeDBInstances(req);
    if ((res.getDBInstances() != null) && (res.getDBInstances().size() == 1)) {
        resources.setIdGeneratorDatabase(res.getDBInstances().get(0));
    }
    req = buildStackInstanceDescribeDBInstanceRequest();
    res = client.describeDBInstances(req);
    if ((res.getDBInstances() != null) && (res.getDBInstances().size() == 1)) {
        resources.setStackInstancesDatabase(res.getDBInstances().get(0));
    }
    // TODO: Describe table DB instances
    List<DBInstance> descDbInstResults = new ArrayList<DBInstance>();
    int numTableInstances = Integer.parseInt(this.config.getNumberTableInstances());
    for (int i = 0; i < numTableInstances; i++) {
        req = buildStackTableDBInstanceDescribeDBInstanceRequest(i);
        res = client.describeDBInstances(req);
        if ((res.getDBInstances() != null) && (res.getDBInstances().size() == 1)) {
            descDbInstResults.add(res.getDBInstances().get(0));
        }
    }
    resources.setStackInstanceTablesDatabases(descDbInstResults);
}
Also used : DBInstance(com.amazonaws.services.rds.model.DBInstance) ArrayList(java.util.ArrayList) DescribeDBInstancesResult(com.amazonaws.services.rds.model.DescribeDBInstancesResult) DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest)

Example 2 with DescribeDBInstancesRequest

use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class MySqlDatabaseSetup method buildStackTableDBInstanceDescribeDBInstanceRequest.

DescribeDBInstancesRequest buildStackTableDBInstanceDescribeDBInstanceRequest(int inst) {
    DescribeDBInstancesRequest req = new DescribeDBInstancesRequest();
    req.setDBInstanceIdentifier(config.getStackTableDBInstanceDatabaseIdentifier(inst));
    return req;
}
Also used : DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest)

Example 3 with DescribeDBInstancesRequest

use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class MySqlDatabaseSetup method buildStackInstanceDescribeDBInstanceRequest.

DescribeDBInstancesRequest buildStackInstanceDescribeDBInstanceRequest() {
    DescribeDBInstancesRequest req = new DescribeDBInstancesRequest();
    req.setDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier());
    return req;
}
Also used : DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest)

Example 4 with DescribeDBInstancesRequest

use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class MySqlDatabaseSetupTest method testbuildStackInstanceDescribeDBInstanceRequest.

@Test
public void testbuildStackInstanceDescribeDBInstanceRequest() {
    DescribeDBInstancesRequest expectedReq = new DescribeDBInstancesRequest().withDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier());
    DescribeDBInstancesRequest req = databaseSetup.buildStackInstanceDescribeDBInstanceRequest();
    assertEquals(expectedReq, req);
}
Also used : DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest) Test(org.junit.Test)

Example 5 with DescribeDBInstancesRequest

use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class MySqlDatabaseSetupTest method testWaitForDatabaseNotAvailable.

@Test
public void testWaitForDatabaseNotAvailable() throws Exception {
    when(mockDbInstance.getDBInstanceStatus()).thenReturn("busy");
    when(mockDbInstance.getDBInstanceIdentifier()).thenReturn("dbInstanceId");
    List<DBInstance> expectedDBInstances = Arrays.asList(mockDbInstance);
    when(mockDBInstancesResult.getDBInstances()).thenReturn(expectedDBInstances);
    ArgumentCaptor<DescribeDBInstancesRequest> captor = new ArgumentCaptor<>();
    when(mockClient.describeDBInstances(captor.capture())).thenReturn(mockDBInstancesResult);
    DBInstance instance = databaseSetup.waitForDatabase(mockDbInstance);
    List<DescribeDBInstancesRequest> actualRequests = captor.getAllValues();
    assertEquals(10, actualRequests.size());
    assertNull(instance);
}
Also used : ArgumentCaptor(org.mockito.ArgumentCaptor) DBInstance(com.amazonaws.services.rds.model.DBInstance) DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest) Test(org.junit.Test)

Aggregations

DescribeDBInstancesRequest (com.amazonaws.services.rds.model.DescribeDBInstancesRequest)14 Test (org.junit.Test)8 DBInstance (com.amazonaws.services.rds.model.DBInstance)6 DescribeDBInstancesResult (com.amazonaws.services.rds.model.DescribeDBInstancesResult)4 ArgumentCaptor (org.mockito.ArgumentCaptor)3 CreateDBInstanceRequest (com.amazonaws.services.rds.model.CreateDBInstanceRequest)2 DBInstanceNotFoundException (com.amazonaws.services.rds.model.DBInstanceNotFoundException)2 ArrayList (java.util.ArrayList)1