Multicast: Add discovery.zen.ping.multicast.send_ping setting to disable sending ping requests while still having multicast enabled, closes #1479.

This commit is contained in:
Shay Banon 2011-12-11 16:24:12 +02:00
parent 3a363976ed
commit 5258b505eb
1 changed files with 13 additions and 0 deletions

View File

@ -75,6 +75,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
private final NetworkService networkService; private final NetworkService networkService;
private final boolean sendPing;
private volatile DiscoveryNodesProvider nodesProvider; private volatile DiscoveryNodesProvider nodesProvider;
@ -113,6 +115,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
this.bufferSize = componentSettings.getAsInt("buffer_size", 2048); this.bufferSize = componentSettings.getAsInt("buffer_size", 2048);
this.ttl = componentSettings.getAsInt("ttl", 3); 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); logger.debug("using group [{}], with port [{}], ttl [{}], and address [{}]", group, port, ttl, address);
this.transportService.registerHandler(MulticastPingResponseRequestHandler.ACTION, new MulticastPingResponseRequestHandler()); this.transportService.registerHandler(MulticastPingResponseRequestHandler.ACTION, new MulticastPingResponseRequestHandler());
@ -221,6 +225,15 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
@Override @Override
public void ping(final PingListener listener, final TimeValue timeout) { 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(); final int id = pingIdGenerator.incrementAndGet();
receivedResponses.put(id, new ConcurrentHashMap<DiscoveryNode, PingResponse>()); receivedResponses.put(id, new ConcurrentHashMap<DiscoveryNode, PingResponse>());
sendPingRequest(id, true); sendPingRequest(id, true);