當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。