本文整理汇总了Java中com.amazonaws.services.ec2.AmazonEC2Client.startInstances方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonEC2Client.startInstances方法的具体用法?Java AmazonEC2Client.startInstances怎么用?Java AmazonEC2Client.startInstances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.AmazonEC2Client
的用法示例。
在下文中一共展示了AmazonEC2Client.startInstances方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startInstances
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
private void startInstances(AmazonEC2Client ec2Client, Exchange exchange) {
Collection instanceIds;
StartInstancesRequest request = new StartInstancesRequest();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS))) {
instanceIds = exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS, Collection.class);
request.withInstanceIds(instanceIds);
} else {
throw new IllegalArgumentException("Instances Ids must be specified");
}
StartInstancesResult result;
try {
result = ec2Client.startInstances(request);
} catch (AmazonServiceException ase) {
LOG.trace("Start Instances command returned the error code {}", ase.getErrorCode());
throw ase;
}
LOG.trace("Starting instances with Ids [{}] ", Arrays.toString(instanceIds.toArray()));
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
示例2: startInstance
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
public void startInstance(AmazonEC2Client ec2Client, String instanceId) throws Exception {
StartInstancesRequest startReq = new StartInstancesRequest();
List<String> instanceIds = new ArrayList<String>();
instanceIds.add(instanceId);
startReq.setInstanceIds(instanceIds);
logger.debug("Starting EC2 instance...." + Arrays.toString(instanceIds.toArray(new String[]{})));
ec2Client.startInstances(startReq);
}
示例3: startInstances
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
private StartInstancesResult startInstances(AmazonEC2Client client, String... instanceIds) {
StartInstancesRequest startRequest = new StartInstancesRequest().withInstanceIds(instanceIds);
StartInstancesResult startResult = client.startInstances(startRequest);
return startResult;
}