本文整理汇总了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;
}
}
示例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;
}
}