Example usage for com.amazonaws.services.ec2.model TerminateInstancesRequest TerminateInstancesRequest

List of usage examples for com.amazonaws.services.ec2.model TerminateInstancesRequest TerminateInstancesRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model TerminateInstancesRequest TerminateInstancesRequest.

Prototype

public TerminateInstancesRequest(java.util.List<String> instanceIds) 

Source Link

Document

Constructs a new TerminateInstancesRequest object.

Usage

From source file:io.druid.indexing.overlord.autoscaling.ec2.EC2AutoScaler.java

License:Apache License

@Override
public AutoScalingData terminateWithIds(List<String> ids) {
    if (ids.isEmpty()) {
        return new AutoScalingData(Lists.<String>newArrayList());
    }/*from ww  w.j  a v a  2  s  . c  o m*/

    try {
        log.info("Terminating instances[%s]", ids);
        amazonEC2Client.terminateInstances(new TerminateInstancesRequest(ids));

        return new AutoScalingData(ids);
    } catch (Exception e) {
        log.error(e, "Unable to terminate any instances.");
    }

    return null;
}

From source file:io.pivotal.strepsirrhini.chaoslemur.infrastructure.AwsInfrastructure.java

License:Apache License

@Override
public void destroy(Member member) throws DestructionException {
    List<String> terminate = new ArrayList<>();
    terminate.add(member.getId());/*  w w  w .ja  va 2  s.c  om*/
    TerminateInstancesRequest tir = new TerminateInstancesRequest(terminate);
    this.amazonEC2.terminateInstances(tir);
}

From source file:jp.classmethod.aws.gradle.ec2.AmazonEC2TerminateInstanceTask.java

License:Apache License

@TaskAction
public void terminateInstance() {
    // to enable conventionMappings feature
    List<String> instanceIds = getInstanceIds();

    if (instanceIds.isEmpty()) {
        return;/* w  w  w  .  java  2  s  .  c  o  m*/
    }

    AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class);
    AmazonEC2 ec2 = ext.getClient();

    terminateInstancesResult = ec2.terminateInstances(new TerminateInstancesRequest(instanceIds));
    getLogger().info("Terminate EC2 instance {} requested", instanceIds);
}

From source file:org.apache.airavata.gfac.ec2.AmazonUtil.java

License:Apache License

/**
 * Terminate instances//  www . j  av  a2  s .c om
 *
 * @param instanceIds instance ids of the running instances.
 */
public static void terminateInstances(List<String> instanceIds) {
    // terminate
    TerminateInstancesRequest request = new TerminateInstancesRequest(instanceIds);
    getEC2Client().terminateInstances(request);
}

From source file:org.apache.druid.indexing.overlord.autoscaling.ec2.EC2AutoScaler.java

License:Apache License

@Override
public AutoScalingData terminateWithIds(List<String> ids) {
    if (ids.isEmpty()) {
        return new AutoScalingData(new ArrayList<>());
    }/*from  ww  w . j a va  2  s . c  o m*/

    try {
        log.info("Terminating instances[%s]", ids);
        amazonEC2Client.terminateInstances(new TerminateInstancesRequest(ids));

        return new AutoScalingData(ids);
    } catch (Exception e) {
        log.error(e, "Unable to terminate any instances.");
    }

    return null;
}

From source file:org.openinfinity.cloud.service.administrator.EC2Wrapper.java

License:Apache License

public boolean terminateInstance(String instanceId) {
    try {/*w  ww .  j a  v  a 2 s. c o  m*/
        ArrayList<String> instances = new ArrayList<String>();
        instances.add(instanceId);
        TerminateInstancesRequest terminateReq = new TerminateInstancesRequest(instances);
        ec2.terminateInstances(terminateReq);
    } catch (Exception e) {
        String message = e.getMessage();
        LOG.error("Error terminating instance (" + instanceId + "): " + message);
        ExceptionUtil.throwSystemException(message, e);
    }
    return true;

}

From source file:org.xmlsh.aws.gradle.ec2.AmazonEC2TerminateInstanceTask.java

License:BSD License

@TaskAction
public void terminateInstance() {
    // to enable conventionMappings feature
    List<String> instanceIds = getInstanceIds();

    if (instanceIds.isEmpty())
        return;/*from  ww w  .j a v  a 2s  .co  m*/

    AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class);
    AmazonEC2 ec2 = ext.getClient();

    terminateInstancesResult = ec2.terminateInstances(new TerminateInstancesRequest(instanceIds));
    getLogger().info("Terminate EC2 instance {} requested", instanceIds);
}

From source file:web.component.impl.aws.AWSEC2Impl.java

@Override
public TerminateInstancesResult terminateInstances(List<String> instanceIds) {
    return terminateInstances(new TerminateInstancesRequest(instanceIds));
}