List of usage examples for com.amazonaws.services.rds.model CreateDBInstanceRequest getAllocatedStorage
public Integer getAllocatedStorage()
The amount of storage (in gibibytes) to allocate for the DB instance.
From source file:com.msi.tough.utils.rds.InstanceEntity.java
/************************************************************************** * Inserts records into the following tables rds_dbinstance * rds_security_group_membership rds_dbparameter_group_status This method * also checks quota's/*from ww w . jav a 2s .c om*/ * * @param createRec * @param userID * @param address * @param readReplica * @throws BaseException */ public static RdsDbinstance insertDBInstance(final Session sess, final CreateDBInstanceRequest createRec, final AccountBean ac) { final Logger logger = LoggerFactory.getLogger(thisClass); final String instID = createRec.getDBInstanceIdentifier(); final RdsDbinstance dbrec = RDSUtil.getInstance(sess, instID, ac.getId()); if (dbrec != null) { throw RDSQueryFaults.DBInstanceAlreadyExists(); } final String paramGrpName = createRec.getDBParameterGroupName(); // check that ParameterGroup exists RdsDbparameterGroup pgRec = ParameterGroupEntity.getParameterGroup(sess, paramGrpName, ac.getId()); if (pgRec == null) { List<RdsDbparameterGroup> paramGrps = ParameterGroupEntity.selectDBParameterGroups(sess, paramGrpName, 1, null, null); if (paramGrps == null || paramGrps.size() != 1) { throw RDSQueryFaults.DBParameterGroupNotFound(); } else { // default parameter group is being used; copy the group and parameters for this user ParameterGroupEntity.createDefaultDBParameterGroup(sess, ac, paramGrpName); pgRec = ParameterGroupEntity.getParameterGroup(sess, paramGrpName, ac.getId()); } } /* * DBSecurityGroup ************************************************* The * create request contains a list of DBSecurityGroupNames we need to * process each one */ final RdsDbinstance newInst = new RdsDbinstance(ac, pgRec); if (createRec.getDBSecurityGroups() == null || createRec.getDBSecurityGroups().size() == 0) { // this line is never reached because "default" is set by default as DBSecurityGroup } else { // Process the array of SecurityGroup Names final String[] secGrpName = createRec.getDBSecurityGroups().toArray(new String[0]); final int len = secGrpName.length; final List<RdsDbsecurityGroup> groups = newInst.getSecurityGroups(); for (int i = 0; i < len; i++) { // check that the security group exists final RdsDbsecurityGroup sgmemRec = SecurityGroupEntity.getSecurityGroup(sess, secGrpName[i], ac.getId()); if (sgmemRec == null && !secGrpName[i].equals("default")) { throw RDSQueryFaults.DBSecurityGroupNotFound(); } groups.add(sgmemRec); } } newInst.setInstanceCreateTime(new Date()); newInst.setLatestRestorableTime(new Date()); newInst.setAllocatedStorage(createRec.getAllocatedStorage().intValue()); newInst.setAutoMinorVersionUpgrade(createRec.getAutoMinorVersionUpgrade()); newInst.setAvailabilityZone(createRec.getAvailabilityZone()); newInst.setBackupRetentionPeriod(createRec.getBackupRetentionPeriod().intValue()); final String dbInstClass = createRec.getDBInstanceClass(); final String instClass = (String) ConfigurationUtil .getConfiguration(Arrays.asList(new String[] { dbInstClass, createRec.getAvailabilityZone() })); if (instClass == null) { throw RDSQueryFaults .InvalidParameterValue(dbInstClass + " is not one of the valid DBInstance classes."); } newInst.setDbinstanceClass(dbInstClass); newInst.setDbinstanceId(createRec.getDBInstanceIdentifier()); newInst.setDbName(createRec.getDBName()); newInst.setDbParameterGroup(paramGrpName); newInst.setEngine(createRec.getEngine()); newInst.setEngineVersion(createRec.getEngineVersion()); newInst.setMasterUsername(createRec.getMasterUsername()); newInst.setMasterUserPassword(createRec.getMasterUserPassword()); newInst.setMultiAz(createRec.getMultiAZ()); newInst.setPort(createRec.getPort().intValue()); newInst.setPreferredBackupWindow(createRec.getPreferredBackupWindow()); newInst.setPreferredMaintenanceWindow(createRec.getPreferredMaintenanceWindow()); newInst.setLicenseModel(createRec.getLicenseModel()); newInst.setDbinstanceStatus("creating"); final List<String> DBSecurityGroupNames = createRec.getDBSecurityGroups(); final List<RdsDbsecurityGroup> dbsecgrps = new LinkedList<RdsDbsecurityGroup>(); for (final String dbSecGrpname : DBSecurityGroupNames) { final RdsDbsecurityGroup temp = SecurityGroupEntity.getSecurityGroup(sess, dbSecGrpname, ac.getId()); if (temp == null) { throw RDSQueryFaults.DBSecurityGroupNotFound(); } dbsecgrps.add(temp); } newInst.setSecurityGroups(dbsecgrps); // save / create the instance record sess.save(newInst); logger.info("insertDBInstance: Successfully Inserted Instance " + "into the Database"); return newInst; }