Search in sources :

Example 1 with DescribeLoadBalancersRequest

use of com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest in project cloudbreak by hortonworks.

the class AwsNativeMetadataCollector method describeLoadBalancer.

private Optional<CloudLoadBalancerMetadata> describeLoadBalancer(String loadBalancerArn, AmazonElasticLoadBalancingClient loadBalancingClient, List<CloudResource> resources) {
    DescribeLoadBalancersRequest describeLoadBalancersRequest = new DescribeLoadBalancersRequest().withLoadBalancerArns(loadBalancerArn);
    DescribeLoadBalancersResult describeLoadBalancersResult = loadBalancingClient.describeLoadBalancers(describeLoadBalancersRequest);
    return describeLoadBalancersResult.getLoadBalancers().stream().findFirst().map(loadBalancer -> {
        LoadBalancerType type = loadBalancerTypeConverter.convert(loadBalancer.getScheme());
        Map<String, Object> parameters = awsNativeLbMetadataCollector.getParameters(loadBalancerArn, resources);
        CloudLoadBalancerMetadata loadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withType(type).withCloudDns(loadBalancer.getDNSName()).withHostedZoneId(loadBalancer.getCanonicalHostedZoneId()).withName(loadBalancer.getLoadBalancerName()).withParameters(parameters).build();
        LOGGER.info("Saved metadata for load balancer {}: DNS {}, zone ID {}", loadBalancer.getLoadBalancerName(), loadBalancer.getDNSName(), loadBalancer.getCanonicalHostedZoneId());
        return loadBalancerMetadata;
    });
}
Also used : DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersResult) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata)

Example 2 with DescribeLoadBalancersRequest

use of com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest in project iep by Netflix.

the class PaginationTest method elb.

@Test
public void elb() throws Exception {
    SortedSet<String> pages = newPageSet(5);
    final Iterator<String> reqIt = pages.iterator();
    final Iterator<String> resIt = pages.iterator();
    Function<DescribeLoadBalancersRequest, DescribeLoadBalancersResult> f = r -> {
        if (r.getMarker() != null) {
            Assert.assertEquals(reqIt.next(), r.getMarker());
        }
        return new DescribeLoadBalancersResult().withNextMarker(resIt.hasNext() ? resIt.next() : null);
    };
    Publisher<DescribeLoadBalancersResult> publisher = Pagination.createPublisher(new DescribeLoadBalancersRequest(), f);
    Iterable<String> iter = Flowable.fromPublisher(publisher).filter(r -> r.getNextMarker() != null).map(DescribeLoadBalancersResult::getNextMarker).blockingIterable();
    SortedSet<String> results = new TreeSet<>();
    for (String s : iter) {
        results.add(s);
    }
    Assert.assertEquals(pages, results);
    Assert.assertFalse(reqIt.hasNext());
}
Also used : ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) ListMetricsRequest(com.amazonaws.services.cloudwatch.model.ListMetricsRequest) SortedSet(java.util.SortedSet) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ListMetricsResult(com.amazonaws.services.cloudwatch.model.ListMetricsResult) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest) Function(java.util.function.Function) TreeSet(java.util.TreeSet) PutMetricDataRequest(com.amazonaws.services.cloudwatch.model.PutMetricDataRequest) DescribeTargetGroupsRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest) Flowable(io.reactivex.Flowable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) ListClustersResult(com.amazonaws.services.elasticmapreduce.model.ListClustersResult) DescribeTargetGroupsResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult) Iterator(java.util.Iterator) ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) Publisher(org.reactivestreams.Publisher) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) ListResourceRecordSetsResult(com.amazonaws.services.route53.model.ListResourceRecordSetsResult) ListHostedZonesRequest(com.amazonaws.services.route53.model.ListHostedZonesRequest) ListClustersRequest(com.amazonaws.services.elasticmapreduce.model.ListClustersRequest) DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult) PutMetricDataResult(com.amazonaws.services.cloudwatch.model.PutMetricDataResult) Assert(org.junit.Assert) ListResourceRecordSetsRequest(com.amazonaws.services.route53.model.ListResourceRecordSetsRequest) DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult) TreeSet(java.util.TreeSet) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest) Test(org.junit.Test)

Example 3 with DescribeLoadBalancersRequest

use of com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest in project cloudbreak by hortonworks.

the class CloudFormationStackUtil method getLoadBalancerByLogicalId.

public LoadBalancer getLoadBalancerByLogicalId(AuthenticatedContext ac, String logicalId) {
    String region = ac.getCloudContext().getLocation().getRegion().value();
    AmazonElasticLoadBalancingClient amazonElbClient = awsClient.createElasticLoadBalancingClient(new AwsCredentialView(ac.getCloudCredential()), region);
    String loadBalancerArn = getResourceArnByLogicalId(ac, logicalId, region);
    DescribeLoadBalancersResult loadBalancersResult = amazonElbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerArns(Collections.singletonList(loadBalancerArn)));
    return loadBalancersResult.getLoadBalancers().get(0);
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersResult) AmazonElasticLoadBalancingClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest)

Aggregations

DescribeLoadBalancersRequest (com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest)2 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersResult)2 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)1 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)1 ListMetricsRequest (com.amazonaws.services.cloudwatch.model.ListMetricsRequest)1 ListMetricsResult (com.amazonaws.services.cloudwatch.model.ListMetricsResult)1 PutMetricDataRequest (com.amazonaws.services.cloudwatch.model.PutMetricDataRequest)1 PutMetricDataResult (com.amazonaws.services.cloudwatch.model.PutMetricDataResult)1 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)1 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)1 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)1 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 DescribeLoadBalancersRequest (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest)1 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult)1 DescribeTargetGroupsRequest (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest)1 DescribeTargetGroupsResult (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult)1 ListClustersRequest (com.amazonaws.services.elasticmapreduce.model.ListClustersRequest)1 ListClustersResult (com.amazonaws.services.elasticmapreduce.model.ListClustersResult)1 ListHostedZonesRequest (com.amazonaws.services.route53.model.ListHostedZonesRequest)1