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


Java AmazonRDSClient类代码示例

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


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

示例1: validate

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
@Override
public void validate(String name, Configured configuration,
    PluginExceptionConditionAccumulator accumulator,
    LocalizationContext localizationContext) {

  AmazonRDSClient client = provider.getClient();

  boolean isValidIdentifier = checkIdentifierFormat(name, accumulator, NAME, localizationContext);
  if (isValidIdentifier) {
    checkIdentifierUniqueness(client, name, NAME, accumulator, localizationContext);
  }
  checkMasterUserPassword(configuration, accumulator, localizationContext);
  checkEngine(client, configuration, accumulator, localizationContext);
  checkInstanceClass(configuration, accumulator, localizationContext);
  checkAllocatedStorage(configuration, accumulator, localizationContext);
  checkDBSubnetGroupName(client, configuration, accumulator, localizationContext);
  checkStorageEncryption(configuration, accumulator, localizationContext);
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:19,代码来源:RDSInstanceTemplateConfigurationValidator.java

示例2: checkMultiAz

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
@VisibleForTesting
void checkMultiAz(AmazonRDSClient client,
    Configured configuration,
    PluginExceptionConditionAccumulator accumulator,
    LocalizationContext localizationContext) {

  String multiAzString = configuration.getConfigurationValue(MULTI_AZ, localizationContext);
  if (multiAzString != null) {
    boolean multiAz = Boolean.parseBoolean(multiAzString);

    if (multiAz) {
      // Illegal to set Availability Zone if creating Multi-AZ deployment.
      String availabilityZone =
          configuration.getConfigurationValue(AVAILABILITY_ZONE, localizationContext);
      if (availabilityZone != null) {
        addError(accumulator, AVAILABILITY_ZONE, localizationContext,
            null, AVAILABILITY_ZONE_NOT_ALLOWED_FOR_MULTI_AZ, availabilityZone);
      }
    }
  }
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:22,代码来源:RDSInstanceTemplateConfigurationValidator.java

示例3: amazonRDS

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

示例4: parseInternal_readReplicaSupportEnabled_configuresReadReplicaEnabledFactoryBean

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

示例5: amazonRDS

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

示例6: createSnapshot

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

示例7: describeInstance

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

示例8: getSnapshotStatus

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

示例9: makeRegionalRdsClient

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
/**
 * Constructs an AmazonRDSClient and sets the region.
 */
public AmazonRDSClient makeRegionalRdsClient()
{
  AWSCredentials credentials = new BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey);
  AmazonRDSClient rds = new AmazonRDSClient(credentials);
  rds.setRegion(awsRegion);
  return rds;
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:11,代码来源:AwsClientFactory.java

示例10: testMakeRegionalRDSClient

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
/**
 * Tests that we can make an rds client.
 */
@Test
public void testMakeRegionalRDSClient()
{
  AmazonRDSClient rds = awsClientFactory.makeRegionalRdsClient();
  assertEquals(ServiceAbbreviations.RDS, rds.getServiceName());
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:10,代码来源:AwsClientFactoryTest.java

示例11: buildAmazonPoolConfig

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
public HikariConfig buildAmazonPoolConfig(final AmazonRDSClient amazonRds) {
    final DBInstance dbInstance = getDbInstance(amazonRds, rdsInstanceId);
    final HikariConfig hikariConfig = getCommonConfig();

    hikariConfig.setUsername(username);
    hikariConfig.setPassword(password);
    hikariConfig.setJdbcUrl("jdbc:postgresql://" +
            dbInstance.getEndpoint().getAddress() + ":" +
            dbInstance.getEndpoint().getPort() + "/" +
            "riistakeskus");

    return hikariConfig;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:14,代码来源:DataSourceProperties.java

示例12: getDbInstance

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
private static DBInstance getDbInstance(final AmazonRDSClient amazonRds, final String rdsInstanceId) {
    try {
        final DescribeDBInstancesRequest request = new DescribeDBInstancesRequest()
                .withDBInstanceIdentifier(rdsInstanceId);
        final DescribeDBInstancesResult response = amazonRds.describeDBInstances(request);

        return response.getDBInstances().get(0);

    } catch (DBInstanceNotFoundException e) {
        throw new IllegalStateException("Could not find DB instance!");
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:13,代码来源:DataSourceProperties.java

示例13: dataSource

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
@Bean(destroyMethod = "close")
public DataSource dataSource(
        final DataSourceProperties dataSourceProperties,
        final AWSCredentialsProvider credentialsProvider,
        final RegionProvider regionProvider) {
    final AmazonRDSClient amazonRds = new AmazonRDSClient(credentialsProvider);
    amazonRds.setRegion(regionProvider.getRegion());

    return new HikariDataSource(dataSourceProperties.buildAmazonPoolConfig(amazonRds));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:11,代码来源:DataSourceConfig.java

示例14: run

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
@Scheduled(fixedRate = 300_000)
public void run() {
    for (final String accountId : allAccountIds.get()) {
        for (final String region : jobsProperties.getWhitelistedRegions()) {
            try {
                final AmazonRDSClient amazonRDSClient = clientProvider.getClient(AmazonRDSClient.class, accountId,
                        Region.getRegion(Regions.fromName(region)));

                Optional<String> marker = Optional.empty();

                do {
                    final DescribeDBInstancesRequest request = new DescribeDBInstancesRequest();
                    marker.ifPresent(request::setMarker);
                    final DescribeDBInstancesResult result = amazonRDSClient.describeDBInstances(request);
                    marker = Optional.ofNullable(trimToNull(result.getMarker()));

                    result.getDBInstances().stream()
                            .filter(DBInstance::getPubliclyAccessible)
                            .filter(dbInstance -> dbInstance.getEndpoint() != null)
                            .forEach(dbInstance -> {
                                final Map<String, Object> metadata = newHashMap();
                                metadata.put("unsecuredDatabase", dbInstance.getEndpoint().getAddress());
                                metadata.put("errorMessages", "Unsecured Database! Your DB can be reached from outside");
                                writeViolation(accountId, region, metadata, dbInstance.getEndpoint().getAddress());

                            });

                } while (marker.isPresent());

            } catch (final Exception e) {
                jobExceptionHandler.onException(e, ImmutableMap.of(
                        "job", this.getClass().getSimpleName(),
                        "aws_account_id", accountId,
                        "aws_region", region));
            }
        }
    }
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:39,代码来源:FetchRdsJob.java

示例15: setUp

import com.amazonaws.services.rds.AmazonRDSClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.clientProviderMock = mock(ClientProvider.class);
    this.jobsPropertiesMock = mock(JobsProperties.class);
    this.violationSinkMock = mock(ViolationSink.class);
    this.amazonRDSClientMock = mock(AmazonRDSClient.class);
    this.accountIdSupplierMock = mock(AccountIdSupplier.class);
    this.exceptionHandlerMock = mock(JobExceptionHandler.class);

    when(accountIdSupplierMock.get()).thenReturn(newHashSet("54321"));

    // Jobsproperties
    when(jobsPropertiesMock.getWhitelistedRegions()).thenReturn(newArrayList("eu-west-1"));

    // Dbinstances
    final Endpoint endpoint = new Endpoint();
    endpoint.setAddress("aws.db.cn");
    final Endpoint endpoint2 = new Endpoint();
    endpoint2.setAddress("aws.db2.cn");
    final DBInstance dbInstance1 = new DBInstance();
    dbInstance1.setPubliclyAccessible(true);
    dbInstance1.setEndpoint(endpoint);
    final DBInstance dbInstance2 = new DBInstance();
    dbInstance2.setPubliclyAccessible(false);
    dbInstance2.setEndpoint(endpoint);
    final DBInstance dbInstance3 = new DBInstance();
    dbInstance3.setPubliclyAccessible(true);
    dbInstance3.setEndpoint(endpoint2);
    describeDBInstancesResultMock = new DescribeDBInstancesResult();
    describeDBInstancesResultMock.setDBInstances(newArrayList(dbInstance1, dbInstance2, dbInstance3));

    // clientprovider
    when(clientProviderMock.getClient(any(), any(String.class), any(Region.class))).thenReturn(amazonRDSClientMock);

}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:36,代码来源:FetchRdsJobTest.java


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