Example usage for com.amazonaws.services.autoscaling AmazonAutoScalingClient setRegion

List of usage examples for com.amazonaws.services.autoscaling AmazonAutoScalingClient setRegion

Introduction

In this page you can find the example usage for com.amazonaws.services.autoscaling AmazonAutoScalingClient setRegion.

Prototype

@Deprecated
void setRegion(Region region);

Source Link

Document

An alternative to AmazonAutoScaling#setEndpoint(String) , sets the regional endpoint for this client's service calls.

Usage

From source file:com.bodybuilding.turbine.discovery.AsgTagInstanceDiscovery.java

License:Apache License

protected AsgTagInstanceDiscovery(AmazonAutoScalingClient asgClient, AmazonEC2Client ec2Client) {
    Preconditions.checkNotNull(asgClient);
    Preconditions.checkNotNull(ec2Client);
    Preconditions.checkState(!Strings.isNullOrEmpty(CLUSTER_TAG_KEY.get()),
            TAG_PROPERTY_NAME + " must be supplied!");
    this.asgClient = asgClient;
    this.ec2Client = ec2Client;

    String regionName = DynamicPropertyFactory.getInstance().getStringProperty("turbine.region", "").get();
    if (Strings.isNullOrEmpty(regionName)) {
        Region currentRegion = Regions.getCurrentRegion();
        if (currentRegion != null) {
            regionName = currentRegion.getName();
        } else {//from  www . ja  va2  s  . co  m
            regionName = "us-east-1";
        }
    }
    Region region = Region.getRegion(Regions.fromName(regionName));
    ec2Client.setRegion(region);
    asgClient.setRegion(region);
    log.debug("Set the region to [{}]", region);
}

From source file:org.apache.gobblin.aws.AWSSdkClient.java

License:Apache License

/***
 * Initialize the AWS SDK Client/*from   w w w  .j av  a2s .com*/
 *
 * @param awsClusterSecurityManager The {@link AWSClusterSecurityManager} to fetch AWS credentials
 * @param region The Amazon AWS {@link Region}
 */
public AWSSdkClient(final AWSClusterSecurityManager awsClusterSecurityManager, final Region region) {
    this.amazonEC2Supplier = Suppliers.memoize(new Supplier<AmazonEC2>() {
        @Override
        public AmazonEC2 get() {
            AmazonEC2Client amazonEC2 = new AmazonEC2Client(awsClusterSecurityManager.getCredentialsProvider());
            amazonEC2.setRegion(region);
            return amazonEC2;
        }
    });
    this.amazonS3Supplier = Suppliers.memoize(new Supplier<AmazonS3>() {
        @Override
        public AmazonS3 get() {
            AmazonS3Client amazonS3 = new AmazonS3Client(awsClusterSecurityManager.getCredentialsProvider());
            amazonS3.setRegion(region);
            return amazonS3;
        }
    });
    this.amazonAutoScalingSupplier = Suppliers.memoize(new Supplier<AmazonAutoScaling>() {
        @Override
        public AmazonAutoScaling get() {
            AmazonAutoScalingClient amazonAutoScaling = new AmazonAutoScalingClient(
                    awsClusterSecurityManager.getCredentialsProvider());
            amazonAutoScaling.setRegion(region);
            return amazonAutoScaling;
        }
    });
}