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"), checkArgument(protocol.toUpperCase().equals("HTTP") || protocol.toUpperCase().equals("TCP"),
"Acceptable values for protocol are HTTP or 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( for (NodeMetadata node : Iterables.filter(context.getComputeService().listNodesDetailsMatching(
NodePredicates.all()), Predicates.and(filter, Predicates.not(NodePredicates.TERMINATED)))) { NodePredicates.all()), filter)) {
Set<String> ids = locationMap.get(node.getLocation());
if (ids == null)
ids = Sets.newHashSet();
ids.add(node.getProviderId()); ids.add(node.getProviderId());
locationMap.put(node.getLocation(), ids); location = node.getLocation();
} }
Set<String> dnsNames = Sets.newHashSet(); Set<String> dnsNames = Sets.newHashSet();
for (Location location : locationMap.keySet()) {
logger.debug(">> creating load balancer (%s)", loadBalancerName); logger.debug(">> creating load balancer (%s)", loadBalancerName);
String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol, loadBalancerPort, String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol, loadBalancerPort,
instancePort, locationMap.get(location)); instancePort, ids);
dnsNames.add(dnsName); dnsNames.add(dnsName);
logger.debug("<< created load balancer (%s) DNS (%s)", loadBalancerName, dnsName); logger.debug("<< created load balancer (%s) DNS (%s)", loadBalancerName, dnsName);
}
return dnsNames; return dnsNames;
} }