本文整理匯總了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;
}
}