热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.amazonaws.services.autoscaling.AmazonAutoScaling.describeAutoScalingGroups()方法的使用及代码示例

本文整理了Java中com.amazonaws.services.autoscaling.AmazonAutoScaling.describeAutoScalingGroups()

本文整理了Java中com.amazonaws.services.autoscaling.AmazonAutoScaling.describeAutoScalingGroups()方法的一些代码示例,展示了AmazonAutoScaling.describeAutoScalingGroups()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonAutoScaling.describeAutoScalingGroups()方法的具体详情如下:
包路径:com.amazonaws.services.autoscaling.AmazonAutoScaling
类名称:AmazonAutoScaling
方法名:describeAutoScalingGroups

AmazonAutoScaling.describeAutoScalingGroups介绍

[英]Simplified method form for invoking the DescribeAutoScalingGroups operation.
[中]调用DescribeAutoScalingGroups操作的简化方法表单。

代码示例

代码示例来源:origin: aws/aws-sdk-java

/**
* Makes a call to the operation specified by the waiter by taking the corresponding request and returns the
* corresponding result
*
* @param describeAutoScalingGroupsRequest
* Corresponding request for the operation
* @return Corresponding result of the operation
*/
@Override
public DescribeAutoScalingGroupsResult apply(DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest) {
return client.describeAutoScalingGroups(describeAutoScalingGroupsRequest);
}
}

代码示例来源:origin: Netflix/eureka

/**
* Queries AWS to get the autoscaling information given the asgName.
*
* @param asgName
* - The name of the ASG.
* @return - The auto scaling group information.
*/
private AutoScalingGroup retrieveAutoScalingGroup(String asgName) {
if (Strings.isNullOrEmpty(asgName)) {
logger.warn("null asgName specified, not attempting to retrieve AutoScalingGroup from AWS");
return null;
}
// You can pass one name or a list of names in the request
DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(asgName);
DescribeAutoScalingGroupsResult result = awsClient
.describeAutoScalingGroups(request);
List asgs = result.getAutoScalingGroups();
if (asgs.isEmpty()) {
return null;
} else {
return asgs.get(0);
}
}

代码示例来源:origin: Netflix/eureka

DescribeAutoScalingGroupsResult result = autoScalingClient.describeAutoScalingGroups(request);
List asgs = result.getAutoScalingGroups();
if (asgs.isEmpty()) {

代码示例来源:origin: Netflix/Priam

.withAutoScalingGroupNames(
asgNames.toArray(new String[asgNames.size()]));
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);

代码示例来源:origin: Netflix/Priam

.withAutoScalingGroupNames(
asgNames.toArray(new String[asgNames.size()]));
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);

代码示例来源:origin: apache/incubator-gobblin

/***
* 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 getAutoScalingGroupsWithTag(Tag tag) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List allAutoScalingGroups = autoScaling
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List 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;
}

代码示例来源:origin: Netflix/Priam

/** Actual membership AWS source of truth... */
@Override
public int getRacMembershipSize() {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq =
new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(instanceInfo.getAutoScalingGroup());
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);
int size = 0;
for (AutoScalingGroup asg : res.getAutoScalingGroups()) {
size += asg.getMaxSize();
}
logger.info("Query on ASG returning {} instances", size);
return size;
} finally {
if (client != null) client.shutdown();
}
}

代码示例来源:origin: Netflix/Priam

@Override
public void expandRacMembership(int count) {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq =
new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(instanceInfo.getAutoScalingGroup());
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();
}
}

代码示例来源:origin: msoute/vertx-deploy-tools

private String matchAutoScalingGroupName(String regex) {
DescribeAutoScalingGroupsResult result = awsAsClient.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest());
List groups = toGroupNameList(result.getAutoScalingGroups());
while (result.getNextToken() != null && !result.getNextToken().isEmpty()) {
result = awsAsClient.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest().withNextToken(result.getNextToken()));
groups.addAll(toGroupNameList(result.getAutoScalingGroups()));
}
List matchedGroups = groups.stream().filter(name -> name.matches(regex)).collect(Collectors.toList());
if (matchedGroups == null || matchedGroups.isEmpty() || matchedGroups.size() != 1) {
int matchSize = matchedGroups == null ? -1 : matchedGroups.size();
if (matchedGroups != null && matchSize > 0) {
matchedGroups.forEach(group -> log.error("Matched group : " + group));
}
throw new IllegalStateException("Unable to match group regex, matched group size " + matchSize);
}
return matchedGroups.stream().findFirst().orElse(regex);
}

代码示例来源:origin: com.netflix.eureka/eureka-core

