当前位置: 首页>>代码示例>>Java>>正文


Java DescribeDBInstancesResult类代码示例

本文整理汇总了Java中com.amazonaws.services.rds.model.DescribeDBInstancesResult的典型用法代码示例。如果您正苦于以下问题:Java DescribeDBInstancesResult类的具体用法?Java DescribeDBInstancesResult怎么用?Java DescribeDBInstancesResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DescribeDBInstancesResult类属于com.amazonaws.services.rds.model包,在下文中一共展示了DescribeDBInstancesResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRDSInstances

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
private void getRDSInstances() {
	DescribeDBInstancesResult response = rdsClient.describeDBInstances(new DescribeDBInstancesRequest());
	
	List<PulseInstance> rds = new ArrayList<PulseInstance>();

	PulseInstance pulse = null;
	for (DBInstance instance : response.getDBInstances()) {
		ListTagsForResourceResult result = rdsClient.listTagsForResource(new ListTagsForResourceRequest().withResourceName(instance.getDBInstanceArn()));
		
		for (com.amazonaws.services.rds.model.Tag tag : result.getTagList()) {
			if (tag.getKey().equals(properties.getTag()) && (tag.getValue().equals("TRUE") || tag.getValue().equals("True") || tag.getValue().equals("true"))) {
				pulse = new PulseInstance();
				pulse.setId(instance.getDBInstanceIdentifier());
				pulse.setName(instance.getDBInstanceIdentifier());
				pulse.setAddress(instance.getEndpoint().getAddress());
				pulse.setType(instance.getDBInstanceClass());
				
				rds.add(pulse);
			}
		}
	}
	
	GetMonitoringInstances.rds = rds;
}
 
开发者ID:nices96,项目名称:scouter-pulse-aws-monitor,代码行数:25,代码来源:GetMonitoringInstances.java

示例2: makeDescribeDBInstancesResult

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
/**
 * Test helper - makes describe result with a named instance.
 */
private DescribeDBInstancesResult makeDescribeDBInstancesResult(String... instanceNames)
{
  DescribeDBInstancesResult result = new DescribeDBInstancesResult();
  List<DBInstance> dbInstances = new ArrayList<DBInstance>();
  if (ArrayUtils.isNotEmpty(instanceNames))
  {
    for (String instanceName : instanceNames)
    {
      DBInstance dbInstance = new DBInstance();
      dbInstance.setDBInstanceIdentifier(instanceName);
      dbInstances.add(dbInstance);
    }
  }
  result.setDBInstances(dbInstances);
  return result;
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:20,代码来源:RdsClientTest.java

示例3: describe

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
public void describe(String dbInstanceIdentifier) throws Exception {
    while (true) {
        DescribeDBInstancesRequest request = new DescribeDBInstancesRequest()
                .withDBInstanceIdentifier(dbInstanceIdentifier);

        DescribeDBInstancesResult response = client.describeDBInstances(request);
        DBInstance dbInstance = response.getDBInstances().get(0);
        if (!dbInstance.getDBInstanceStatus().equalsIgnoreCase("creating")) {
            System.out.println("Done! " + response);
            System.out.println(dbInstance.getEndpoint().getAddress());
            System.out.println(dbInstance.getEndpoint().getPort());
            break;
        }

        System.out.println("Not done - will wait 10s: " + response);
        Thread.sleep(10000L);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:19,代码来源:CreateDbInstance.java

示例4: fetchInstanceMetrics

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
private void fetchInstanceMetrics() throws CandlestackAWSException, CandlestackException {
	Set<String> replicaInstances = RDSUtil.getReplicaInstances( rdsClient );

	DescribeDBInstancesResult dbInstanceResults = rdsClient.describeDBInstances();
	for ( DBInstance dbInstance : dbInstanceResults.getDBInstances() ) {

		String dbInstanceId = dbInstance.getDBInstanceIdentifier();
		RDSType rdsType = RDSType.getTypeFromEngine( dbInstance.getEngine() );
		if ( !RDSUtil.isDBInstanceEligible( dbInstanceId, dbInstancePrefix, dbInstanceRegex, rdsType ) ) {
			continue;
		}

		for ( RDSCloudWatchMetric cloudWatchMetric : cloudWatchMetrics ) {
			if ( cloudWatchMetric.isRDSTypeSupported( rdsType ) && !cloudWatchMetric.isClusterOnlyMetric() && ( !cloudWatchMetric.isReplicaOnlyMetric() || replicaInstances.contains( dbInstanceId ) ) ) {
				cloudWatchAccessor.lookupAndSaveMetricData( cloudWatchMetric, dbInstanceId, RDSUtil.TYPE_NAME );
			}
		}

	}
}
 
开发者ID:CodeArcsInc,项目名称:candlestack,代码行数:21,代码来源:RDSMetricsFetcher.java

示例5: getReadReplicaEndpoints

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
@Override
public List<Endpoint> getReadReplicaEndpoints(String dbInstanceId) {
	List<Endpoint> endpoints = null;
	
	DescribeDBInstancesResult result = rds.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceId));
	
	// If the master exist and has any read replicas
	if(result.getDBInstances().size() == 1 && result.getDBInstances().get(0).getReadReplicaDBInstanceIdentifiers().size() > 0) {
		endpoints = new ArrayList<Endpoint>();
		for(String readReplicaId : result.getDBInstances().get(0).getReadReplicaDBInstanceIdentifiers()) {
			DBInstance rrInstance = rds.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier(readReplicaId)).getDBInstances().get(0);
			if (rrInstance.getDBInstanceStatus().equals("available")) {
				endpoints.add(rrInstance.getEndpoint());
			}
		}
		if(endpoints.size() == 0) {
			endpoints = null;
		}
		
	}
	
	return endpoints;
}
 
