use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetup method setupAllDatabaseInstances.
/**
* Create all database instances if they do not already exist.
*
* @param client
* @param config
*/
public void setupAllDatabaseInstances() throws InterruptedException {
// Build the request to create the ID generator database.
CreateDBInstanceRequest request = buildIdGeneratorCreateDBInstanceRequest();
// Get the instances
DBInstance idGenInstance = createOrGetDatabaseInstance(request);
log.debug("Database instance: ");
log.debug(idGenInstance);
// Now create the stack instance database
request = buildStackInstancesCreateDBInstanceRequest();
// Get the instances
DBInstance stackInstance = createOrGetDatabaseInstance(request);
log.debug("Database instance: ");
log.debug(stackInstance);
// Create the table instances databases
int numTableInstances = Integer.parseInt(config.getNumberTableInstances());
List<DBInstance> stackTableInstances = new ArrayList<DBInstance>();
for (int inst = 0; inst < numTableInstances; inst++) {
request = buildStackTableDBInstanceCreateDBInstanceRequest(inst);
DBInstance dbInst = createOrGetDatabaseInstance(request);
log.debug("Database instance: " + dbInst);
stackTableInstances.add(dbInst);
}
// Wait for both to be created
idGenInstance = waitForDatabase(idGenInstance);
stackInstance = waitForDatabase(stackInstance);
List<DBInstance> updStackTableInstances = new ArrayList<DBInstance>();
for (DBInstance ti : stackTableInstances) {
ti = waitForDatabase(ti);
updStackTableInstances.add(ti);
}
resources.setIdGeneratorDatabase(idGenInstance);
resources.setStackInstancesDatabase(stackInstance);
resources.setStackInstanceTablesDatabases(updStackTableInstances);
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetup method buildIdGeneratorCreateDBInstanceRequest.
/**
* Build up the CreateDBInstanceRequest used to create the ID Generator database.
*
* @return
*/
CreateDBInstanceRequest buildIdGeneratorCreateDBInstanceRequest() {
CreateDBInstanceRequest request = getDefaultCreateDBInstanceRequest();
// Is this a production stack?
if (config.isProductionStack()) {
// Production database need to have a backup replicate ready to go in another
// zone at all times!
request.setMultiAZ(true);
} else {
// This is not a production stack so we do not want to incur the extra cost of
// a backup replicate database in another zone.
request.setMultiAZ(false);
}
// This will be the schema name.
request.setDBName(config.getIdGeneratorDatabaseSchemaName());
request.setDBInstanceIdentifier(config.getIdGeneratorDatabaseIdentifier());
// This database only needs a small amount of disk space so this is set the minimum of 5 GB
request.setAllocatedStorage(new Integer(5));
request.setMasterUsername(config.getIdGeneratorDatabaseMasterUsername());
request.setMasterUserPassword(config.getIdGeneratorDatabaseMasterPasswordPlaintext());
// The security group
request.withDBSecurityGroups(config.getIdGeneratorDatabaseSecurityGroupName());
// The parameters.
request.setDBParameterGroupName(config.getDatabaseParameterGroupName());
return request;
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetup method buildStackTableDBInstanceCreateDBInstanceRequest.
CreateDBInstanceRequest buildStackTableDBInstanceCreateDBInstanceRequest(int instNum) {
CreateDBInstanceRequest request = getDefaultCreateDBInstanceRequest();
if (config.isProductionStack()) {
request.setDBInstanceClass(DATABASE_INSTANCE_CLASS_R3_LARGE);
request.setAllocatedStorage(new Integer(500));
} else {
request.setDBInstanceClass(DATABASE_INSTANCE_CLASS_M1_SMALL);
request.setAllocatedStorage(new Integer(10));
}
// This will be the schema name.
request.setDBName(config.getStackInstanceTablesDBSchema());
request.setDBInstanceIdentifier(config.getStackTableDBInstanceDatabaseIdentifier(instNum));
request.setMasterUsername(config.getStackInstanceDatabaseMasterUser());
request.setMasterUserPassword(config.getStackInstanceDatabaseMasterPasswordPlaintext());
request.setBackupRetentionPeriod(0);
// The security group
request.withDBSecurityGroups(config.getStackDatabaseSecurityGroupName());
// The parameters.
request.setDBParameterGroupName(config.getDatabaseParameterGroupName());
// if this is a production stack
return request;
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetup method getDefaultCreateDBInstanceRequest.
/**
* Fill out a CreateDBInstanceRequest will all of the default values.
*
* @return
*/
public static CreateDBInstanceRequest getDefaultCreateDBInstanceRequest() {
CreateDBInstanceRequest request = new CreateDBInstanceRequest();
request.setAllocatedStorage(new Integer(10));
request.setDBInstanceClass(DATABASE_INSTANCE_CLASS_M1_SMALL);
request.setEngine(DATABASE_ENGINE_MYSQL);
// request.setAvailabilityZone(EC2_AVAILABILITY_ZONE_US_EAST_1D);
request.setPreferredMaintenanceWindow(PREFERRED_DATABASE_MAINTENANCE_WINDOW_SUNDAY_NIGHT_PDT);
request.setBackupRetentionPeriod(new Integer(7));
request.setPreferredBackupWindow(PREFERRED_DATABASE_BACKUP_WINDOW_MIDNIGHT);
request.setMultiAZ(false);
request.setEngineVersion(DATABASE_ENGINE_MYSQL_VERSION);
request.setAutoMinorVersionUpgrade(true);
request.setLicenseModel(LICENSE_MODEL_GENERAL_PUBLIC);
return request;
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetup method buildStackInstancesCreateDBInstanceRequest.
/**
* Build up the CreateDBInstanceRequest used for the stack-instance database.
*
* @return
*/
CreateDBInstanceRequest buildStackInstancesCreateDBInstanceRequest() {
CreateDBInstanceRequest request = getDefaultCreateDBInstanceRequest();
// Production stacks have have different properties
if (config.isProductionStack()) {
// Production database need to have a backup replicate ready to go in another
// zone at all times!
request.setMultiAZ(true);
// The production database should be a large
request.setDBInstanceClass(DATABASE_INSTANCE_CLASS_R3_LARGE);
// The size of the database should be 50GB
request.setAllocatedStorage(new Integer(50));
} else {
// This is not a production stack so we do not want to incur the extra cost of
// a backup replicate database in another zone.
request.setMultiAZ(false);
// All non-production databases should be small
request.setDBInstanceClass(DATABASE_INSTANCE_CLASS_M1_SMALL);
// The size of the database should be 10GB
request.setAllocatedStorage(new Integer(10));
}
// This will be the schema name.
request.setDBName(config.getStackInstanceDatabaseSchema());
request.setDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier());
request.setMasterUsername(config.getStackInstanceDatabaseMasterUser());
request.setMasterUserPassword(config.getStackInstanceDatabaseMasterPasswordPlaintext());
// The security group
request.withDBSecurityGroups(config.getStackDatabaseSecurityGroupName());
// The parameters.
request.setDBParameterGroupName(config.getDatabaseParameterGroupName());
// if this is a production stack
return request;
}
Aggregations