本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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 );
}
}
}
}
示例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;
}
示例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");
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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 "";
}
示例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;
}
示例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 );
}
示例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);
}
}