本文整理汇总了Java中com.amazonaws.services.ec2.model.TerminateInstancesRequest.setInstanceIds方法的典型用法代码示例。如果您正苦于以下问题:Java TerminateInstancesRequest.setInstanceIds方法的具体用法?Java TerminateInstancesRequest.setInstanceIds怎么用?Java TerminateInstancesRequest.setInstanceIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.model.TerminateInstancesRequest
的用法示例。
在下文中一共展示了TerminateInstancesRequest.setInstanceIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: terminateEc2Instance
import com.amazonaws.services.ec2.model.TerminateInstancesRequest; //导入方法依赖的package包/类
public void terminateEc2Instance(AmazonEC2Client ec2Client, String instanceId) throws Exception {
try {
TerminateInstancesRequest termReq = new TerminateInstancesRequest();
List<String> instanceIds = new ArrayList<String>();
instanceIds.add(instanceId);
termReq.setInstanceIds(instanceIds);
logger.debug("Terminating EC2 instances...." + Arrays.toString(instanceIds.toArray(new String[]{})));
ec2Client.terminateInstances(termReq);
} catch(Exception e) {
logger.error("Unexpected error terminating: " + instanceId + " "+ e.getMessage(),e);
}
}
示例2: terminateInstances
import com.amazonaws.services.ec2.model.TerminateInstancesRequest; //导入方法依赖的package包/类
/**
* Terminate instances.
*
* @param instanceIds
* instances' IDs
* @return list of instances change
*/
protected final List<InstanceStateChange> terminateInstances(
final Collection<String> instanceIds) {
log.info("Terminate instances:" + toString(instanceIds));
TerminateInstancesRequest request = new TerminateInstancesRequest();
request.setInstanceIds(instanceIds);
TerminateInstancesResult result = amazonEC2Client
.terminateInstances(request);
return result.getTerminatingInstances();
}