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


Java DescribeInstanceStatusRequest.setInstanceIds方法代码示例

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


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

示例1: getInstanceStatus

import com.amazonaws.services.ec2.model.DescribeInstanceStatusRequest; //导入方法依赖的package包/类
public InstanceStatus getInstanceStatus() {
	if (id == null) {
		getSpotStatus();
		if (id == null)
			return InstanceStatus.INSTANCE_NOT_FOUND;
	}

	com.amazonaws.services.ec2.AmazonEC2 client = AmazonEC2.connect();

	DescribeInstanceStatusRequest instanceReq = new DescribeInstanceStatusRequest();
	List<String> instanceIds = new ArrayList<String>();
	instanceIds.add(id);
	instanceReq.setInstanceIds(instanceIds);
	DescribeInstanceStatusResult instanceRes = client
			.describeInstanceStatus(instanceReq);

	List<com.amazonaws.services.ec2.model.InstanceStatus> reqs = instanceRes
			.getInstanceStatuses();
	if (reqs.size() > 0)
		return InstanceStatus.valueFromStatus(reqs.get(0));
	else {
		return InstanceStatus.INSTANCE_NOT_FOUND;
	}
}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:25,代码来源:Instance.java

示例2: getInstanceStatus

import com.amazonaws.services.ec2.model.DescribeInstanceStatusRequest; //导入方法依赖的package包/类
public InstanceStatus getInstanceStatus(AmazonEC2Client ec2Client, String instanceId) {
	List<String> instanceIds = new ArrayList<String>();
	instanceIds.add(instanceId);
	DescribeInstanceStatusRequest statusReq = new DescribeInstanceStatusRequest();
	statusReq.setInstanceIds(instanceIds);
	DescribeInstanceStatusResult result = ec2Client.describeInstanceStatus(statusReq);
	List<InstanceStatus> statuses = result.getInstanceStatuses();
	if (statuses == null || statuses.size() == 0) {
		return null;
	}
	return statuses.iterator().next();
}
 
开发者ID:bitsofinfo,项目名称:s3-bucket-loader,代码行数:13,代码来源:Ec2Util.java

示例3: dumpEc2InstanceStatus

import com.amazonaws.services.ec2.model.DescribeInstanceStatusRequest; //导入方法依赖的package包/类
public List<String> dumpEc2InstanceStatus(AmazonEC2Client ec2Client, List<Instance> ec2Instances) {
	try {
		List<String> instanceIds = new ArrayList<String>();
		
		for (Instance ec2node : ec2Instances) {
			instanceIds.add(ec2node.getInstanceId());
		}
		
		DescribeInstanceStatusRequest statusReq = new DescribeInstanceStatusRequest();
		statusReq.setInstanceIds(instanceIds);
		DescribeInstanceStatusResult result = ec2Client.describeInstanceStatus(statusReq);
		
		List<InstanceStatus> statuses = result.getInstanceStatuses();
		
		List<String> impairedInstances = new ArrayList<String>();
		
		StringBuffer sb = new StringBuffer("EC2 worker instance STATUS:\n");
		for (InstanceStatus status : statuses) {
			sb.append("\tid:"+status.getInstanceId() + 
					"\taz:" + status.getAvailabilityZone() + 
					"\tstate:" + status.getInstanceState().getName() + 
					"\tstatus:" + status.getInstanceStatus().getStatus() + 
					"\tsystem_status: " + status.getSystemStatus().getStatus() + "\n"); 
			
			if (status.getInstanceStatus().getStatus().equalsIgnoreCase("impaired")) {
				impairedInstances.add(status.getInstanceId());
			}
		}
		
		logger.info(sb.toString()+"\n");
		
		return impairedInstances;
		
	} catch(Exception e) {
		logger.error("Error getting instance state: " + e.getMessage(),e);
		return null;
	}
	
}
 
开发者ID:bitsofinfo,项目名称:s3-bucket-loader,代码行数:40,代码来源:Ec2Util.java


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