use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollector method collectLoadBalancer.
@Override
public List<CloudLoadBalancerMetadata> collectLoadBalancer(AuthenticatedContext ac, List<LoadBalancerType> lbTypes, List<CloudResource> resources) {
List<CloudLoadBalancerMetadata> result = new ArrayList<>();
String region = ac.getCloudContext().getLocation().getRegion().value();
AwsCredentialView awsCredential = new AwsCredentialView(ac.getCloudCredential());
LOGGER.debug("Collect AWS load balancer metadata, for cluster {}", ac.getCloudContext().getName());
Set<CloudResource> loadBalancers = resources.stream().filter(resource -> ResourceType.ELASTIC_LOAD_BALANCER.equals(resource.getType())).collect(Collectors.toSet());
Set<String> loadBalancerArns = loadBalancers.stream().map(CloudResource::getReference).collect(Collectors.toSet());
AmazonElasticLoadBalancingClient loadBalancingClient = awsClient.createElasticLoadBalancingClient(awsCredential, region);
LOGGER.info("Collect AWS load balancer metadata, in region '{}' with ARNs: '{}'", region, String.join(", ", loadBalancerArns));
for (String loadBalancerArn : loadBalancerArns) {
Optional<CloudLoadBalancerMetadata> collectedLoadBalancer = collectLoadBalancerMetadata(loadBalancingClient, loadBalancerArn, resources);
collectedLoadBalancer.ifPresent(result::add);
}
return result;
}
Aggregations