bug fix in load balancer

This commit is contained in:
Lili Nader 2010-10-22 17:42:39 -07:00
parent a96d332ea4
commit 3b89b8bcd7
1 changed files with 11 additions and 13 deletions

View File

@ -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<Location, Set<String>> locationMap = Maps.newHashMap();
Set<String> ids = Sets.newHashSet();
Location location = null;
for (NodeMetadata node : Iterables.filter(context.getComputeService().listNodesDetailsMatching(
NodePredicates.all()), Predicates.and(filter, Predicates.not(NodePredicates.TERMINATED)))) {
Set<String> 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<String> 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;
}