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


Java AmazonEC2Client.describeReservedInstances方法代码示例

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


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

示例1: getReservedInstancesForZone

import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
@Override
public Map<AvailabilityZone, List<ReservedInstances>> getReservedInstancesForZone(
    AvailabilityZone zone, AmazonEC2Client client) throws Exception {

  OperationStats op = new OperationStats("ec2InstanceStore", "getReservedInstancesForZone");

  try {
    Map<AvailabilityZone, List<ReservedInstances>> ret = new HashMap<>();
    DescribeReservedInstancesRequest request = new DescribeReservedInstancesRequest()
        .withFilters(new Filter("availability-zone", Arrays.asList(zone.getZoneName())))
        .withSdkClientExecutionTimeout(
            600 * 1000) //10 minutes time out for total execution including retries
        .withSdkRequestTimeout(300 * 1000); //5 minutes time out for a single request

    DescribeReservedInstancesResult result = client.describeReservedInstances(request);
    ret.put(zone, result.getReservedInstances());

    op.succeed();
    return ret;

  } catch (Exception e) {

    op.failed();
    logger.error(ExceptionUtils.getRootCauseMessage(e));
    throw e;
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:28,代码来源:Ec2InstanceStore.java

示例2: getReservedInstances

import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
/**
 * Get Reserved instances for a given region
 * @param region
 * @return
 */
@Override
public List<ReservedInstances> getReservedInstances(Region region) {

  OperationStats op = new OperationStats("ec2InstanceStore", "getReservedInstances");
  try {

    AmazonEC2Client client = getClient(region);
    DescribeReservedInstancesRequest request = new DescribeReservedInstancesRequest()
        .withSdkClientExecutionTimeout(
            600 * 1000) //10 minutes time out for total execution including retries
        .withSdkRequestTimeout(300 * 1000); //5 minutes time out for a single request

    DescribeReservedInstancesResult result = client.describeReservedInstances(request);

    op.succeed();
    return result.getReservedInstances();

  } catch (Exception e) {

    op.failed();
    logger.error(ExceptionUtils.getRootCauseMessage(e));
    throw e;
  }


}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:32,代码来源:Ec2InstanceStore.java


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