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