本文整理了Java中com.amazonaws.services.autoscaling.AmazonAutoScaling.describeAutoScalingGroups()
方法的一些代码示例,展示了AmazonAutoScaling.describeAutoScalingGroups()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonAutoScaling.describeAutoScalingGroups()
方法的具体详情如下:
包路径:com.amazonaws.services.autoscaling.AmazonAutoScaling
类名称: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
if (asgs.isEmpty()) {
return null;
} else {
return asgs.get(0);
}
}
代码示例来源:origin: Netflix/eureka
DescribeAutoScalingGroupsResult result = autoScalingClient.describeAutoScalingGroups(request);
List
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
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List
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
while (result.getNextToken() != null && !result.getNextToken().isEmpty()) {
result = awsAsClient.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest().withNextToken(result.getNextToken()));
groups.addAll(toGroupNameList(result.getAutoScalingGroups()));
}
List
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
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
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
AmazonAutoScaling client = null;
try {
client = getAutoScalingClient();
DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(envVariables.getRack());
DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq);
List
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
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List
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
final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
final List
.describeAutoScalingGroups(describeAutoScalingGroupsRequest)
.getAutoScalingGroups();
final List
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
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();
}
}