diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseLoadBalancerService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseLoadBalancerService.java index d76fb6b704..33e300ed4d 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseLoadBalancerService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseLoadBalancerService.java @@ -101,23 +101,21 @@ public class BaseLoadBalancerService implements LoadBalancerService { checkArgument(protocol.toUpperCase().equals("HTTP") || protocol.toUpperCase().equals("TCP"), "Acceptable values for protocol are HTTP or TCP"); - Map> locationMap = Maps.newHashMap(); + Set ids = Sets.newHashSet(); + Location location = null; for (NodeMetadata node : Iterables.filter(context.getComputeService().listNodesDetailsMatching( - NodePredicates.all()), Predicates.and(filter, Predicates.not(NodePredicates.TERMINATED)))) { - Set ids = locationMap.get(node.getLocation()); - if (ids == null) - ids = Sets.newHashSet(); + NodePredicates.all()), filter)) { ids.add(node.getProviderId()); - locationMap.put(node.getLocation(), ids); + location = node.getLocation(); } Set dnsNames = Sets.newHashSet(); - for (Location location : locationMap.keySet()) { - logger.debug(">> creating load balancer (%s)", loadBalancerName); - String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol, loadBalancerPort, - instancePort, locationMap.get(location)); - dnsNames.add(dnsName); - logger.debug("<< created load balancer (%s) DNS (%s)", loadBalancerName, dnsName); - } + + logger.debug(">> creating load balancer (%s)", loadBalancerName); + String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol, loadBalancerPort, + instancePort, ids); + dnsNames.add(dnsName); + logger.debug("<< created load balancer (%s) DNS (%s)", loadBalancerName, dnsName); + return dnsNames; }