Package com.amazonaws.services.ec2

Examples of com.amazonaws.services.ec2.AmazonEC2Client


   * @return list of newly launched instances
   */
  public static List<Instance> launchInstance(String AMI_ID, String type, Integer number) {
    List<Instance> resultList = new ArrayList<Instance>();

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here


   * @return list of newly launched instances
   */
  public static List<Instance> launchInstance(String AMI_ID, String type, Integer number, String keyname) {
    List<Instance> resultList = new ArrayList<Instance>();

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);
    request.setKeyName(keyname);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here

  }
 

  private List<Instance> startInstances(AmazonEC2Client ec2, String AMI_ID, String INS_TYPE, NotificationService notifier) throws AmazonServiceException {
    // start only 1 instance
    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, 1, 1);
    request.setKeyName(KEY_PAIR_NAME);
    request.setInstanceType(INS_TYPE);

    RunInstancesResult result = ec2.runInstances(request);

    List<Instance> instances = result.getReservation().getInstances();
View Full Code Here

    List<Instance> resultList = new ArrayList<Instance>();

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);
    request.setKeyName(keyname);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here

    // start only 1 instance
    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, 1, 1);
    request.setKeyName(KEY_PAIR_NAME);
    request.setInstanceType(INS_TYPE);

    RunInstancesResult result = ec2.runInstances(request);

    List<Instance> instances = result.getReservation().getInstances();

    while (!allInstancesStateEqual(instances, InstanceStateName.Running)) {

      // instance status should not be Terminated
      if (anyInstancesStateEqual(instances, InstanceStateName.Terminated)) {
View Full Code Here

    return additionalWorkerAllocated;
  }

  private void launchInstance(String instanceId)
  {
    StartInstancesRequest startInstancesRequest = new StartInstancesRequest();
    List<String> instancesIdsToLaunch = new ArrayList<String>();
    instancesIdsToLaunch.add(instanceId);
    startInstancesRequest.setInstanceIds(instancesIdsToLaunch);
    ec2Client.startInstances(startInstancesRequest);
    updateInstanceState(instanceId, "running");
  }
View Full Code Here

  public void stopInstance() throws ClientProtocolException, IOException
  {
    String instanceId = getInstanceId();
    List<String> instancesId = new ArrayList<String>();
    instancesId.add(instanceId);
    StopInstancesRequest stopInstancesRequest = new StopInstancesRequest(instancesId);
    amazonEC2Client.stopInstances(stopInstancesRequest);
  }
View Full Code Here

   *
   * @param instanceIds
   */
  public static void terminateInstances(List<String> instanceIds) {
    // terminate
    TerminateInstancesRequest request = new TerminateInstancesRequest(instanceIds);
    getEC2Client().terminateInstances(request);
  }
View Full Code Here

   *
   * @param instanceIds
   */
  public static void terminateInstances(String... instanceIds) {
    // terminate
    TerminateInstancesRequest request = new TerminateInstancesRequest();
    getEC2Client().terminateInstances(request.withInstanceIds(instanceIds));
  }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.ec2.AmazonEC2Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.