Search in sources :

Example 1 with DescribeLaunchConfigurationsRequest

use of com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest in project cloudbreak by hortonworks.

the class LaunchConfigurationHandler method getLaunchConfigurations.

public List<LaunchConfiguration> getLaunchConfigurations(AmazonAutoScalingClient autoScalingClient, Collection<AutoScalingGroup> scalingGroups) {
    DescribeLaunchConfigurationsRequest launchConfigurationsRequest = new DescribeLaunchConfigurationsRequest();
    launchConfigurationsRequest.setLaunchConfigurationNames(scalingGroups.stream().map(AutoScalingGroup::getLaunchConfigurationName).collect(Collectors.toList()));
    return autoScalingClient.describeLaunchConfigurations(launchConfigurationsRequest).getLaunchConfigurations();
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) DescribeLaunchConfigurationsRequest(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest)

Example 2 with DescribeLaunchConfigurationsRequest

use of com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest in project cloudbreak by hortonworks.

the class LaunchConfigurationHandlerTest method getLaunchConfigurations.

@Test
public void getLaunchConfigurations() {
    when(autoScalingClient.describeLaunchConfigurations(any(DescribeLaunchConfigurationsRequest.class))).thenReturn(new DescribeLaunchConfigurationsResult());
    Collection<AutoScalingGroup> autoScalingGroups = Lists.newArrayList(new AutoScalingGroup().withLaunchConfigurationName("a"), new AutoScalingGroup().withLaunchConfigurationName("b"));
    underTest.getLaunchConfigurations(autoScalingClient, autoScalingGroups);
    ArgumentCaptor<DescribeLaunchConfigurationsRequest> captor = ArgumentCaptor.forClass(DescribeLaunchConfigurationsRequest.class);
    verify(autoScalingClient, times(1)).describeLaunchConfigurations(captor.capture());
    assertEquals(autoScalingGroups.size(), captor.getValue().getLaunchConfigurationNames().size());
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) DescribeLaunchConfigurationsRequest(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest) DescribeLaunchConfigurationsResult(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult) Test(org.junit.Test)

Example 3 with DescribeLaunchConfigurationsRequest

use of com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest in project titus-control-plane by Netflix.

the class AwsInstanceCloudConnector method getInstanceLaunchConfiguration.

@Override
public Observable<List<InstanceLaunchConfiguration>> getInstanceLaunchConfiguration(List<String> launchConfigurationIds) {
    if (launchConfigurationIds.isEmpty()) {
        return Observable.just(Collections.emptyList());
    }
    DescribeLaunchConfigurationsRequest request = new DescribeLaunchConfigurationsRequest().withLaunchConfigurationNames(launchConfigurationIds);
    Observable<DescribeLaunchConfigurationsResult> observable = toObservable(request, autoScalingClient::describeLaunchConfigurationsAsync);
    return observable.map(response -> toInstanceLaunchConfigurations(response.getLaunchConfigurations())).timeout(configuration.getAwsRequestTimeoutMs(), TimeUnit.MILLISECONDS);
}
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) DescribeLaunchConfigurationsRequest(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest) DescribeLaunchConfigurationsResult(com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult)

Aggregations

AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)3 DescribeLaunchConfigurationsRequest (com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest)3 DescribeLaunchConfigurationsResult (com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult)2 AmazonWebServiceRequest (com.amazonaws.AmazonWebServiceRequest)1 AsyncHandler (com.amazonaws.handlers.AsyncHandler)1 AmazonAutoScalingAsync (com.amazonaws.services.autoscaling.AmazonAutoScalingAsync)1 AutoScalingInstanceDetails (com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails)1 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)1 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)1 DescribeAutoScalingInstancesRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingInstancesRequest)1 DescribeAutoScalingInstancesResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingInstancesResult)1 DetachInstancesRequest (com.amazonaws.services.autoscaling.model.DetachInstancesRequest)1 DetachInstancesResult (com.amazonaws.services.autoscaling.model.DetachInstancesResult)1 LaunchConfiguration (com.amazonaws.services.autoscaling.model.LaunchConfiguration)1 SuspendedProcess (com.amazonaws.services.autoscaling.model.SuspendedProcess)1 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)1 UpdateAutoScalingGroupRequest (com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupRequest)1 UpdateAutoScalingGroupResult (com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult)1 AmazonEC2Async (com.amazonaws.services.ec2.AmazonEC2Async)1 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)1