use of com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest in project photon-model by vmware.
the class AWSLoadBalancerServiceTest method getAwsLoadBalancer.
private LoadBalancerDescription getAwsLoadBalancer(String name) {
DescribeLoadBalancersRequest describeRequest = new DescribeLoadBalancersRequest().withLoadBalancerNames(name);
DescribeLoadBalancersResult describeResult = null;
try {
describeResult = this.client.describeLoadBalancers(describeRequest);
} catch (Exception e) {
this.host.log("Exception describing load balancers with name '%s': %s", name, e.toString());
}
Collection<LoadBalancerDescription> lbs = describeResult != null ? describeResult.getLoadBalancerDescriptions() : null;
if (lbs == null || lbs.isEmpty()) {
return null;
}
if (lbs.size() > 1) {
throw new IllegalStateException("More than one load balancers found with name '" + name + "'.");
}
return lbs.iterator().next();
}
use of com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest in project SimianArmy by Netflix.
the class AWSClient method describeElasticLoadBalancers.
/**
* Describe a set of specific ELBs.
*
* @param names the ELB names
* @return the ELBs
*/
public List<LoadBalancerDescription> describeElasticLoadBalancers(String... names) {
if (names == null || names.length == 0) {
LOGGER.info(String.format("Getting all ELBs in region %s.", region));
} else {
LOGGER.info(String.format("Getting ELBs for %d names in region %s.", names.length, region));
}
AmazonElasticLoadBalancingClient elbClient = elbClient();
DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest().withLoadBalancerNames(names);
DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request);
List<LoadBalancerDescription> elbs = result.getLoadBalancerDescriptions();
LOGGER.info(String.format("Got %d ELBs in region %s.", elbs.size(), region));
return elbs;
}
use of com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest in project ignite by apache.
the class TcpDiscoveryElbIpFinder method getRegisteredAddresses.
/**
* {@inheritDoc}
*/
@Override
public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException {
initClients();
List<String> instanceIds = new ArrayList<>();
DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest().withLoadBalancerNames(loadBalancerName);
List<LoadBalancerDescription> descs = amazonELBClient.describeLoadBalancers(req).getLoadBalancerDescriptions();
for (LoadBalancerDescription desc : descs) {
for (Instance instance : desc.getInstances()) instanceIds.add(instance.getInstanceId());
}
DescribeInstancesRequest instReq = new DescribeInstancesRequest().withInstanceIds(instanceIds);
List<Reservation> reservations = amazonEC2Client.describeInstances(instReq).getReservations();
List<InetSocketAddress> addrs = new ArrayList<>();
for (Reservation reservation : reservations) {
List<com.amazonaws.services.ec2.model.Instance> instances = reservation.getInstances();
for (com.amazonaws.services.ec2.model.Instance instance : instances) addrs.add(new InetSocketAddress(instance.getPrivateIpAddress(), 0));
}
return addrs;
}
use of com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest in project photon-model by vmware.
the class AWSLoadBalancerService method getAWSLoadBalancer.
private DeferredResult<AWSLoadBalancerContext> getAWSLoadBalancer(AWSLoadBalancerContext context) {
DescribeLoadBalancersRequest describeRequest = new DescribeLoadBalancersRequest().withLoadBalancerNames(context.loadBalancerStateExpanded.name);
String message = "Describing AWS load balancer [" + context.loadBalancerStateExpanded.name + "].";
AWSDeferredResultAsyncHandler<DescribeLoadBalancersRequest, DescribeLoadBalancersResult> handler = new AWSDeferredResultAsyncHandler<>(this, message);
context.client.describeLoadBalancersAsync(describeRequest, handler);
return handler.toDeferredResult().thenCompose(result -> {
List<com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription> lbs = result.getLoadBalancerDescriptions();
if (lbs != null && !lbs.isEmpty() && lbs.size() == 1) {
context.registeredInstances = lbs.iterator().next().getInstances();
return DeferredResult.completed(context);
}
return DeferredResult.failed(new IllegalStateException("Unable to describe load balancer with name '" + context.loadBalancerStateExpanded.name + "' for update"));
});
}
use of com.amazonaws.services.elasticloadbalancing.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());
}
Aggregations