All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.elastisys.scale.cloudpool.aws.commons.requests.autoscaling.AttachAutoScalingGroupInstance Maven / Gradle / Ivy

The newest version!
package com.elastisys.scale.cloudpool.aws.commons.requests.autoscaling;

import java.util.concurrent.Callable;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.services.autoscaling.model.AttachInstancesRequest;

/**
 * A {@link Callable} task that, when executed, requests a particular instance
 * to be attached to an Auto Scaling Group. As a side-effect, the desired
 * capacity of the Auto Scaling Group is incremented.
 */
public class AttachAutoScalingGroupInstance extends AmazonAutoScalingRequest {

    /** The name of the Auto Scaling Group. */
    private final String autoScalingGroup;
    /** The machine instance identifier to be attached. */
    private final String instanceId;

    public AttachAutoScalingGroupInstance(AWSCredentials awsCredentials, String region,
            ClientConfiguration clientConfig, String autoScalingGroup, String instanceId) {
        super(awsCredentials, region, clientConfig);
        this.autoScalingGroup = autoScalingGroup;
        this.instanceId = instanceId;
    }

    @Override
    public Void call() {
        AttachInstancesRequest request = new AttachInstancesRequest().withAutoScalingGroupName(this.autoScalingGroup)
                .withInstanceIds(this.instanceId);
        getClient().getApi().attachInstances(request);

        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy