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


Java AmazonAutoScalingClient类代码示例

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


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

示例1: AsgTagInstanceDiscovery

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
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 {
            regionName = "us-east-1";
        }
    }
    Region region = Region.getRegion(Regions.fromName(regionName));
    ec2Client.setRegion(region);
    asgClient.setRegion(region);
    log.debug("Set the region to [{}]", region);
}
 
开发者ID:bbcom,项目名称:turbine-plugins,代码行数:22,代码来源:AsgTagInstanceDiscovery.java

示例2: getCloudResources

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
private List<CloudResource> getCloudResources(AuthenticatedContext ac, CloudStack stack, String cFStackName, AmazonCloudFormationClient client,
        AmazonEC2Client amazonEC2Client, AmazonAutoScalingClient amazonASClient, boolean mapPublicIpOnLaunch) {
    List<CloudResource> cloudResources = new ArrayList<>();
    AmazonCloudFormationClient cloudFormationClient = awsClient.createCloudFormationClient(new AwsCredentialView(ac.getCloudCredential()),
            ac.getCloudContext().getLocation().getRegion().value());
    scheduleStatusChecks(stack, ac, cloudFormationClient);
    suspendAutoScaling(ac, stack);
    if (mapPublicIpOnLaunch) {
        Map<String, String> eipAllocationIds = getElasticIpAllocationIds(cFStackName, client);
        List<Group> gateways = getGatewayGroups(stack.getGroups());
        for (Group gateway : gateways) {
            List<String> eips = getEipsForGatewayGroup(eipAllocationIds, gateway);
            List<String> instanceIds = getInstancesForGroup(ac, amazonASClient, client, gateway);
            associateElasticIpsToInstances(amazonEC2Client, eips, instanceIds);
        }
    }
    return cloudResources;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:19,代码来源:AwsResourceConnector.java

示例3: collect

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Override
public List<CloudVmMetaDataStatus> collect(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) {
    List<CloudVmMetaDataStatus> cloudVmMetaDataStatuses = new ArrayList<>();
    try {
        String region = ac.getCloudContext().getLocation().getRegion().value();
        AmazonCloudFormationClient amazonCFClient =
                awsClient.createCloudFormationClient(new AwsCredentialView(ac.getCloudCredential()), region);
        AmazonAutoScalingClient amazonASClient =
                awsClient.createAutoScalingClient(new AwsCredentialView(ac.getCloudCredential()), region);
        AmazonEC2Client amazonEC2Client =
                awsClient.createAccess(new AwsCredentialView(ac.getCloudCredential()), region);

        //contains all instances
        ListMultimap<String, CloudInstance> groupByInstanceGroup = groupByInstanceGroup(vms);

        for (String key : groupByInstanceGroup.keySet()) {
            List<CloudInstance> cloudInstances = groupByInstanceGroup.get(key);
            cloudVmMetaDataStatuses.addAll(collectGroupMetaData(ac, amazonASClient, amazonEC2Client, amazonCFClient, key, cloudInstances));
        }

        return cloudVmMetaDataStatuses;
    } catch (RuntimeException e) {
        throw new CloudConnectorException(e.getMessage(), e);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:26,代码来源:AwsMetadataCollector.java

示例4: AwsAutoScalingDeployUtils

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
public AwsAutoScalingDeployUtils(String region, DeployConfiguration activeConfiguration, Log log) {
    this.activeConfiguration = activeConfiguration;
    this.log = log;

    Region awsRegion = Region.getRegion(Regions.fromName(region));
    awsAsClient = new AmazonAutoScalingClient();
    awsAsClient.setRegion(awsRegion);

    awsElbClient = new AmazonElasticLoadBalancingClient();
    awsElbClient.setRegion(awsRegion);

    awsEc2Client = new AmazonEC2Client();
    awsEc2Client.setRegion(awsRegion);

    activeConfiguration.withAutoScalingGroup(matchAutoScalingGroupName(activeConfiguration.getAutoScalingGroupId()));

}
 
开发者ID:msoute,项目名称:vertx-deploy-tools,代码行数:18,代码来源:AwsAutoScalingDeployUtils.java

示例5: configure

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
/**
 * Binds all the Amazon services used.
 */
@Override
protected void configure() {
    final Region region = Region.getRegion(Regions.fromName(regionName));
    bind(AmazonEC2.class).toInstance(createAmazonClientInstance(AmazonEC2Client.class, region));
    bind(AmazonCloudFormation.class).toInstance(createAmazonClientInstance(AmazonCloudFormationClient.class, region));
    bind(AmazonIdentityManagement.class).toInstance(createAmazonClientInstance(AmazonIdentityManagementClient.class, region));
    bind(AWSKMS.class).toInstance(createAmazonClientInstance(AWSKMSClient.class, region));
    bind(AmazonS3.class).toInstance(createAmazonClientInstance(AmazonS3Client.class, region));
    bind(AmazonAutoScaling.class).toInstance(createAmazonClientInstance(AmazonAutoScalingClient.class, region));
    bind(AWSSecurityTokenService.class).toInstance(createAmazonClientInstance(AWSSecurityTokenServiceClient.class, region));
    bind(AWSLambda.class).toInstance(createAmazonClientInstance(AWSLambdaClient.class, region));
    bind(AmazonSNS.class).toInstance(createAmazonClientInstance(AmazonSNSClient.class, region));
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:17,代码来源:CerberusModule.java

示例6: AWSSdkClient

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
/***
 * Initialize the AWS SDK Client
 *
 * @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;
    }
  });
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:34,代码来源:AWSSdkClient.java

示例7: getClient

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Override
public AmazonAutoScalingClient getClient() {
  AmazonAutoScalingClient client = new AmazonAutoScalingClient(new Aws().getAwsCredentials());

  String region = getUserProperty(AWS_REGION);
  String endpoint = "https://autoscaling." + region + ".amazonaws.com"; //$NON-NLS-1$ //$NON-NLS-2$

  client.setEndpoint(endpoint);

  return client;
}
 
开发者ID:tuhrig,项目名称:DeployMan,代码行数:12,代码来源:AutoScaling.java

示例8: createAmazonAutoScalingGroup

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Override
public void createAmazonAutoScalingGroup(AWSCredentials credentials, String name, int maxsize, int minsize, int coolDown, String configName,
                                         Collection<String> loadBalancerNames, Collection<com.amazonaws.services.autoscaling.model.Tag> tags) {
    AmazonAutoScalingClient amazonAutoScalingClient = amazonAutoScalingClientFactory.createAmazonAutoScalingClient(credentials);
    CreateAutoScalingGroupRequest createAutoScalingGroupRequest = new CreateAutoScalingGroupRequest().withAutoScalingGroupName(name)
            .withDefaultCooldown(coolDown).withLaunchConfigurationName(configName).withMaxSize(maxsize).withMinSize(minsize).withTags(tags)
            .withLoadBalancerNames(loadBalancerNames).withAvailabilityZones(Arrays.asList("us-west-2b"));
    amazonAutoScalingClient.createAutoScalingGroup(createAutoScalingGroupRequest);
}
 
开发者ID:sequenceiq,项目名称:sequenceiq-samples,代码行数:10,代码来源:SimpleAutoScalingService.java

示例9: updateAmazonAutoScalingGroupCoolDown

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Override
public void updateAmazonAutoScalingGroupCoolDown(AWSCredentials credentials, String name, int coolDown) {
    AmazonAutoScalingClient amazonAutoScalingClient = amazonAutoScalingClientFactory.createAmazonAutoScalingClient(credentials);
    UpdateAutoScalingGroupRequest updateAutoScalingGroupRequest = new UpdateAutoScalingGroupRequest()
            .withAutoScalingGroupName(name)
            .withDefaultCooldown(coolDown);
    amazonAutoScalingClient.updateAutoScalingGroup(updateAutoScalingGroupRequest);
}
 
开发者ID:sequenceiq,项目名称:sequenceiq-samples,代码行数:9,代码来源:SimpleAutoScalingService.java

示例10: updateAmazonAutoScalingGroupMaxSize

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Override
public void updateAmazonAutoScalingGroupMaxSize(AWSCredentials credentials, String name, int maxSize) {
    AmazonAutoScalingClient amazonAutoScalingClient = amazonAutoScalingClientFactory.createAmazonAutoScalingClient(credentials);
    UpdateAutoScalingGroupRequest updateAutoScalingGroupRequest = new UpdateAutoScalingGroupRequest()
            .withAutoScalingGroupName(name)
            .withMaxSize(maxSize);
    amazonAutoScalingClient.updateAutoScalingGroup(updateAutoScalingGroupRequest);
}
 
开发者ID:sequenceiq,项目名称:sequenceiq-samples,代码行数:9,代码来源:SimpleAutoScalingService.java

示例11: updateAmazonAutoScalingGroupMinSize

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Override
public void updateAmazonAutoScalingGroupMinSize(AWSCredentials credentials, String name, int minSize) {
    AmazonAutoScalingClient amazonAutoScalingClient = amazonAutoScalingClientFactory.createAmazonAutoScalingClient(credentials);
    UpdateAutoScalingGroupRequest updateAutoScalingGroupRequest = new UpdateAutoScalingGroupRequest()
            .withAutoScalingGroupName(name)
            .withMinSize(minSize);
    amazonAutoScalingClient.updateAutoScalingGroup(updateAutoScalingGroupRequest);
}
 
开发者ID:sequenceiq,项目名称:sequenceiq-samples,代码行数:9,代码来源:SimpleAutoScalingService.java

示例12: suspendAutoScaling

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
private void suspendAutoScaling(AuthenticatedContext ac, CloudStack stack) {
    AmazonAutoScalingClient amazonASClient = awsClient.createAutoScalingClient(new AwsCredentialView(ac.getCloudCredential()),
            ac.getCloudContext().getLocation().getRegion().value());
    for (Group group : stack.getGroups()) {
        String asGroupName = cfStackUtil.getAutoscalingGroupName(ac, group.getName(), ac.getCloudContext().getLocation().getRegion().value());
        amazonASClient.suspendProcesses(new SuspendProcessesRequest().withAutoScalingGroupName(asGroupName).withScalingProcesses(SUSPENDED_PROCESSES));
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:9,代码来源:AwsResourceConnector.java

示例13: resumeAutoScaling

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
private void resumeAutoScaling(AuthenticatedContext ac, CloudStack stack) {
    AmazonAutoScalingClient amazonASClient = awsClient.createAutoScalingClient(new AwsCredentialView(ac.getCloudCredential()),
            ac.getCloudContext().getLocation().getRegion().value());
    for (Group group : stack.getGroups()) {
        String asGroupName = cfStackUtil.getAutoscalingGroupName(ac, group.getName(), ac.getCloudContext().getLocation().getRegion().value());
        amazonASClient.resumeProcesses(new ResumeProcessesRequest().withAutoScalingGroupName(asGroupName).withScalingProcesses(SUSPENDED_PROCESSES));
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:9,代码来源:AwsResourceConnector.java

示例14: resumeAutoScalingPolicies

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
private void resumeAutoScalingPolicies(AuthenticatedContext ac, CloudStack stack) {
    for (Group instanceGroup : stack.getGroups()) {
        try {
            String asGroupName = cfStackUtil.getAutoscalingGroupName(ac, instanceGroup.getName(), ac.getCloudContext().getLocation().getRegion().value());
            if (asGroupName != null) {
                AmazonAutoScalingClient amazonASClient = awsClient.createAutoScalingClient(new AwsCredentialView(ac.getCloudCredential()),
                        ac.getCloudContext().getLocation().getRegion().value());
                List<AutoScalingGroup> asGroups = amazonASClient.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest()
                        .withAutoScalingGroupNames(asGroupName)).getAutoScalingGroups();
                if (!asGroups.isEmpty()) {
                    if (!asGroups.get(0).getSuspendedProcesses().isEmpty()) {
                        amazonASClient.updateAutoScalingGroup(new UpdateAutoScalingGroupRequest()
                                .withAutoScalingGroupName(asGroupName)
                                .withMinSize(0)
                                .withDesiredCapacity(0));
                        amazonASClient.resumeProcesses(new ResumeProcessesRequest().withAutoScalingGroupName(asGroupName));
                    }
                }
            } else {
                LOGGER.info("Autoscaling Group's physical id is null (the resource doesn't exist), it is not needed to resume scaling policies.");
            }
        } catch (AmazonServiceException e) {
            if (e.getErrorMessage().matches("Resource.*does not exist for stack.*") || e.getErrorMessage().matches("Stack '.*' does not exist.*")) {
                LOGGER.info(e.getMessage());
            } else {
                throw e;
            }
        }
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:31,代码来源:AwsResourceConnector.java

示例15: getInstanceIds

import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
public List<String> getInstanceIds(AmazonAutoScalingClient amazonASClient, String asGroupName) {
    DescribeAutoScalingGroupsResult describeAutoScalingGroupsResult = amazonASClient
            .describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(asGroupName));
    List<String> instanceIds = new ArrayList<>();
    if (describeAutoScalingGroupsResult.getAutoScalingGroups().get(0).getInstances() != null) {
        for (Instance instance : describeAutoScalingGroupsResult.getAutoScalingGroups().get(0).getInstances()) {
            if ("InService".equals(instance.getLifecycleState())) {
                instanceIds.add(instance.getInstanceId());
            }
        }
    }
    return instanceIds;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:14,代码来源:CloudFormationStackUtil.java


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