Skip to content

Commit a5432ba

Browse files
committed
limit the number of addresses to try and connect to when doing unicast discovery with just the host and not the port to 5
1 parent 90d005a commit a5432ba

File tree

1 file changed

+4
-2
lines changed
  • modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast

1 file changed

+4
-2
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService
9595
int idCounter = 0;
9696
for (String host : hosts) {
9797
try {
98-
for (TransportAddress address : transportService.addressesFromString(host)) {
99-
nodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", address));
98+
TransportAddress[] addresses = transportService.addressesFromString(host);
99+
// we only limit to 5 addresses, makes no sense to ping 100 ports
100+
for (int i = 0; (i < addresses.length && i < 5); i++) {
101+
nodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", addresses[i]));
100102
}
101103
} catch (Exception e) {
102104
throw new ElasticSearchIllegalArgumentException("Failed to resolve address for [" + host + "]", e);

0 commit comments

Comments
 (0)