当前位置: 首页>>代码示例>>Java>>正文


Java DescribeAvailabilityZonesResult.getAvailabilityZones方法代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult.getAvailabilityZones方法的典型用法代码示例。如果您正苦于以下问题:Java DescribeAvailabilityZonesResult.getAvailabilityZones方法的具体用法?Java DescribeAvailabilityZonesResult.getAvailabilityZones怎么用?Java DescribeAvailabilityZonesResult.getAvailabilityZones使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult的用法示例。


在下文中一共展示了DescribeAvailabilityZonesResult.getAvailabilityZones方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleSuccess

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
@Override
public void handleSuccess(DescribeAvailabilityZonesRequest request,
        DescribeAvailabilityZonesResult result) {

    List<AvailabilityZone> zones = result.getAvailabilityZones();
    if (zones == null || zones.isEmpty()) {
        this.service
                .logFine(() -> "No AvailabilityZones found. Nothing to be created locally");
        this.context.refreshSubStage = this.next;
        this.service.processRefreshSubStages(this.context);
        return;
    }

    loadLocalResources(this.service, this.context,
            zones.stream()
                    .map(AvailabilityZone::getZoneName)
                    .collect(Collectors.toList()),
            cm -> createMissingLocalInstances(zones, cm),
            cm -> {
                this.service.logFine(() -> "No AvailabilityZones found. Nothing to be"
                        + " created locally");
                this.context.refreshSubStage = this.next;
                this.service.processRefreshSubStages(this.context);
            });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:AWSEnumerationAndCreationAdapterService.java

示例2: getAvailabilityZonesForSubnetIds

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
/**
 * This implementation uses the DescribeAvailabilityZones API to get the list of AZs.
 */
@Override
public List<AvailabilityZone> getAvailabilityZonesForSubnetIds(Collection<Subnet> subnets, AwsParamsDto awsParamsDto)
{
    Set<String> zoneNames = new HashSet<>();
    for (Subnet subnet : subnets)
    {
        zoneNames.add(subnet.getAvailabilityZone());
    }

    AmazonEC2Client ec2Client = getEc2Client(awsParamsDto);
    DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest = new DescribeAvailabilityZonesRequest();
    describeAvailabilityZonesRequest.setZoneNames(zoneNames);
    DescribeAvailabilityZonesResult describeAvailabilityZonesResult = ec2Operations.describeAvailabilityZones(ec2Client, describeAvailabilityZonesRequest);
    return describeAvailabilityZonesResult.getAvailabilityZones();
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:19,代码来源:Ec2DaoImpl.java

示例3: getAllAvailabilityZones

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
public static List<String> getAllAvailabilityZones() {
	connect();
	
	DescribeAvailabilityZonesRequest req = new DescribeAvailabilityZonesRequest();
	
	ArrayList<Filter> filters = new ArrayList<Filter>();
	ArrayList<String> regions = new ArrayList<String>();
	regions.add(Configuration.REGION);
	filters.add(new Filter("region-name", regions));
	req.setFilters(filters);
	
	DescribeAvailabilityZonesResult res = client.describeAvailabilityZones(req);
	
	List<AvailabilityZone> zones = res.getAvailabilityZones();
	ArrayList<String> zonesStr = new ArrayList<String>();
	for (AvailabilityZone zone : zones)
		zonesStr.add(zone.getZoneName());
	
	return zonesStr;
}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:21,代码来源:AmazonEC2.java

示例4: getAvailabilityZones

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
@Override
public List<AvailabilityZone> getAvailabilityZones(Region region) throws Exception {
  OperationStats op = new OperationStats("ec2InstanceStore", "getAvailabilityZones");
  try {
    DescribeAvailabilityZonesRequest request = new DescribeAvailabilityZonesRequest();
    DescribeAvailabilityZonesResult result = getClient(region).describeAvailabilityZones();
    List<AvailabilityZone> ret = result.getAvailabilityZones();
    op.succeed();
    return ret;
  } catch (Exception ex) {
    op.failed();
    throw ex;
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:15,代码来源:Ec2InstanceStore.java

示例5: main

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
public static void main(String[] args)
{
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeRegionsResult regions_response = ec2.describeRegions();

    for(Region region : regions_response.getRegions()) {
        System.out.printf(
            "Found region %s " +
            "with endpoint %s",
            region.getRegionName(),
            region.getEndpoint());
    }

    DescribeAvailabilityZonesResult zones_response =
        ec2.describeAvailabilityZones();

    for(AvailabilityZone zone : zones_response.getAvailabilityZones()) {
        System.out.printf(
            "Found availability zone %s " +
            "with status %s " +
            "in region %s",
            zone.getZoneName(),
            zone.getState(),
            zone.getRegionName());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:28,代码来源:DescribeRegionsAndZones.java

示例6: listAvailableZonesOfRegion

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
private List<Zone> listAvailableZonesOfRegion(Region region)
{
    checkNotNull(region);
    checkState(!isNullOrEmpty(region.getName()));
    checkState(!isNullOrEmpty(region.getEndpoint()));

    List<Zone> zones = newArrayList();
    
    AmazonEC2Client client = new AmazonEC2Client(awsCredentials_);
    client.setEndpoint(region.getEndpoint());

    try
    {
        DescribeAvailabilityZonesResult availabilityZonesResult = client.describeAvailabilityZones(new DescribeAvailabilityZonesRequest()
                .withFilters(new com.amazonaws.services.ec2.model.Filter().withName("region-name").withValues(region.getName()),
                             new com.amazonaws.services.ec2.model.Filter().withName("state").withValues("available"))
                            );

        for (AvailabilityZone zone : availabilityZonesResult.getAvailabilityZones())
        {
            zones.add(new Zone().setName(zone.getZoneName()).setRegion(region));
        }

        Collections.sort(zones);
    }
    catch (AmazonClientException exception)
    {
        LOG.warn("Error on listing the available zones of region [name:{}, endpoint:{}]. Error message: [{}]", 
                region.getName(), region.getEndpoint(), exception.getMessage(), exception);
    }

    return zones;
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:34,代码来源:EC2.java

示例7: getAvailabilityZones

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public List<AvailabilityZone> getAvailabilityZones(Long userNo, Long platformNo) {
    // アベイラビリティゾーンを取得
    AwsProcessClient awsProcessClient = awsProcessClientFactory.createAwsProcessClient(userNo, platformNo);
    DescribeAvailabilityZonesRequest request = new DescribeAvailabilityZonesRequest();
    DescribeAvailabilityZonesResult result = awsProcessClient.getEc2Client().describeAvailabilityZones(request);
    List<AvailabilityZone> availabilityZones = result.getAvailabilityZones();

    // ソート
    Collections.sort(availabilityZones, Comparators.COMPARATOR_AVAILABILITY_ZONE);

    return availabilityZones;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:17,代码来源:AwsDescribeServiceImpl.java

示例8: describeAvailabilityZones

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
public List<AvailabilityZone> describeAvailabilityZones(AwsProcessClient awsProcessClient) {
    DescribeAvailabilityZonesRequest request = new DescribeAvailabilityZonesRequest();
    DescribeAvailabilityZonesResult result = awsProcessClient.getEc2Client().describeAvailabilityZones(request);
    List<AvailabilityZone> availabilityZones = result.getAvailabilityZones();

    return availabilityZones;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:8,代码来源:AwsCommonProcess.java

示例9: getAvailabilityZones

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
/***
 * Get availability zones in an Amazon AWS region
 *
 * @return List of availability zones
 */
public List<AvailabilityZone> getAvailabilityZones() {

  final AmazonEC2 amazonEC2 = getEc2Client();

  final DescribeAvailabilityZonesResult describeAvailabilityZonesResult = amazonEC2.describeAvailabilityZones();
  final List<AvailabilityZone> availabilityZones = describeAvailabilityZonesResult.getAvailabilityZones();
  LOGGER.info("Found: " + availabilityZones.size() + " availability zone");

  return availabilityZones;
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:16,代码来源:AWSSdkClient.java

示例10: getAvailabilityZones

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
public List<AvailabilityZone> getAvailabilityZones() {
    DescribeAvailabilityZonesResult res = this.client.describeAvailabilityZones();
    return res.getAvailabilityZones();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:5,代码来源:AwsDiskClient.java

示例11: regions

import com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult; //导入方法依赖的package包/类
@Override
@Cacheable(cacheNames = "cloudResourceRegionCache", key = "#cloudCredential?.id")
public CloudRegions regions(CloudCredential cloudCredential, Region region, Map<String, String> filters) throws Exception {
    AmazonEC2Client ec2Client = awsClient.createAccess(cloudCredential);
    Map<Region, List<AvailabilityZone>> regionListMap = new HashMap<>();
    Map<Region, String> displayNames = new HashMap<>();

    DescribeRegionsRequest describeRegionsRequest = new DescribeRegionsRequest();
    DescribeRegionsResult describeRegionsResult = ec2Client.describeRegions(describeRegionsRequest);
    String defaultRegion = awsZoneParameterDefault;

    for (com.amazonaws.services.ec2.model.Region awsRegion : describeRegionsResult.getRegions()) {
        if (region == null || Strings.isNullOrEmpty(region.value()) || awsRegion.getRegionName().equals(region.value())) {
            DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest = new DescribeAvailabilityZonesRequest();

            ec2Client.setRegion(RegionUtils.getRegion(awsRegion.getRegionName()));
            Filter filter = new Filter();
            filter.setName("region-name");
            List<String> list = new ArrayList<>();
            list.add(awsRegion.getRegionName());
            filter.setValues(list);

            describeAvailabilityZonesRequest.withFilters(filter);

            DescribeAvailabilityZonesResult describeAvailabilityZonesResult = ec2Client.describeAvailabilityZones(describeAvailabilityZonesRequest);

            List<AvailabilityZone> tmpAz = new ArrayList<>();
            for (com.amazonaws.services.ec2.model.AvailabilityZone availabilityZone : describeAvailabilityZonesResult.getAvailabilityZones()) {
                tmpAz.add(availabilityZone(availabilityZone.getZoneName()));
            }
            regionListMap.put(region(awsRegion.getRegionName()), tmpAz);
            DisplayName displayName = regionDisplayNames.get(region(awsRegion.getRegionName()));
            if (displayName == null || Strings.isNullOrEmpty(displayName.value())) {
                displayNames.put(region(awsRegion.getRegionName()), awsRegion.getRegionName());
            } else {
                displayNames.put(region(awsRegion.getRegionName()), displayName.value());
            }
        }
    }
    if (region != null && !Strings.isNullOrEmpty(region.value())) {
        defaultRegion = region.value();
    }
    return new CloudRegions(regionListMap, displayNames, defaultRegion);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:45,代码来源:AwsPlatformResources.java


注:本文中的com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult.getAvailabilityZones方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。