List of usage examples for com.amazonaws.services.rds.model DBInstance getDBName
public String getDBName()
The meaning of this parameter differs according to the database engine you use.
From source file:com.airbnb.billow.RDSInstance.java
public RDSInstance(DBInstance instance, DBCluster cluster, List<Tag> tagList) { this.allocatedStorage = instance.getAllocatedStorage(); this.autoMinorVersionUpgrade = instance.getAutoMinorVersionUpgrade(); this.availabilityZone = instance.getAvailabilityZone(); this.backupRetentionPeriod = instance.getBackupRetentionPeriod(); this.characterSetName = instance.getCharacterSetName(); this.dBInstanceClass = instance.getDBInstanceClass(); this.dBInstanceIdentifier = instance.getDBInstanceIdentifier(); this.dBInstanceStatus = instance.getDBInstanceStatus(); this.dBClusterIdentifier = instance.getDBClusterIdentifier(); this.dBName = instance.getDBName(); this.dBParameterGroups = instance.getDBParameterGroups(); this.dBSecurityGroups = instance.getDBSecurityGroups(); this.dBSubnetGroup = instance.getDBSubnetGroup(); this.endpoint = instance.getEndpoint(); if (this.endpoint != null) { this.hostname = endpoint.getAddress(); this.privateIP = getPrivateIp(hostname); } else {/*from w ww . j a v a 2 s . co m*/ this.hostname = null; this.privateIP = null; } this.engine = instance.getEngine(); this.engineVersion = instance.getEngineVersion(); this.instanceCreateTime = instance.getInstanceCreateTime(); this.iops = instance.getIops(); this.latestRestorableTime = instance.getLatestRestorableTime(); this.licenseModel = instance.getLicenseModel(); this.masterUsername = instance.getMasterUsername(); this.multiAZ = instance.getMultiAZ(); this.optionGroupMemberships = instance.getOptionGroupMemberships(); this.pendingModifiedValues = instance.getPendingModifiedValues(); this.preferredBackupWindow = instance.getPreferredBackupWindow(); this.preferredMaintenanceWindow = instance.getPreferredMaintenanceWindow(); this.publiclyAccessible = instance.getPubliclyAccessible(); this.readReplicaDBInstanceIdentifiers = instance.getReadReplicaDBInstanceIdentifiers(); this.readReplicaSourceDBInstanceIdentifier = instance.getReadReplicaSourceDBInstanceIdentifier(); this.secondaryAvailabilityZone = instance.getSecondaryAvailabilityZone(); this.statusInfos = instance.getStatusInfos(); this.vpcSecurityGroups = instance.getVpcSecurityGroups(); this.isMaster = checkIfMaster(instance, cluster); this.tags = new HashMap<>(tagList.size()); for (Tag tag : tagList) { this.tags.put(tag.getKey(), tag.getValue()); } }
From source file:com.AWSManagementAntTask.dao.RDSDao.java
public AWSMATDto find() { List<IAWSDto> dtolist = new ArrayList<IAWSDto>(); for (DBInstance res : rds.describeDBInstances().getDBInstances()) { RDSDto dto = new RDSDto(); dto.setRegionName(this.dto.getRegionName()); dto.setDBInstanceIdentifier(res.getDBInstanceIdentifier()); dto.setDBName(res.getDBName()); dto.setDBInstanceStatus(res.getDBInstanceStatus()); dto.setInstanceCreateTime(res.getInstanceCreateTime()); dto.setEngine(res.getEngine());/*from www . j a va 2 s .c o m*/ dto.setEngineVersion(res.getEngineVersion()); dto.setLicenseModel(res.getLicenseModel()); dto.setStorageType(res.getStorageType()); dto.setAllocatedStorage(res.getAllocatedStorage()); dto.setDBInstanceClass(res.getDBInstanceClass()); dto.setMasterUsername(res.getMasterUsername()); dtolist.add(dto); } this.dto.setRdslist(dtolist); return this.dto; }
From source file:com.jaspersoft.jasperserver.war.amazon.client.AwsDataSourceServiceImpl.java
License:Open Source License
private List<AwsDBInstanceDTO> toRDSInstancesDTOs(List<DBInstance> dbInstances, String amazonDBService) { List<AwsDBInstanceDTO> awsDBInstanceDTOs = new ArrayList<AwsDBInstanceDTO>(); if (dbInstances != null && dbInstances.size() > 0) { for (DBInstance dbInstance : dbInstances) { if (dbInstance.getDBInstanceStatus().toLowerCase().equals(awsDataSourceActiveStatus)) { AwsDBInstanceDTO awsDBInstanceDTO = new AwsDBInstanceDTO(); awsDBInstanceDTO.setdBInstanceIdentifier(dbInstance.getDBInstanceIdentifier()); awsDBInstanceDTO.setdBName(dbInstance.getDBName()); awsDBInstanceDTO.setEngine(dbInstance.getEngine()); awsDBInstanceDTO.setEngineVersion(dbInstance.getEngineVersion()); awsDBInstanceDTO.setAddress(dbInstance.getEndpoint().getAddress()); awsDBInstanceDTO.setPort(dbInstance.getEndpoint().getPort()); awsDBInstanceDTO.setAmazonDbService(amazonDBService.toLowerCase()); updateWithConnectionUrl(awsDBInstanceDTO); awsDBInstanceDTOs.add(awsDBInstanceDTO); }// ww w . ja v a 2 s . com } } else { return generateDBServiceInfoStatus(amazonDBService, "resource.dataSource.aws.empty"); } return awsDBInstanceDTOs; }
From source file:com.msi.tough.rdsquery.RDSQueryUtil.java
public static void marshalDBInstance(XMLNode parent, DBInstance dbInstance) { XMLNode n = new XMLNode(RDS_Constants.NODE_DBINSTANCE); parent.addNode(n);/* w w w . java 2s.c o m*/ QueryUtil.addNode(n, RDS_Constants.NODE_ALLOCATEDSTORAGE, "" + dbInstance.getAllocatedStorage()); QueryUtil.addNode(n, RDS_Constants.NODE_AUTOMINORVERSIONUPGRADE, dbInstance.getAutoMinorVersionUpgrade()); QueryUtil.addNode(n, RDS_Constants.NODE_AVAILABILITYZONE, dbInstance.getAvailabilityZone()); QueryUtil.addNode(n, RDS_Constants.NODE_BACKUPRETENTIONPERIOD, dbInstance.getBackupRetentionPeriod()); QueryUtil.addNode(n, RDS_Constants.NODE_DBINSTANCECLASS, dbInstance.getDBInstanceClass()); QueryUtil.addNode(n, RDS_Constants.NODE_DBINSTANCEIDENTIFIER, dbInstance.getDBInstanceIdentifier()); QueryUtil.addNode(n, RDS_Constants.NODE_DBNAME, dbInstance.getDBName()); QueryUtil.addNode(n, RDS_Constants.NODE_DBINSTANCESTATUS, dbInstance.getDBInstanceStatus()); RDSQueryUtil.marshalDBParameterGroupStatus(n, dbInstance); RDSQueryUtil.marshalDBSecurityGroups(n, dbInstance); RDSQueryUtil.marshalEndpoint(n, dbInstance); QueryUtil.addNode(n, RDS_Constants.NODE_ENGINE, dbInstance.getEngine().toLowerCase()); QueryUtil.addNode(n, RDS_Constants.NODE_ENGINEVERSION, dbInstance.getEngineVersion()); QueryUtil.addNode(n, RDS_Constants.INSTANCE_CREATETIME, dbInstance.getInstanceCreateTime()); QueryUtil.addNode(n, RDS_Constants.NODE_LICENSEMODEL, dbInstance.getLicenseModel()); QueryUtil.addNode(n, RDS_Constants.NODE_LATESTRESTORABLETIME, dbInstance.getLatestRestorableTime()); QueryUtil.addNode(n, RDS_Constants.NODE_MULTIAZ, dbInstance.getMultiAZ()); RDSQueryUtil.marshalPendingModifiedValues(n, dbInstance.getPendingModifiedValues()); QueryUtil.addNode(n, RDS_Constants.PREFERREDBACKUPWINDOW, dbInstance.getPreferredBackupWindow()); QueryUtil.addNode(n, RDS_Constants.NODE_PREFERREDMAINTENANCEWINDOW, dbInstance.getPreferredMaintenanceWindow()); RDSQueryUtil.marshalReadReplicaDBInstanceIdentifiers(n, dbInstance.getReadReplicaDBInstanceIdentifiers()); QueryUtil.addNode(n, RDS_Constants.NODE_READREPLICASOURCEDBINSTANCEIDENTIFIER, dbInstance.getReadReplicaSourceDBInstanceIdentifier()); QueryUtil.addNode(n, RDS_Constants.NODE_MASTERUSERNAME, dbInstance.getMasterUsername()); }
From source file:com.optimalbi.AmazonAccount.java
License:Apache License
private void populateRDS() throws AmazonClientException { for (Region region : getRegions()) { try {/*from ww w . j a v a 2s . c o m*/ if (region.isServiceSupported(ServiceAbbreviations.RDS)) { AmazonRDSClient rds = new AmazonRDSClient(getCredentials().getCredentials()); rds.setRegion(region); DescribeDBInstancesResult result = rds.describeDBInstances(); List<DBInstance> instances = result.getDBInstances(); getLogger().info("RDS, Adding " + instances.size() + " instances from " + region.getName()); for (DBInstance i : instances) { LocalRDSService temp; if (i.getDBName() != null) { temp = new LocalRDSService(i.getDBName(), getCredentials(), region, i, getLogger()); } else { temp = new LocalRDSService(i.getDBInstanceIdentifier(), getCredentials(), region, i, getLogger()); } if (servicePricings != null && servicePricings.size() > 0) { if (servicePricings.get(region).getRDSPricing() != null) { temp.attachPricing(servicePricings.get(region).getRDSPricing()); } } services.add(temp); } } else { getLogger().info("RDS, NOPE from " + region.getName()); } } catch (AmazonClientException e) { throw new AmazonClientException(region.getName() + " " + e.getMessage()); } completed.set(completed.get() + 1); } }
From source file:fr.xebia.cloud.amazon.aws.tools.AmazonAwsUtils.java
License:Apache License
/** * <p>//from www.j a v a 2s. c o m * Wait for the database creation and returns a {@link DBInstance} with up * to date values. * </p> * <p> * Note: some information are missing of the {@link DBInstance} returned by * {@link AmazonRDS#describeDBInstances(DescribeDBInstancesRequest)} as long * as the instance is "creating" rather than "available" (e.g. * {@link DBInstance#getEndpoint()} that holds the ip address). * </p> * * @param dbInstance * @param rds * @return up to date 'available' dbInstance * @throws DBInstanceNotFoundException the given <code>dbInstance</code> no longer exists (e.g. it * has been destroyed, etc). */ @Nonnull public static DBInstance awaitForDbInstanceCreation(@Nonnull DBInstance dbInstance, @Nonnull AmazonRDS rds) throws DBInstanceNotFoundException { logger.info( "Get Instance " + dbInstance.getDBInstanceIdentifier() + "/" + dbInstance.getDBName() + " status"); while (!"available".equals(dbInstance.getDBInstanceStatus())) { logger.info("Instance " + dbInstance.getDBInstanceIdentifier() + "/" + dbInstance.getDBName() + " not yet available, sleep..."); try { // 20 s because MySQL creation takes much more than 60s Thread.sleep(20 * 1000); } catch (InterruptedException e) { throw Throwables.propagate(e); } DescribeDBInstancesRequest describeDbInstanceRequest = new DescribeDBInstancesRequest() .withDBInstanceIdentifier(dbInstance.getDBInstanceIdentifier()); DescribeDBInstancesResult describeDBInstancesResult = rds .describeDBInstances(describeDbInstanceRequest); List<DBInstance> dbInstances = describeDBInstancesResult.getDBInstances(); Preconditions.checkState(dbInstances.size() == 1, "Exactly 1 db instance expected : %S", dbInstances); dbInstance = Iterables.getFirst(dbInstances, null); } return dbInstance; }
From source file:fr.xebia.demo.amazon.aws.AmazonAwsInfrastructureMaker.java
License:Apache License
public DBInstance awaitForDbInstanceCreation(DBInstance dbInstance) { int counter = 0; while (!"available".equals(dbInstance.getDBInstanceStatus())) { if (counter > 0) { System.out.println("Instance " + dbInstance.getDBInstanceIdentifier() + "/" + dbInstance.getDBName() + " not yet available"); try { Thread.sleep(20 * 1000); } catch (InterruptedException e) { e.printStackTrace();// ww w . jav a 2 s.c o m } } DescribeDBInstancesRequest describeDbInstanceRequest = new DescribeDBInstancesRequest() .withDBInstanceIdentifier(dbInstance.getDBInstanceIdentifier()); DescribeDBInstancesResult describeDBInstancesResult = rds .describeDBInstances(describeDbInstanceRequest); List<DBInstance> dbInstances = describeDBInstancesResult.getDBInstances(); Preconditions.checkState(dbInstances.size() == 1, "Exactly 1 db instance expected : %S", dbInstances); dbInstance = Iterables.getFirst(dbInstances, null); } return dbInstance; }
From source file:fr.xebia.demo.amazon.aws.AmazonAwsInfrastructureMaker.java
License:Apache License
/** * Returns a base-64 version of the mime-multi-part user-data file. * //from w w w .j a va 2 s. c o m * @param distribution * @param dbInstance * @param jdbcUsername * @param jdbcPassword * @param warUrl * @return */ protected String buildUserData(Distribution distribution, DBInstance dbInstance, String jdbcUsername, String jdbcPassword, String warUrl) { // USER DATA SHELL SCRIPT Map<String, Object> rootMap = Maps.newHashMap(); rootMap.put("catalinaBase", distribution.getCatalinaBase()); rootMap.put("warUrl", warUrl); String warName = Iterables.getLast(Splitter.on("/").split(warUrl)); rootMap.put("warName", warName); Map<String, String> systemProperties = Maps.newHashMap(); rootMap.put("systemProperties", systemProperties); String jdbcUrl = "jdbc:mysql://" + dbInstance.getEndpoint().getAddress() + ":" + dbInstance.getEndpoint().getPort() + "/" + dbInstance.getDBName(); systemProperties.put("jdbc.url", jdbcUrl); systemProperties.put("jdbc.username", jdbcUsername); systemProperties.put("jdbc.password", jdbcPassword); String shellScript = FreemarkerUtils.generate(rootMap, "/provision_tomcat.py.fmt"); // USER DATA CLOUD CONFIG InputStream cloudConfigAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream(distribution.getCloudConfigFilePath()); Preconditions.checkNotNull(cloudConfigAsStream, "'" + distribution.getCloudConfigFilePath() + "' not found in path"); Readable cloudConfig = new InputStreamReader(cloudConfigAsStream); return CloudInitUserDataBuilder.start() // .addShellScript(shellScript) // .addCloudConfig(cloudConfig) // .buildBase64UserData(); }
From source file:fr.xebia.demo.amazon.aws.PetclinicInfrastructureEnforcer.java
License:Apache License
/** * <p>//from ww w . jav a2 s .com * Wait for the database creation and returns a {@link DBInstance} with up * to date values. * </p> * <p> * Note: some information are missing of the {@link DBInstance} returned by * {@link AmazonRDS#describeDBInstances(DescribeDBInstancesRequest)} as long * as the instance is "creating" rather than "available" (e.g. * {@link DBInstance#getEndpoint()} that holds the ip address). * </p> * * @param dbInstance * @return up to date 'available' dbInstance * @throws DBInstanceNotFoundException * the given <code>dbInstance</code> no longer exists (e.g. it * has been destroyed, etc). */ @Nonnull public DBInstance awaitForDbInstanceCreation(@Nonnull DBInstance dbInstance) throws DBInstanceNotFoundException { LOGGER.info("Get Instance {}/{} status", dbInstance.getDBInstanceIdentifier(), dbInstance.getDBName()); while (!"available".equals(dbInstance.getDBInstanceStatus())) { LOGGER.info("Instance {}/{} not yet available, sleep...", dbInstance.getDBInstanceIdentifier(), dbInstance.getDBName()); try { // 20 s because MySQL creation takes much more than 60s Thread.sleep(20 * 1000); } catch (InterruptedException e) { throw Throwables.propagate(e); } DescribeDBInstancesRequest describeDbInstanceRequest = new DescribeDBInstancesRequest() .withDBInstanceIdentifier(dbInstance.getDBInstanceIdentifier()); DescribeDBInstancesResult describeDBInstancesResult = rds .describeDBInstances(describeDbInstanceRequest); List<DBInstance> dbInstances = describeDBInstancesResult.getDBInstances(); Preconditions.checkState(dbInstances.size() == 1, "Exactly 1 db instance expected : %S", dbInstances); dbInstance = Iterables.getFirst(dbInstances, null); } return dbInstance; }
From source file:fr.xebia.demo.amazon.aws.PetclinicInfrastructureEnforcer.java
License:Apache License
/** * Returns a base-64 version of the mime-multi-part cloud-init file to put * in the user-data attribute of the ec2 instance. * /*ww w.ja va 2 s .c o m*/ * @param distribution * @param dbInstance * @param jdbcUsername * @param jdbcPassword * @param warUrl * @return */ @Nonnull protected String buildCloudInitUserData(Distribution distribution, DBInstance dbInstance, String jdbcUsername, String jdbcPassword, String warUrl, String rootContext) { // SHELL SCRIPT Map<String, Object> rootMap = Maps.newHashMap(); rootMap.put("catalinaBase", distribution.getCatalinaBase()); rootMap.put("warUrl", warUrl); rootMap.put("warName", rootContext + ".war"); Map<String, String> systemProperties = Maps.newHashMap(); rootMap.put("systemProperties", systemProperties); String jdbcUrl = "jdbc:mysql://" + dbInstance.getEndpoint().getAddress() + ":" + dbInstance.getEndpoint().getPort() + "/" + dbInstance.getDBName(); systemProperties.put("jdbc.url", jdbcUrl); systemProperties.put("jdbc.username", jdbcUsername); systemProperties.put("jdbc.password", jdbcPassword); String shellScript = FreemarkerUtils.generate(rootMap, "/provision_tomcat.py.fmt"); // CLOUD CONFIG InputStream cloudConfigAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream(distribution.getCloudConfigFilePath()); Preconditions.checkNotNull(cloudConfigAsStream, "'" + distribution.getCloudConfigFilePath() + "' not found in path"); Readable cloudConfig = new InputStreamReader(cloudConfigAsStream); return CloudInitUserDataBuilder.start() // .addShellScript(shellScript) // .addCloudConfig(cloudConfig) // .buildBase64UserData(); }