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);
});
}
Aggregations