limit the number of addresses to try and connect to when doing unicast discovery with just the host and not the port to 5

This commit is contained in:
kimchy 2011-01-11 00:53:20 +02:00
parent 90d005a330
commit a5432ba7ce
1 changed files with 4 additions and 2 deletions

View File

@ -95,8 +95,10 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
int idCounter = 0; int idCounter = 0;
for (String host : hosts) { for (String host : hosts) {
try { try {
for (TransportAddress address : transportService.addressesFromString(host)) { TransportAddress[] addresses = transportService.addressesFromString(host);
nodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", address)); // we only limit to 5 addresses, makes no sense to ping 100 ports
for (int i = 0; (i < addresses.length && i < 5); i++) {
nodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", addresses[i]));
} }
} catch (Exception e) { } catch (Exception e) {
throw new ElasticSearchIllegalArgumentException("Failed to resolve address for [" + host + "]", e); throw new ElasticSearchIllegalArgumentException("Failed to resolve address for [" + host + "]", e);