Search in sources :

Example 6 with InstanceGroup

use of com.netflix.titus.api.connector.cloud.InstanceGroup in project titus-control-plane by Netflix.

the class AwsInstanceCloudConnector method doDetach.

private Completable doDetach(String instanceGroup, List<String> instanceIds, boolean shrink) {
    DetachInstancesRequest request = new DetachInstancesRequest().withAutoScalingGroupName(instanceGroup).withInstanceIds(instanceIds).withShouldDecrementDesiredCapacity(shrink);
    Observable<DetachInstancesResult> observable = toObservable(request, autoScalingClient::detachInstancesAsync);
    return observable.doOnCompleted(() -> logger.info("Detached instances: {}", instanceIds)).doOnError(e -> logger.warn("Failed to detach instances: {}, due to {}", instanceIds, e.getMessage())).toCompletable();
}
Also used : InstanceLaunchConfiguration(com.netflix.titus.api.connector.cloud.InstanceLaunchConfiguration) BiFunction(java.util.function.BiFunction) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) TerminateInstancesResult(com.amazonaws.services.ec2.model.TerminateInstancesResult) LoggerFactory(org.slf4j.LoggerFactory) DescribeLaunchConfigurationsResult(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult) Collections.singletonList(java.util.Collections.singletonList) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) CreateTagsRequest(com.amazonaws.services.ec2.model.CreateTagsRequest) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) CloudConnectorException(com.netflix.titus.api.connector.cloud.CloudConnectorException) Map(java.util.Map) Schedulers(rx.schedulers.Schedulers) Either(com.netflix.titus.common.util.tuple.Either) ResourceDimension(com.netflix.titus.api.model.ResourceDimension) Reservation(com.amazonaws.services.ec2.model.Reservation) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Scheduler(rx.Scheduler) Collectors(java.util.stream.Collectors) List(java.util.List) AutoScalingInstanceDetails(com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails) UpdateAutoScalingGroupResult(com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult) Tag(com.amazonaws.services.ec2.model.Tag) ProxyConfiguration(com.netflix.titus.common.util.guice.annotation.ProxyConfiguration) Optional(java.util.Optional) ObservableExt(com.netflix.titus.common.util.rx.ObservableExt) Completable(rx.Completable) AwsInstanceType(com.netflix.titus.common.aws.AwsInstanceType) ProxyType(com.netflix.titus.common.util.guice.ProxyType) Singleton(javax.inject.Singleton) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Observable(rx.Observable) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) UpdateAutoScalingGroupRequest(com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupRequest) Pair(com.netflix.titus.common.util.tuple.Pair) InstanceCloudConnector(com.netflix.titus.api.connector.cloud.InstanceCloudConnector) AwsInstanceDescriptor(com.netflix.titus.common.aws.AwsInstanceDescriptor) DescribeAutoScalingInstancesResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingInstancesResult) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) Filter(com.amazonaws.services.ec2.model.Filter) Named(javax.inject.Named) TagDescription(com.amazonaws.services.autoscaling.model.TagDescription) Instance(com.netflix.titus.api.connector.cloud.Instance) AmazonWebServiceRequest(com.amazonaws.AmazonWebServiceRequest) Logger(org.slf4j.Logger) DescribeLaunchConfigurationsRequest(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest) DetachInstancesRequest(com.amazonaws.services.autoscaling.model.DetachInstancesRequest) InstanceState(com.netflix.titus.api.connector.cloud.Instance.InstanceState) SuspendedProcess(com.amazonaws.services.autoscaling.model.SuspendedProcess) CreateTagsResult(com.amazonaws.services.ec2.model.CreateTagsResult) AmazonEC2Async(com.amazonaws.services.ec2.AmazonEC2Async) Mono(reactor.core.publisher.Mono) TerminateInstancesRequest(com.amazonaws.services.ec2.model.TerminateInstancesRequest) Emitter(rx.Emitter) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) Activator(com.netflix.titus.common.util.guice.annotation.Activator) TimeUnit(java.util.concurrent.TimeUnit) DescribeAutoScalingInstancesRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingInstancesRequest) AsyncHandler(com.amazonaws.handlers.AsyncHandler) AmazonEC2Exception(com.amazonaws.services.ec2.model.AmazonEC2Exception) InstanceGroup(com.netflix.titus.api.connector.cloud.InstanceGroup) AmazonAutoScalingAsync(com.amazonaws.services.autoscaling.AmazonAutoScalingAsync) Collections(java.util.Collections) DetachInstancesResult(com.amazonaws.services.autoscaling.model.DetachInstancesResult) LaunchConfiguration(com.amazonaws.services.autoscaling.model.LaunchConfiguration) DetachInstancesResult(com.amazonaws.services.autoscaling.model.DetachInstancesResult) DetachInstancesRequest(com.amazonaws.services.autoscaling.model.DetachInstancesRequest)

Aggregations

InstanceGroup (com.netflix.titus.api.connector.cloud.InstanceGroup)6 SuspendedProcess (com.amazonaws.services.autoscaling.model.SuspendedProcess)4 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)4 Instance (com.netflix.titus.api.connector.cloud.Instance)4 AmazonWebServiceRequest (com.amazonaws.AmazonWebServiceRequest)3 AsyncHandler (com.amazonaws.handlers.AsyncHandler)3 AmazonAutoScalingAsync (com.amazonaws.services.autoscaling.AmazonAutoScalingAsync)3 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)3 AutoScalingInstanceDetails (com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails)3 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)3 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)3 DescribeAutoScalingInstancesRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingInstancesRequest)3 DescribeAutoScalingInstancesResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingInstancesResult)3 DescribeLaunchConfigurationsRequest (com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest)3 DescribeLaunchConfigurationsResult (com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult)3 DetachInstancesRequest (com.amazonaws.services.autoscaling.model.DetachInstancesRequest)3 DetachInstancesResult (com.amazonaws.services.autoscaling.model.DetachInstancesResult)3 LaunchConfiguration (com.amazonaws.services.autoscaling.model.LaunchConfiguration)3 UpdateAutoScalingGroupRequest (com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupRequest)3 UpdateAutoScalingGroupResult (com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult)3