Search in sources :

Example 1 with TargetGroupNotFoundException

use of com.amazonaws.services.elasticloadbalancingv2.model.TargetGroupNotFoundException in project titus-control-plane by Netflix.

the class AwsLoadBalancerConnector method getLoadBalancer.

@Override
public Single<LoadBalancer> getLoadBalancer(String loadBalancerId) {
    final DescribeTargetHealthRequest request = new DescribeTargetHealthRequest().withTargetGroupArn(loadBalancerId);
    long startTime = registry.clock().wallTime();
    Single<DescribeTargetHealthResult> asyncResult = AwsObservableExt.asyncActionSingle(factory -> getClient(loadBalancerId).describeTargetHealthAsync(request, factory.handler()));
    return asyncResult.observeOn(scheduler).map(result -> {
        connectorMetrics.success(AwsLoadBalancerConnectorMetrics.AwsLoadBalancerMethods.DescribeTargetHealth, startTime);
        Set<String> ips = result.getTargetHealthDescriptions().stream().map(description -> description.getTarget().getId()).collect(Collectors.toSet());
        return new LoadBalancer(loadBalancerId, LoadBalancer.State.ACTIVE, ips);
    }).onErrorResumeNext(throwable -> {
        connectorMetrics.failure(AwsLoadBalancerConnectorMetrics.AwsLoadBalancerMethods.DescribeTargetHealth, throwable, startTime);
        if (throwable instanceof TargetGroupNotFoundException) {
            return Single.just(new LoadBalancer(loadBalancerId, LoadBalancer.State.REMOVED, Collections.emptySet()));
        }
        return Single.error(throwable);
    });
}
Also used : DescribeTargetHealthRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthRequest) Completable(rx.Completable) LoadBalancerConnector(com.netflix.titus.api.connector.cloud.LoadBalancerConnector) DeregisterTargetsRequest(com.amazonaws.services.elasticloadbalancingv2.model.DeregisterTargetsRequest) RegisterTargetsRequest(com.amazonaws.services.elasticloadbalancingv2.model.RegisterTargetsRequest) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) ProxyType(com.netflix.titus.common.util.guice.ProxyType) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) Observable(rx.Observable) Inject(javax.inject.Inject) TargetGroupNotFoundException(com.amazonaws.services.elasticloadbalancingv2.model.TargetGroupNotFoundException) Single(rx.Single) DescribeTargetGroupsRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest) CloudConnectorException(com.netflix.titus.api.connector.cloud.CloudConnectorException) Schedulers(rx.schedulers.Schedulers) AmazonElasticLoadBalancingAsync(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingAsync) TargetDescription(com.amazonaws.services.elasticloadbalancingv2.model.TargetDescription) DescribeTargetGroupsResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult) Logger(org.slf4j.Logger) DescribeTargetHealthResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthResult) AmazonClientProvider(com.netflix.titus.ext.aws.AmazonClientProvider) Set(java.util.Set) LoadBalancer(com.netflix.titus.api.connector.cloud.LoadBalancer) AwsObservableExt(com.netflix.titus.ext.aws.AwsObservableExt) Scheduler(rx.Scheduler) Collectors(java.util.stream.Collectors) Registry(com.netflix.spectator.api.Registry) ProxyConfiguration(com.netflix.titus.common.util.guice.annotation.ProxyConfiguration) Arn(com.amazonaws.arn.Arn) Collections(java.util.Collections) DescribeTargetHealthRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthRequest) Set(java.util.Set) TargetGroupNotFoundException(com.amazonaws.services.elasticloadbalancingv2.model.TargetGroupNotFoundException) LoadBalancer(com.netflix.titus.api.connector.cloud.LoadBalancer) DescribeTargetHealthResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthResult)

Aggregations

Arn (com.amazonaws.arn.Arn)1 AmazonElasticLoadBalancingAsync (com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingAsync)1 DeregisterTargetsRequest (com.amazonaws.services.elasticloadbalancingv2.model.DeregisterTargetsRequest)1 DescribeTargetGroupsRequest (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest)1 DescribeTargetGroupsResult (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult)1 DescribeTargetHealthRequest (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthRequest)1 DescribeTargetHealthResult (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetHealthResult)1 RegisterTargetsRequest (com.amazonaws.services.elasticloadbalancingv2.model.RegisterTargetsRequest)1 TargetDescription (com.amazonaws.services.elasticloadbalancingv2.model.TargetDescription)1 TargetGroupNotFoundException (com.amazonaws.services.elasticloadbalancingv2.model.TargetGroupNotFoundException)1 Registry (com.netflix.spectator.api.Registry)1 CloudConnectorException (com.netflix.titus.api.connector.cloud.CloudConnectorException)1 LoadBalancer (com.netflix.titus.api.connector.cloud.LoadBalancer)1 LoadBalancerConnector (com.netflix.titus.api.connector.cloud.LoadBalancerConnector)1 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)1 ProxyType (com.netflix.titus.common.util.guice.ProxyType)1 ProxyConfiguration (com.netflix.titus.common.util.guice.annotation.ProxyConfiguration)1 AmazonClientProvider (com.netflix.titus.ext.aws.AmazonClientProvider)1 AwsObservableExt (com.netflix.titus.ext.aws.AwsObservableExt)1 Collections (java.util.Collections)1