本文整理汇总了Java中com.amazonaws.services.autoscaling.AmazonAutoScalingClient类的典型用法代码示例。如果您正苦于以下问题:Java AmazonAutoScalingClient类的具体用法?Java AmazonAutoScalingClient怎么用?Java AmazonAutoScalingClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonAutoScalingClient类属于com.amazonaws.services.autoscaling包,在下文中一共展示了AmazonAutoScalingClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: createAutoScalingClient
import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
public AmazonAutoScalingClient createAutoScalingClient(AwsCredentialView awsCredential, String regionName) {
AmazonAutoScalingClient client = isRoleAssumeRequired(awsCredential)
? new AmazonAutoScalingClient(credentialClient.retrieveCachedSessionCredentials(awsCredential))
: new AmazonAutoScalingClient(createAwsCredentials(awsCredential));
client.setRegion(RegionUtils.getRegion(regionName));
return client;
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:8,代码来源:AwsClient.java
示例17: collectGroupMetaData
import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
private List<CloudVmMetaDataStatus> collectGroupMetaData(AuthenticatedContext ac, AmazonAutoScalingClient amazonASClient,
AmazonEC2Client amazonEC2Client, AmazonCloudFormationClient amazonCFClient, String groupName, List<CloudInstance> cloudInstances) {
List<CloudVmMetaDataStatus> cloudVmMetaDataStatuses = new ArrayList<>();
String asGroupName = cloudFormationStackUtil.getAutoscalingGroupName(ac, amazonCFClient, groupName);
List<String> instanceIds = cloudFormationStackUtil.getInstanceIds(amazonASClient, asGroupName);
DescribeInstancesRequest instancesRequest = cloudFormationStackUtil.createDescribeInstancesRequest(instanceIds);
DescribeInstancesResult instancesResult = amazonEC2Client.describeInstances(instancesRequest);
//contains instances with instanceId
Map<String, CloudInstance> mapByInstanceId = mapByInstanceId(cloudInstances);
//contains instances with privateId (without instanceId)
Queue<CloudInstance> untrackedInstances = untrackedInstances(cloudInstances);
for (Reservation reservation : instancesResult.getReservations()) {
LOGGER.info("Number of instances found in reservation: {}", reservation.getInstances().size());
for (Instance instance : reservation.getInstances()) {
String instanceId = instance.getInstanceId();
CloudInstance cloudInstance = ensureInstanceTag(mapByInstanceId, instance, instanceId, untrackedInstances, amazonEC2Client);
if (cloudInstance != null) {
CloudInstanceMetaData md = new CloudInstanceMetaData(instance.getPrivateIpAddress(), instance.getPublicIpAddress());
CloudVmInstanceStatus cloudVmInstanceStatus = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.CREATED);
CloudVmMetaDataStatus cloudVmMetaDataStatus = new CloudVmMetaDataStatus(cloudVmInstanceStatus, md);
cloudVmMetaDataStatuses.add(cloudVmMetaDataStatus);
}
}
}
return cloudVmMetaDataStatuses;
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:35,代码来源:AwsMetadataCollector.java
示例18: findClient
import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
private AmazonAutoScaling findClient(Account account, Region region) {
// TODO: need to config client config parameter. ignore it for now.
// TODO: need a cached version based on account and region as key
AWSCredentials credential = new BasicAWSCredentials(account.getAccessKeyId(), account.getSecretAccessKey());
AmazonAutoScaling as = new AmazonAutoScalingClient(credential);
// as.setEndpoint(region.toAsEndpoint());
return as;
}
开发者ID:veyronfei,项目名称:clouck,代码行数:9,代码来源:AsWrapperImpl.java
示例19: autoScaling
import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
@Bean
public AmazonAutoScaling autoScaling() {
AmazonAutoScaling client = new AmazonAutoScalingClient();
client.setRegion(region);
return client;
}
开发者ID:aws-samples,项目名称:aws-codedeploy-sample-tomcat,代码行数:7,代码来源:MvcConfiguration.java
示例20: main
import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; //导入依赖的package包/类
public static void main( String[] args ) throws IOException {
final String env = "prod";
AWSCredentials credentials =
new PropertiesCredentials(
ShutdownWorkers.class.getResourceAsStream( "/AwsCredentials.properties" )
);
try {
// Scalo a zero
int min = 0;
int desired = 0;
int max = 0;
AmazonAutoScaling as = new AmazonAutoScalingClient(credentials);
as.setEndpoint("autoscaling.eu-west-1.amazonaws.com");
DescribeAutoScalingGroupsResult dasgres = as.describeAutoScalingGroups();
List<AutoScalingGroup> lasg = dasgres.getAutoScalingGroups();
for (AutoScalingGroup asg : lasg) {
if(asg.getAutoScalingGroupName().equals("asg-kopjra-prod-workers")){
desired = asg.getDesiredCapacity();
max = asg.getMaxSize();
min = asg.getMinSize();
break;
}
}
UpdateAutoScalingGroupRequest uasgr = new UpdateAutoScalingGroupRequest();
uasgr.setAutoScalingGroupName("asg-kopjra-prod-workers");
uasgr.setDesiredCapacity(0);
uasgr.setMaxSize(0);
uasgr.setMinSize(0);
as.updateAutoScalingGroup(uasgr);
System.out.println("Done: workers shutting down!");
System.out.println("When you run the StartupWorkers, remember to use the following parameters: "+min+" "+max+" "+desired);
} catch (AmazonServiceException ase) {
System.err.println( "AmazonServiceException" );
} catch (AmazonClientException ace) {
System.err.println( "AmazonClientException" );
} catch (Exception e){
System.err.println( "OtherException" );
}
}
开发者ID:emanuelecasadio,项目名称:CliDispatcher,代码行数:45,代码来源:ShutdownWorkers.java
注:本文中的com.amazonaws.services.autoscaling.AmazonAutoScalingClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论