本文整理汇总了Java中com.amazonaws.services.autoscaling.AmazonAutoScaling类的典型用法代码示例。如果您正苦于以下问题:Java AmazonAutoScaling类的具体用法?Java AmazonAutoScaling怎么用?Java AmazonAutoScaling使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonAutoScaling类属于com.amazonaws.services.autoscaling包,在下文中一共展示了AmazonAutoScaling类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAutoScalingGroupsWithTag
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/***
* Get list of {@link AutoScalingGroup}s for a given tag
*
* @param tag Tag to filter the auto scaling groups
* @return List of {@link AutoScalingGroup}s qualifying the filter tag
*/
public List<AutoScalingGroup> getAutoScalingGroupsWithTag(Tag tag) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List<AutoScalingGroup> allAutoScalingGroups = autoScaling
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List<AutoScalingGroup> filteredAutoScalingGroups = Lists.newArrayList();
for (AutoScalingGroup autoScalingGroup : allAutoScalingGroups) {
for (TagDescription tagDescription : autoScalingGroup.getTags()) {
if (tagDescription.getKey().equalsIgnoreCase(tag.getKey()) &&
tagDescription.getValue().equalsIgnoreCase(tag.getValue())) {
filteredAutoScalingGroups.add(autoScalingGroup);
}
}
}
return filteredAutoScalingGroups;
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:29,代码来源:AWSSdkClient.java
示例2: getRacMembershipSize
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/**
* Actual membership AWS source of truth...
*/
@Override
public int getRacMembershipSize() {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(config.getASGName());
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);
int size = 0;
for (AutoScalingGroup asg : res.getAutoScalingGroups()) {
size += asg.getMaxSize();
}
logger.info(String.format("Query on ASG returning %d instances", size));
return size;
} finally {
if (client != null) {
client.shutdown();
}
}
}
开发者ID:Netflix,项目名称:Raigad,代码行数:27,代码来源:AWSMembership.java
示例3: expandRacMembership
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Override
public void expandRacMembership(int count) {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(config.getASGName());
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);
AutoScalingGroup asg = res.getAutoScalingGroups().get(0);
UpdateAutoScalingGroupRequest ureq = new UpdateAutoScalingGroupRequest();
ureq.setAutoScalingGroupName(asg.getAutoScalingGroupName());
ureq.setMinSize(asg.getMinSize() + 1);
ureq.setMaxSize(asg.getMinSize() + 1);
ureq.setDesiredCapacity(asg.getMinSize() + 1);
client.updateAutoScalingGroup(ureq);
} finally {
if (client != null) {
client.shutdown();
}
}
}
开发者ID:Netflix,项目名称:Raigad,代码行数:22,代码来源:AWSMembership.java
示例4: amazonAutoScalingClient
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Bean
public AmazonAutoScaling amazonAutoScalingClient(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonAutoScalingClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:10,代码来源:AwsConfig.java
示例5: configure
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的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: setup
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Before
public void setup() {
autoScalingClient = mock(AmazonAutoScaling.class);
ec2Client = mock(AmazonEC2.class);
autoScalingService = new AutoScalingService(autoScalingClient, ec2Client);
}
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:8,代码来源:AutoScalingServiceTest.java
示例7: AWSSdkClient
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的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
示例8: deleteAutoScalingGroup
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/***
* Delete an auto scaling group by its name
*
* @param autoScalingGroupName Name of auto scaling group to delete
* @param shouldForceDelete If the AutoScalingGroup should be deleted without waiting for instances to terminate
*/
public void deleteAutoScalingGroup(String autoScalingGroupName,
boolean shouldForceDelete) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DeleteAutoScalingGroupRequest deleteLaunchConfigurationRequest = new DeleteAutoScalingGroupRequest()
.withAutoScalingGroupName(autoScalingGroupName)
.withForceDelete(shouldForceDelete);
autoScaling.deleteAutoScalingGroup(deleteLaunchConfigurationRequest);
LOGGER.info("Deleted AutoScalingGroup: " + autoScalingGroupName);
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:20,代码来源:AWSSdkClient.java
示例9: getRacMembership
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Override
public Map<String, List<String>> getRacMembership(Collection<String> autoScalingGroupNames) {
if (CollectionUtils.isEmpty(autoScalingGroupNames)) {
return Collections.emptyMap();
}
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest =
new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(autoScalingGroupNames);
DescribeAutoScalingGroupsResult describeAutoScalingGroupsResult = client.describeAutoScalingGroups(describeAutoScalingGroupsRequest);
Map<String, List<String>> asgs = new HashMap<>();
for (AutoScalingGroup autoScalingGroup : describeAutoScalingGroupsResult.getAutoScalingGroups()) {
List<String> asgInstanceIds = Lists.newArrayList();
for (Instance asgInstance : autoScalingGroup.getInstances()) {
if (!(asgInstance.getLifecycleState().equalsIgnoreCase("terminating") ||
asgInstance.getLifecycleState().equalsIgnoreCase("shutting-down") ||
asgInstance.getLifecycleState().equalsIgnoreCase("terminated"))) {
asgInstanceIds.add(asgInstance.getInstanceId());
}
}
asgs.put(autoScalingGroup.getAutoScalingGroupName(), asgInstanceIds);
logger.info("AWS returned the following instance ID's for {} ASG: {}",
autoScalingGroup.getAutoScalingGroupName(),
StringUtils.join(asgInstanceIds, ","));
}
return asgs;
} finally {
if (client != null) {
client.shutdown();
}
}
}
开发者ID:Netflix,项目名称:Raigad,代码行数:38,代码来源:AWSMembership.java
示例10: findClient
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的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
示例11: describeLaunchConfigurations
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Override
public List<AbstractResource<?>> describeLaunchConfigurations(Account account, Region region, DateTime dt) {
AmazonAutoScaling as = findClient(account, region);
DescribeLaunchConfigurationsRequest req = new DescribeLaunchConfigurationsRequest();
log.debug("start describing instances for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
DescribeLaunchConfigurationsResult res = as.describeLaunchConfigurations(req);
return converter.toAsLaunchConfigurations(res.getLaunchConfigurations(), account.getId(), region, dt);
}
开发者ID:veyronfei,项目名称:clouck,代码行数:11,代码来源:AsWrapperImpl.java
示例12: describeAutoScalingGroups
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Override
public List<AbstractResource<?>> describeAutoScalingGroups(Account account, Region region, DateTime dt) {
AmazonAutoScaling as = findClient(account, region);
DescribeAutoScalingGroupsRequest req = new DescribeAutoScalingGroupsRequest();
log.debug("start describing auto scaling groups for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
DescribeAutoScalingGroupsResult res = as.describeAutoScalingGroups(req);
return converter.toAsGroups(res.getAutoScalingGroups(), account.getId(), region, dt);
}
开发者ID:veyronfei,项目名称:clouck,代码行数:11,代码来源:AsWrapperImpl.java
示例13: AutoScalingService
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Inject
public AutoScalingService(final AmazonAutoScaling autoScalingClient, final AmazonEC2 ec2Client) {
this.autoScalingClient = autoScalingClient;
this.ec2Client = ec2Client;
}
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:6,代码来源:AutoScalingService.java
示例14: autoScaling
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
@Bean
public AmazonAutoScaling autoScaling() {
AmazonAutoScaling client = new AmazonAutoScalingClient();
client.setRegion(region);
return client;
}
开发者ID:aws-samples,项目名称:aws-codedeploy-sample-tomcat,代码行数:7,代码来源:MvcConfiguration.java
示例15: main
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的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
示例16: createLaunchConfig
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/***
* Create a launch configuration that can be later used to create {@link AmazonAutoScaling} groups
*
* @param launchConfigName Desired launch config name
* @param imageId AMI image id to use
* @param instanceType EC2 instance type to use
* @param keyName Key name
* @param securityGroups Security groups to apply
* @param kernelId Optional kernel id
* @param ramdiskId Optional ram disk id
* @param blockDeviceMapping Optional EBS device mapping
* @param iamInstanceProfile Optional IAM instance profile
* @param instanceMonitoring Optional instance monitoring
* @param userData User data (eg. shell script to execute at instance boot under this launch config)
*/
public void createLaunchConfig(String launchConfigName,
String imageId,
String instanceType,
String keyName,
String securityGroups,
Optional<String> kernelId,
Optional<String> ramdiskId,
Optional<BlockDeviceMapping> blockDeviceMapping,
Optional<String> iamInstanceProfile,
Optional<InstanceMonitoring> instanceMonitoring,
String userData) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
CreateLaunchConfigurationRequest createLaunchConfigurationRequest = new CreateLaunchConfigurationRequest()
.withLaunchConfigurationName(launchConfigName)
.withImageId(imageId)
.withInstanceType(instanceType)
.withSecurityGroups(SPLITTER.splitToList(securityGroups))
.withKeyName(keyName)
.withUserData(userData);
if (kernelId.isPresent()) {
createLaunchConfigurationRequest = createLaunchConfigurationRequest
.withKernelId(kernelId.get());
}
if (ramdiskId.isPresent()) {
createLaunchConfigurationRequest = createLaunchConfigurationRequest
.withRamdiskId(ramdiskId.get());
}
if (blockDeviceMapping.isPresent()) {
createLaunchConfigurationRequest = createLaunchConfigurationRequest
.withBlockDeviceMappings(blockDeviceMapping.get());
}
if (iamInstanceProfile.isPresent()) {
createLaunchConfigurationRequest = createLaunchConfigurationRequest
.withIamInstanceProfile(iamInstanceProfile.get());
}
if (instanceMonitoring.isPresent()) {
createLaunchConfigurationRequest = createLaunchConfigurationRequest
.withInstanceMonitoring(instanceMonitoring.get());
}
autoScaling.createLaunchConfiguration(createLaunchConfigurationRequest);
LOGGER.info("Created Launch Configuration: " + launchConfigName);
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:62,代码来源:AWSSdkClient.java
示例17: createAutoScalingGroup
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/***
* Create and launch an {@link AmazonAutoScaling} group
*
* @param groupName Auto scaling group name
* @param launchConfig Launch configuration string
* @param minSize Minimum number of instances to maintain in auto scaling group
* @param maxSize Maximum number of instances to scale up-to for load
* @param desiredCapacity Desired number of instances to maintain in auto scaling group
* @param availabilityZones Optional availability zones to make use of
* @param cooldown Optional cooldown period before any scaling event (default is 300 secs)
* @param healthCheckGracePeriod Optional grace period till which no health check is performed after bootup (default is 300 secs)
* @param healthCheckType Optional health check type (default is EC2 instance check)
* @param loadBalancer Optional load balancer to use
* @param terminationPolicy Optional termination policies
* @param tags Optional tags to set on auto scaling group (they are set to propagate to EC2 instances implicitly)
*/
public void createAutoScalingGroup(String groupName,
String launchConfig,
Integer minSize, Integer maxSize, Integer desiredCapacity,
Optional<String> availabilityZones,
Optional<Integer> cooldown,
Optional<Integer> healthCheckGracePeriod,
Optional<String> healthCheckType,
Optional<String> loadBalancer,
Optional<String> terminationPolicy,
List<Tag> tags) {
AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
// Propagate ASG tags to EC2 instances launched under the ASG by default
// (we want to ensure this, hence not configurable)
final List<Tag> tagsWithPropagationSet = Lists.newArrayList();
for (Tag tag : tags) {
tagsWithPropagationSet.add(tag.withPropagateAtLaunch(true));
}
CreateAutoScalingGroupRequest createAutoScalingGroupRequest = new CreateAutoScalingGroupRequest()
.withAutoScalingGroupName(groupName)
.withLaunchConfigurationName(launchConfig)
.withMinSize(minSize)
.withMaxSize(maxSize)
.withDesiredCapacity(desiredCapacity)
.withTags(tagsWithPropagationSet);
if (availabilityZones.isPresent()) {
createAutoScalingGroupRequest = createAutoScalingGroupRequest
.withAvailabilityZones(SPLITTER.splitToList(availabilityZones.get()));
}
if (cooldown.isPresent()) {
createAutoScalingGroupRequest = createAutoScalingGroupRequest
.withDefaultCooldown(cooldown.get());
}
if (healthCheckGracePeriod.isPresent()) {
createAutoScalingGroupRequest = createAutoScalingGroupRequest
.withHealthCheckGracePeriod(healthCheckGracePeriod.get());
}
if (healthCheckType.isPresent()) {
createAutoScalingGroupRequest = createAutoScalingGroupRequest
.withHealthCheckType(healthCheckType.get());
}
if (loadBalancer.isPresent()) {
createAutoScalingGroupRequest = createAutoScalingGroupRequest
.withLoadBalancerNames(SPLITTER.splitToList(loadBalancer.get()));
}
if (terminationPolicy.isPresent()) {
createAutoScalingGroupRequest = createAutoScalingGroupRequest
.withTerminationPolicies(SPLITTER.splitToList(terminationPolicy.get()));
}
autoScaling.createAutoScalingGroup(createAutoScalingGroupRequest);
LOGGER.info("Created AutoScalingGroup: " + groupName);
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:73,代码来源:AWSSdkClient.java
示例18: getAutoScalingClient
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
protected AmazonAutoScaling getAutoScalingClient() {
AmazonAutoScaling client = new AmazonAutoScalingClient(provider.getAwsCredentialProvider());
client.setEndpoint("autoscaling." + config.getDC() + ".amazonaws.com");
return client;
}
开发者ID:Netflix,项目名称:Raigad,代码行数:6,代码来源:AWSMembership.java
示例19: deleteLaunchConfiguration
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/***
* Delete a launch configuration by its name
*
* @param launchConfigName Name of launch config to delete
*/
public void deleteLaunchConfiguration(String launchConfigName) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DeleteLaunchConfigurationRequest deleteLaunchConfigurationRequest = new DeleteLaunchConfigurationRequest()
.withLaunchConfigurationName(launchConfigName);
autoScaling.deleteLaunchConfiguration(deleteLaunchConfigurationRequest);
LOGGER.info("Deleted Launch Configuration: " + launchConfigName);
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:17,代码来源:AWSSdkClient.java
示例20: getAmazonAutoScalingClient
import com.amazonaws.services.autoscaling.AmazonAutoScaling; //导入依赖的package包/类
/***
* Creates a new Amazon AutoScaling client to invoke service methods on Amazon AutoScaling
*
* @return Amazon AutoScaling client to invoke service methods on Amazon AutoScaling
*/
public AmazonAutoScaling getAmazonAutoScalingClient() {
return amazonAutoScalingSupplier.get();
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:9,代码来源:AWSSdkClient.java
注:本文中的com.amazonaws.services.autoscaling.AmazonAutoScaling类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论