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


Java AmazonRDS类代码示例

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


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

示例1: afterPropertiesSet_noInstanceFound_reportsIllegalStateException

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
@Test
public void afterPropertiesSet_noInstanceFound_reportsIllegalStateException() throws Exception {
    //Arrange
    this.expectedException.expect(IllegalStateException.class);
    this.expectedException.expectMessage("No database instance with id:'test'");

    AmazonRDS amazonRDS = mock(AmazonRDS.class);
    when(amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).thenThrow(new DBInstanceNotFoundException("foo"));

    AmazonRdsDataSourceFactoryBean amazonRdsDataSourceFactoryBean = new AmazonRdsDataSourceFactoryBean(amazonRDS, "test", "foo");

    //Act
    amazonRdsDataSourceFactoryBean.afterPropertiesSet();

    //Assert
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:17,代码来源:AmazonRdsDataSourceFactoryBeanTest.java

示例2: amazonRDS

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的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

示例3: parseInternal_readReplicaSupportEnabled_configuresReadReplicaEnabledFactoryBean

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
@Test
public void parseInternal_readReplicaSupportEnabled_configuresReadReplicaEnabledFactoryBean() throws Exception {

    //Arrange
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

    BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(Mockito.class);
    beanDefinitionBuilder.setFactoryMethod("mock");
    beanDefinitionBuilder.addConstructorArgValue(AmazonRDS.class);
    beanFactory.registerBeanDefinition(AmazonWebserviceClientConfigurationUtils.getBeanName(AmazonRDSClient.class.getName()), beanDefinitionBuilder.getBeanDefinition());

    XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
    xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-readReplicaEnabled.xml", getClass()));

    //Act
    BeanDefinition beanDefinition = beanFactory.getBeanDefinition("test");

    //Assert
    assertEquals(AmazonRdsReadReplicaAwareDataSourceFactoryBean.class.getName(), beanDefinition.getBeanClassName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:21,代码来源:AmazonRdsDataSourceBeanDefinitionParserTest.java

示例4: parseInternal_customRegionConfigured_amazonRdsClientWithCustomRegionConfigured

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
@Test
public void parseInternal_customRegionConfigured_amazonRdsClientWithCustomRegionConfigured() throws Exception {

    //Arrange
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

    XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
    xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-customRegion.xml", getClass()));

    //Act
    AmazonRDS amazonRDS = beanFactory.getBean(AmazonRDS.class);

    //Assert
    //have to use reflection utils
    assertEquals("https://rds.eu-west-1.amazonaws.com", ReflectionTestUtils.getField(amazonRDS, "endpoint").toString());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:17,代码来源:AmazonRdsDataSourceBeanDefinitionParserTest.java

示例5: DefaultListableBeanFactory

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
@Test
public void parseInternal_customRegionProviderConfigured_amazonRdsClientWithCustomRegionConfiguredThatIsReturnedFromRegionProvider() throws Exception {

    //Arrange
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

    XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
    xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-customRegionProvider.xml", getClass()));

    //Act
    AmazonRDS amazonRDS = beanFactory.getBean(AmazonRDS.class);

    //Assert
    //have to use reflection utils
    assertEquals("https://rds.eu-west-1.amazonaws.com", ReflectionTestUtils.getField(amazonRDS, "endpoint").toString());

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:18,代码来源:AmazonRdsDataSourceBeanDefinitionParserTest.java

示例6: canRetry_retryPossibleDueToAvailableDatabase_returnsTrue

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的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

示例7: canRetry_withResourceIdResolver_returnsTrue

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的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

示例8: canRetry_retryNotPossibleDueToNoDatabase_returnsFalse

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

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

    when(amazonRDS.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).
            thenThrow(new DBInstanceNotFoundException("test"));

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

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

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

示例9: canRetry_multipleDatabasesFoundForInstanceIdentifier_reportsException

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的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

示例10: beforeEachTestRuns

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
@Before
public void beforeEachTestRuns() {
	AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
	AmazonEC2 ec2Client = EnvironmentSetupForTests.createEC2Client();
	AmazonElasticLoadBalancing awsElbClient = EnvironmentSetupForTests.createELBClient();
	AmazonCloudFormation cfnClient = EnvironmentSetupForTests.createCFNClient();
	AmazonRDS awsRdsClient = EnvironmentSetupForTests.createRDSClient();

	CloudClient cloudClient = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain());
	LoadBalancerClient elbClient = new LoadBalancerClient(awsElbClient);
	VpcRepository vpcRepository = new VpcRepository(cloudClient);

	CloudFormationClient cloudFormationClient = new CloudFormationClient(cfnClient);
	cloudRepository = new CloudRepository(cloudClient);
	ResourceRepository cfnRepository = new CfnRepository(cloudFormationClient, cloudRepository, "CfnAssist");
	
	elbRepository = new ELBRepository(elbClient, vpcRepository, cfnRepository);
	rdsClient = new RDSClient(awsRdsClient);
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:20,代码来源:TestPictureGeneration.java

示例11: createSnapshot

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
/**
 * @inheritDoc
 */
@Override
public void createSnapshot( String snapshotName, String instanceName,
                            Identity identity )
{
    AmazonRDS rds =
        ActivityUtils.createClient( AmazonRDSClient.class, identity );
    try
    {
        rds.describeDBSnapshots( new DescribeDBSnapshotsRequest().withDBSnapshotIdentifier( snapshotName ) );
        return;
    }
    catch ( DBSnapshotNotFoundException e )
    {
    }
    rds.createDBSnapshot( new CreateDBSnapshotRequest( snapshotName,
                                                       instanceName ) );
}
 
开发者ID:jiaqi,项目名称:datamung,代码行数:21,代码来源:RdsActivitiesImpl.java

示例12: describeInstance

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的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

示例13: getSnapshotStatus

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
/**
 * @inheritDoc
 */
@Override
public String getSnapshotStatus( String snapshotName, Identity identity )
{
    AmazonRDS rds =
        ActivityUtils.createClient( AmazonRDSClient.class, identity );
    try
    {
        DescribeDBSnapshotsResult result =
            rds.describeDBSnapshots( new DescribeDBSnapshotsRequest().withDBSnapshotIdentifier( snapshotName ) );
        return result.getDBSnapshots().get( 0 ).getStatus();
    }
    catch ( DBSnapshotNotFoundException e )
    {
        return null;
    }
}
 
开发者ID:jiaqi,项目名称:datamung,代码行数:20,代码来源:RdsActivitiesImpl.java

示例14: getReplicaInstances

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
public static Set<String> getReplicaInstances( AmazonRDS rdsClient ) {
	DescribeDBClustersResult dbClusterResults = rdsClient.describeDBClusters();
	Set<String> replicas = new HashSet<>();
	for ( DBCluster cluster : dbClusterResults.getDBClusters() ) {
		for ( DBClusterMember member : cluster.getDBClusterMembers() ) {
			if ( !member.getIsClusterWriter() ) {
				replicas.add( member.getDBInstanceIdentifier() );
			}
		}
	}
	return replicas;
}
 
开发者ID:CodeArcsInc,项目名称:candlestack,代码行数:13,代码来源:RDSUtil.java

示例15: scanRDS

import com.amazonaws.services.rds.AmazonRDS; //导入依赖的package包/类
/**
 * Collect data for RDS.
 *
 * @param stats
 *            current statistics object.
 * @param account
 *            currently used credentials object.
 * @param region
 *            currently used aws region.
 */
public static void scanRDS(AwsStats stats, AwsAccount account, Regions region) {
	LOG.debug("Scan for RDS in region " + region.getName() + " in account " + account.getAccountId());

	try {
		AmazonRDS rds = new AmazonRDSClient(account.getCredentials());
		rds.setRegion(Region.getRegion(region));

		List<DBInstance> list = rds.describeDBInstances().getDBInstances();

		int totalItems = list.size();
		for (DBInstance dbInstance : list) {
			AwsResource res = new AwsResource(dbInstance.getDBName(), account.getAccountId(), AwsResourceType.RDS, region);
			res.addInfo("DBInstanceIdentifier", dbInstance.getDBInstanceIdentifier());
			stats.add(res);
		}

		LOG.info(totalItems + " RDS instances in region " + region.getName() + " in account " + account.getAccountId());
	} catch (AmazonServiceException ase) {
		LOG.error("Exception of RDS: " + ase.getMessage());
	}
}
 
开发者ID:janloeffler,项目名称:aws-utilization-monitor,代码行数:32,代码来源:AwsScan.java


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