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


Java StartInstancesRequest.setInstanceIds方法代码示例

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


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

示例1: startInstance

import com.amazonaws.services.ec2.model.StartInstancesRequest; //导入方法依赖的package包/类
StartInstancesResult startInstance(InstanceRequest instanceRequest, Context context) {
	AmazonEC2Async client = createEC2Client();
	try {
		StartInstancesRequest req = new StartInstancesRequest();
		req.setInstanceIds(Arrays.asList(instanceRequest.getInstanceId()));
		Future<StartInstancesResult> result = client.startInstancesAsync(req);
		while (!result.isDone()) {
			Thread.sleep(100);
		}
		return result.get();

	} catch (Exception e) {
		throw new RuntimeException("unexpected error has occured in the start instance request.", e);
	} finally {
		client.shutdown();
	}
}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:18,代码来源:InstanceStartFunction.java

示例2: startInstance

import com.amazonaws.services.ec2.model.StartInstancesRequest; //导入方法依赖的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);
}
 
开发者ID:bitsofinfo,项目名称:s3-bucket-loader,代码行数:9,代码来源:Ec2Util.java

示例3: instanceStart

import com.amazonaws.services.ec2.model.StartInstancesRequest; //导入方法依赖的package包/类
/**
 * http://shlomoswidler.com/2009/07/ec2-instance-life-cycle.html
 */
public void instanceStart(final String instanceId) throws Exception {

	final Instance instance = findInstance(instanceId);

	final InstanceStateName state = stateFrom(instance);

	logger.info("start: current state=" + state);

	switch (state) {
	case Running:
		return;
	case Pending:
		waitForIstanceState(instanceId, InstanceStateName.Running);
		return;
	case Stopped:
		break;
	case Stopping:
		waitForIstanceState(instanceId, InstanceStateName.Stopped);
		break;
	case ShuttingDown:
	case Terminated:
		throw new IllegalStateException("start: dead instance");
	default:
		throw new IllegalStateException("start: unknown state");
	}

	final StartInstancesRequest request = new StartInstancesRequest();
	request.setInstanceIds(wrapList(instanceId));

	final StartInstancesResult result = amazonClient
			.startInstances(request);

	waitForIstanceState(instanceId, InstanceStateName.Running);

}
 
开发者ID:jwrapper,项目名称:jwrapper-maven-plugin,代码行数:39,代码来源:CarrotElasticCompute.java

示例4: startInstances

import com.amazonaws.services.ec2.model.StartInstancesRequest; //导入方法依赖的package包/类
/**
 * Start instances.
 *
 * @param instanceIds
 *            instances' IDs
 * @return list of instances change
 */
protected final List<InstanceStateChange> startInstances(
        final Collection<String> instanceIds) {
    log.info("Start instances:" + toString(instanceIds));

    StartInstancesRequest request = new StartInstancesRequest();
    request.setInstanceIds(instanceIds);
    StartInstancesResult result = amazonEC2Client.startInstances(request);
    return result.getStartingInstances();
}
 
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:17,代码来源:BaseTest.java

示例5: StartServer

import com.amazonaws.services.ec2.model.StartInstancesRequest; //导入方法依赖的package包/类
public static void StartServer(String keys, JSONObject endpointsAPI, String serverId)
{			
	String accessKey = keys.split(";")[0];
	String secretKey = keys.split(";")[1];
	
	String regionEndpoint = (String) endpointsAPI.get("amazon-regionEndpoint");
	try
	{
		// EC2 Client for given region and credentials
					AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(accessKey, secretKey));
					ec2.setEndpoint(regionEndpoint);
					
					StartInstancesRequest req = new StartInstancesRequest();
					ArrayList<String> list = new ArrayList<String>();
					list.add(serverId);
					req.setInstanceIds(list);
					
					System.out.println("Starting Instance " + serverId);
					ec2.startInstances(req);
					
					return;
					
				}
				catch (AmazonServiceException ase)
				{
					System.out.println("Caught an AmazonServiceException, which means your request made it " + "to AWS, but was rejected with an error response for some reason.");
					System.out.println("Error Message:    " + ase.getMessage());
					System.out.println("HTTP Status Code: " + ase.getStatusCode());
					System.out.println("AWS Error Code:   " + ase.getErrorCode());
					System.out.println("Error Type:       " + ase.getErrorType());
					System.out.println("Request ID:       " + ase.getRequestId());
					return;
					
				} 
				catch (AmazonClientException ace)
				{
					System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with AWS, " + "such as not being able to access the network.");
					System.out.println("Error Message: " + ace.getMessage());
					return;
				}
}
 
开发者ID:tosca-types,项目名称:openstack,代码行数:42,代码来源:AwsUtilities.java


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