热门标签 | 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();
}
}

推荐阅读
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 本文详细介绍了Java中org.w3c.dom.Text类的splitText()方法,通过多个代码示例展示了其实际应用。该方法用于将文本节点在指定位置拆分为两个节点,并保持在文档树中。 ... [详细]
  • 本文详细探讨了JDBC(Java数据库连接)的内部机制,重点分析其作为服务提供者接口(SPI)框架的应用。通过类图和代码示例,展示了JDBC如何注册驱动程序、建立数据库连接以及执行SQL查询的过程。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文介绍了Java并发库中的阻塞队列(BlockingQueue)及其典型应用场景。通过具体实例,展示了如何利用LinkedBlockingQueue实现线程间高效、安全的数据传递,并结合线程池和原子类优化性能。 ... [详细]
  • 主要用了2个类来实现的,话不多说,直接看运行结果,然后在奉上源代码1.Index.javaimportjava.awt.Color;im ... [详细]
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 将Web服务部署到Tomcat
    本文介绍了如何在JDeveloper 12c中创建一个Java项目,并将其打包为Web服务,然后部署到Tomcat服务器。内容涵盖从项目创建、编写Web服务代码、配置相关XML文件到最终的本地部署和验证。 ... [详细]
  • 2023年京东Android面试真题解析与经验分享
    本文由一位拥有6年Android开发经验的工程师撰写,详细解析了京东面试中常见的技术问题。涵盖引用传递、Handler机制、ListView优化、多线程控制及ANR处理等核心知识点。 ... [详细]
  • 本文详细介绍如何使用Samba软件配置CIFS文件共享服务,涵盖安装、配置、权限管理及多用户挂载等关键步骤。通过具体示例和命令行操作,帮助读者快速搭建并优化Samba服务器。 ... [详细]
  • 解决JAX-WS动态客户端工厂弃用问题并迁移到XFire
    在处理Java项目中的JAR包冲突时,我们遇到了JaxWsDynamicClientFactory被弃用的问题,并成功将其迁移到org.codehaus.xfire.client。本文详细介绍了这一过程及解决方案。 ... [详细]
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社区 版权所有