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

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

There is a newer version: 5.2.3
Show 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.DetachInstancesRequest;

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

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

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

	@Override
	public Void call() {
		DetachInstancesRequest request = new DetachInstancesRequest()
				.withAutoScalingGroupName(this.autoScalingGroup)
				.withInstanceIds(this.instanceId)
				.withShouldDecrementDesiredCapacity(true);
		getClient().getApi().detachInstances(request);

		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy