Example usage for com.amazonaws.services.ecs.model StopTaskRequest StopTaskRequest

List of usage examples for com.amazonaws.services.ecs.model StopTaskRequest StopTaskRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ecs.model StopTaskRequest StopTaskRequest.

Prototype

StopTaskRequest

Source Link

Usage

From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSService.java

License:Open Source License

void deleteTask(String taskArn, String clusterArn) {
    final AmazonECSClient client = getAmazonECSClient();

    LOGGER.log(Level.INFO, "Delete ECS Slave task: {0}", taskArn);
    try {//  w  w  w.  j  av a  2  s . c  o  m
        client.stopTask(new StopTaskRequest().withTask(taskArn).withCluster(clusterArn));
    } catch (ClientException e) {
        LOGGER.log(Level.SEVERE, "Couldn't stop task arn " + taskArn + " caught exception: " + e.getMessage(),
                e);
    }
}

From source file:com.netflix.spinnaker.clouddriver.ecs.deploy.ops.TerminateInstancesAtomicOperation.java

License:Apache License

@Override
public Void operate(List priorOutputs) {
    updateTaskStatus("Initializing Terminate ECS Instances Operation...");
    AmazonECS ecs = getAmazonEcsClient();

    for (String taskId : description.getEcsTaskIds()) {
        updateTaskStatus("Terminating instance: " + taskId);
        String clusterArn = containerInformationService.getClusterArn(description.getCredentialAccount(),
                description.getRegion(), taskId);
        StopTaskRequest request = new StopTaskRequest().withTask(taskId).withCluster(clusterArn);
        ecs.stopTask(request);/*w w w .j  av a  2  s .  c o  m*/
    }

    return null;
}

From source file:com.remediatetheflag.global.utils.AWSHelper.java

License:Apache License

public void terminateTask(String taskArn) {
    String regionFromArn = taskArn.split(":")[3];
    AmazonECS client = AmazonECSClientBuilder.standard().withRegion(regionFromArn)
            .withCredentials(new DefaultAWSCredentialsProviderChain()).build();
    try {/*ww w.  j a v  a2  s  . c om*/
        StopTaskRequest stopTaskRequest = new StopTaskRequest();
        stopTaskRequest.withCluster(RTFConfig.getExercisesCluster()).withTask(taskArn);
        client.stopTask(stopTaskRequest);
    } catch (Exception e) {
        logger.error("Error terminating task " + e.getMessage());
    }
}

From source file:com.remediatetheflag.global.utils.AWSHelper.java

License:Apache License

public void terminateTask(RTFECSContainerTask ecsInstance) {
    AmazonECS client = AmazonECSClientBuilder.standard().withRegion(ecsInstance.getRegion())
            .withCredentials(new DefaultAWSCredentialsProviderChain()).build();
    try {/*from ww w  . ja v  a  2  s  . c  o m*/
        StopTaskRequest stopTaskRequest = new StopTaskRequest();
        stopTaskRequest.withCluster(RTFConfig.getExercisesCluster()).withTask(ecsInstance.getTaskArn());
        client.stopTask(stopTaskRequest);
    } catch (Exception e) {
        logger.error("Error terminating task " + e.getMessage());
    }
}