From 5258b505eb9ddff63e1bd765ded8368c5fe7ea02 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 11 Dec 2011 16:24:12 +0200 Subject: [PATCH] Multicast: Add discovery.zen.ping.multicast.send_ping setting to disable sending ping requests while still having multicast enabled, closes #1479. --- .../zen/ping/multicast/MulticastZenPing.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java b/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java index eaf99c34d5e..7878e979bff 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java @@ -75,6 +75,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem private final NetworkService networkService; + private final boolean sendPing; + private volatile DiscoveryNodesProvider nodesProvider; @@ -113,6 +115,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem this.bufferSize = componentSettings.getAsInt("buffer_size", 2048); this.ttl = componentSettings.getAsInt("ttl", 3); + this.sendPing = componentSettings.getAsBoolean("send_ping", true); + logger.debug("using group [{}], with port [{}], ttl [{}], and address [{}]", group, port, ttl, address); this.transportService.registerHandler(MulticastPingResponseRequestHandler.ACTION, new MulticastPingResponseRequestHandler()); @@ -221,6 +225,15 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem @Override public void ping(final PingListener listener, final TimeValue timeout) { + if (!sendPing) { + threadPool.cached().execute(new Runnable() { + @Override + public void run() { + listener.onPing(new PingResponse[0]); + } + }); + return; + } final int id = pingIdGenerator.incrementAndGet(); receivedResponses.put(id, new ConcurrentHashMap()); sendPingRequest(id, true);