/**
* Queries AWS to get the autoscaling information given the asgName.
*
* @param asgName
* - The name of the ASG.
* @return - The auto scaling group information.
*/
private AutoScalingGroup retrieveAutoScalingGroup(String asgName) {
if (Strings.isNullOrEmpty(asgName)) {
logger.warn("null asgName specified, not attempting to retrieve AutoScalingGroup from AWS");
return null;
}
// You can pass one name or a list of names in the request
DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(asgName);
DescribeAutoScalingGroupsResult result = awsClient
.describeAutoScalingGroups(request);
List asgs = result.getAutoScalingGroups();
if (asgs.isEmpty()) {
return null;
} else {
return asgs.get(0);
}
}

代码示例来源:origin: msoute/vertx-deploy-tools

public AutoScalingGroup getAutoScalingGroup() {
DescribeAutoScalingGroupsResult result = awsAsClient.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(activeConfiguration.getAutoScalingGroupId()));
if (result.getAutoScalingGroups().isEmpty()) {
log.error("No Autoscaling group found with id : " + activeConfiguration.getAutoScalingGroupId());
throw new IllegalStateException();
}
return result.getAutoScalingGroups().get(0);
}

代码示例来源:origin: com.elastisys.scale/cloudpool.aws.commons

@Override
public AutoScalingGroup call() {
DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(this.groupName);
DescribeAutoScalingGroupsResult result = getClient().getApi().describeAutoScalingGroups(request);
List autoScalingGroups = result.getAutoScalingGroups();
if (autoScalingGroups.isEmpty()) {
throw new IllegalArgumentException(format("Auto Scaling Group '%s' doesn't exist in region '%s'.",
this.groupName, getClient().getRegion()));
}
return getOnlyElement(autoScalingGroups);
}

代码示例来源:origin: com.netflix.dynomitemanager/dynomitemanager-common

@Override
public List getRacMembership() {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(envVariables.getRack());
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);
List instanceIds = Lists.newArrayList();
for (AutoScalingGroup asg : res.getAutoScalingGroups()) {
for (Instance ins : asg.getInstances())
if (!(ins.getLifecycleState().equalsIgnoreCase("Terminating")
|| ins.getLifecycleState().equalsIgnoreCase("shutting-down")
|| ins.getLifecycleState().equalsIgnoreCase("Terminated")))
instanceIds.add(ins.getInstanceId());
}
logger.info(String.format("Querying Amazon returned following instance in the ASG: %s --> %s",
envVariables.getRack(), StringUtils.join(instanceIds, ",")));
return instanceIds;
} finally {
if (client != null)
client.shutdown();
}
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-aws

/***
* 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 getAutoScalingGroupsWithTag(Tag tag) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List allAutoScalingGroups = autoScaling
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List 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;
}

代码示例来源:origin: org.apache.gobblin/gobblin-aws

/***
* 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 getAutoScalingGroupsWithTag(Tag tag) {
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List allAutoScalingGroups = autoScaling
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List 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;
}

代码示例来源:origin: com.atlassian.buildeng/ecs-scheduler

/**
*
* @param autoScalingGroup name
* @return described autoscaling group
* @throws ECSException
*/
@Override
public AutoScalingGroup describeAutoScalingGroup(String autoScalingGroup) throws ECSException {
try {
AmazonAutoScaling asgClient = AmazonAutoScalingClientBuilder.defaultClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(autoScalingGroup);
List groups = asgClient.describeAutoScalingGroups(asgReq).getAutoScalingGroups();
if (groups.size() > 1) {
throw new ECSException("More than one group by name:" + autoScalingGroup);
}
if (groups.isEmpty()) {
throw new ECSException("No auto scaling group with name:" + autoScalingGroup);
}
return groups.get(0);
} catch (Exception ex) {
if (ex instanceof ECSException) {
throw ex;
} else {
throw new ECSException(ex);
}
}
}

代码示例来源:origin: com.netflix.dynomitemanager/dynomitemanager-common

/**
* Actual membership AWS source of truth...
*/
@Override
public int getRacMembershipSize() {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(envVariables.getRack());
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();
}
}

代码示例来源:origin: com.netflix.dynomitemanager/dynomitemanager-common

/**
* Cross-account member of AWS
*/
@Override
public int getCrossAccountRacMembershipSize() {
AmazonAutoScaling client = null;
try {
client = getCrossAccountAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(envVariables.getRack());
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);
int size = 0;
for (AutoScalingGroup asg : res.getAutoScalingGroups()) {
size += asg.getMaxSize();
}
logger.info(String.format("Query on cross account ASG returning %d instances", size));
return size;
} finally {
if (client != null)
client.shutdown();
}
}

代码示例来源:origin: com.netflix.raigad/raigad

@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();
}
}

代码示例来源:origin: com.netflix.dynomitemanager/dynomitemanager-common

@Override
public void expandRacMembership(int count) {
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(envVariables.getRack());
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();
}
}

推荐阅读
author-avatar
咖喱2502894907
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有