开发者ID:awslabs,项目名称:amediamanager,代码行数:24,代码来源:RdsDbEndpointRetriever.java

示例6: isDatabaseAvailable

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
private boolean isDatabaseAvailable(RetryContext context) {
    DescribeDBInstancesResult describeDBInstancesResult;
    try {
        describeDBInstancesResult = this.amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier((String) context.getAttribute(DB_INSTANCE_ATTRIBUTE_NAME)));
    } catch (DBInstanceNotFoundException e) {
        LOGGER.warn("Database Instance with name {} has been removed or is not configured correctly, no retry possible", getDbInstanceIdentifier());
        //Database has been deleted while operating, hence we can not retry
        return false;
    }

    if (describeDBInstancesResult.getDBInstances().size() == 1) {
        DBInstance dbInstance = describeDBInstancesResult.getDBInstances().get(0);
        InstanceStatus instanceStatus = InstanceStatus.fromDatabaseStatus(dbInstance.getDBInstanceStatus());
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Status of database to be retried is {}", instanceStatus);
        }
        return instanceStatus.isRetryable();
    } else {
        throw new IllegalStateException("Multiple databases found for same identifier, this is likely an incompatibility with the Amazon SDK");
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:22,代码来源:DatabaseInstanceStatusRetryPolicy.java

示例7: amazonRDS

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
@Bean
public AmazonRDS amazonRDS() {
    AmazonRDSClient client = Mockito.mock(AmazonRDSClient.class);
    when(client.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).thenReturn(
            new DescribeDBInstancesResult().
                    withDBInstances(new DBInstance().
                            withDBInstanceStatus("available").
                            withDBName("test").
                            withDBInstanceIdentifier("test").
                            withEngine("mysql").
                            withMasterUsername("admin").
                            withEndpoint(new Endpoint().
                                    withAddress("localhost").
                                    withPort(3306)
                            ).withReadReplicaDBInstanceIdentifiers("read1")
                    )
    );
    return client;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:AmazonRdsInstanceConfigurationTest.java

示例8: canRetry_retryPossibleDueToAvailableDatabase_returnsTrue

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
@Test
public void canRetry_retryPossibleDueToAvailableDatabase_returnsTrue() throws Exception {
    //Arrange
    AmazonRDS amazonRDS = mock(AmazonRDS.class);

    DatabaseInstanceStatusRetryPolicy policy = new DatabaseInstanceStatusRetryPolicy(amazonRDS, "test");
    when(amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).
            thenReturn(new DescribeDBInstancesResult().withDBInstances(new DBInstance().withDBInstanceStatus("available")));

    RetryContext retryContext = policy.open(new RetryContextSupport(null));

    //Act
    policy.registerThrowable(retryContext, new TransientDataAccessResourceException("not available"));

    //Assert
    assertTrue(policy.canRetry(retryContext));
    policy.close(retryContext);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:DatabaseInstanceStatusRetryPolicyTest.java

示例9: canRetry_withResourceIdResolver_returnsTrue

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
@Test
public void canRetry_withResourceIdResolver_returnsTrue() throws Exception {
    //Arrange
    AmazonRDS amazonRDS = mock(AmazonRDS.class);
    ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class);

    DatabaseInstanceStatusRetryPolicy policy = new DatabaseInstanceStatusRetryPolicy(amazonRDS, "foo");
    when(amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).
            thenReturn(new DescribeDBInstancesResult().withDBInstances(new DBInstance().withDBInstanceStatus("available")));

    when(resourceIdResolver.resolveToPhysicalResourceId("foo")).thenReturn("test");

    policy.setResourceIdResolver(resourceIdResolver);


    RetryContext retryContext = policy.open(new RetryContextSupport(null));

    //Act
    policy.registerThrowable(retryContext, new TransientDataAccessResourceException("not available"));

    //Assert
    assertTrue(policy.canRetry(retryContext));
    policy.close(retryContext);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:25,代码来源:DatabaseInstanceStatusRetryPolicyTest.java

示例10: canRetry_multipleDatabasesFoundForInstanceIdentifier_reportsException

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
@Test
public void canRetry_multipleDatabasesFoundForInstanceIdentifier_reportsException() throws Exception {
    //Arrange
    this.expectedException.expect(IllegalStateException.class);
    this.expectedException.expectMessage("Multiple databases found for same identifier");

    AmazonRDS amazonRDS = mock(AmazonRDS.class);

    DatabaseInstanceStatusRetryPolicy policy = new DatabaseInstanceStatusRetryPolicy(amazonRDS, "test");

    DescribeDBInstancesResult describeDBInstancesResult = new DescribeDBInstancesResult().withDBInstances(new DBInstance(), new DBInstance());
    when(amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).
            thenReturn(describeDBInstancesResult);

    RetryContext retryContext = policy.open(new RetryContextSupport(null));

    //Act
    policy.registerThrowable(retryContext, new TransientDataAccessResourceException("not available"));

    //Assert
    policy.canRetry(retryContext);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:23,代码来源:DatabaseInstanceStatusRetryPolicyTest.java

示例11: amazonRDS

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
@Bean
public AmazonRDSClient amazonRDS() {
    AmazonRDSClient client = Mockito.mock(AmazonRDSClient.class);
    when(client.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).thenReturn(
            new DescribeDBInstancesResult().
                    withDBInstances(new DBInstance().
                            withDBInstanceStatus("available").
                            withDBName("test").
                            withDBInstanceIdentifier("test").
                            withEngine("mysql").
                            withMasterUsername("admin").
                            withEndpoint(new Endpoint().
                                    withAddress("localhost").
                                    withPort(3306)
                            ).withReadReplicaDBInstanceIdentifiers("read1")
                    )
    );
    return client;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:AmazonRdsDatabaseAutoConfigurationTest.java

示例12: getDBEndPoint

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
public String getDBEndPoint(String dbInstanceId, int timeout){
    DescribeDBInstancesRequest ddbir = new DescribeDBInstancesRequest()
            .withDBInstanceIdentifier(dbInstanceId);
    System.out.println("Waiting for DB endpoints");
    while(timeout -- > 0){
        System.out.print("-");
        DescribeDBInstancesResult ddbi = rdsClient.describeDBInstances(ddbir);
        Endpoint endpoint = ddbi.getDBInstances().get(0).getEndpoint();
        if(endpoint != null && endpoint.toString().length()!=0)
            return endpoint.getAddress()+":"+endpoint.getPort();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(BeanstalkConnector.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return "";
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:20,代码来源:BeanstalkConnector.java

示例13: getDBInstancesForVpc

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
public List<DBInstance> getDBInstancesForVpc(String vpcId) {	
	DescribeDBInstancesResult result = rdsClient.describeDBInstances();
	List<DBInstance> dbInstances = result.getDBInstances();
	
	List<DBInstance> filtered = new LinkedList<DBInstance>(); 
	for(DBInstance dbInstance : dbInstances) {
		DBSubnetGroup dbSubnetGroup = dbInstance.getDBSubnetGroup();
		if (dbSubnetGroup!=null) {
			String groupVpcId = dbSubnetGroup.getVpcId();
			if (groupVpcId.equals(vpcId)) {
				filtered.add(dbInstance);
			}
		}
	}
	return filtered;
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:17,代码来源:RDSClient.java

示例14: describeInstance

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
/**
 * @inheritDoc
 */
@Override
public DatabaseInstance describeInstance( String instanceName,
                                          Identity identity )
{
    AmazonRDS rds =
        ActivityUtils.createClient( AmazonRDSClient.class, identity );
    DescribeDBInstancesResult results =
        rds.describeDBInstances( new DescribeDBInstancesRequest().withDBInstanceIdentifier( instanceName ) );
    if ( results.getDBInstances().isEmpty() )
    {
        return null;
    }
    DBInstance result = results.getDBInstances().get( 0 );
    return toDatabaseInstance( result );
}
 
开发者ID:jiaqi,项目名称:datamung,代码行数:19,代码来源:RdsActivitiesImpl.java

示例15: describeInstance

import com.amazonaws.services.rds.model.DescribeDBInstancesResult; //导入依赖的package包/类
/**
 * Gets a description of the requested RDS instance.  Throws if not found.
 */
public DBInstance describeInstance(String instanceName)
{
  LOGGER.debug("describeDBInstances(instanceName: " + instanceName + ")");
  StopWatch stopWatch = new StopWatch();
  try
  {
    stopWatch.start();
    DescribeDBInstancesRequest request = new DescribeDBInstancesRequest();
    request.setDBInstanceIdentifier(instanceName);
    DescribeDBInstancesResult result = awsRdsClient.describeDBInstances(request);
    if (result == null || CollectionUtils.isEmpty(result.getDBInstances()))
    {
      // Note: this branch should never execute.  We expect Amazon to throw DBInstanceNotFoundException instead.
      throw new DBSnapshotNotFoundException("RDS cannot find instance '" + instanceName + "'");
    }
    else if (result.getDBInstances().size() > 1)
    {
      LOGGER.warn("Expected 1 instance named '" + instanceName + "', found " + result.getDBInstances().size());
    }
    return result.getDBInstances().get(0);
  }
  finally
  {
    stopWatch.stop();
    LOGGER.debug("describeDBInstances time elapsed: " + stopWatch);
  }
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:31,代码来源:RdsClient.java


注:本文中的com.amazonaws.services.rds.model.DescribeDBInstancesResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。