From 6ede83ab45831b69b2627e1ad05acb3a1f55d6d9 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 11 Apr 2014 17:24:32 +0200 Subject: [PATCH] [Discovery] add rejoin on master gone flag, defaults to false defaults to false since there is still work left to properly make it work --- .../org/elasticsearch/discovery/zen/ZenDiscovery.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index 97223d73f62..2aecce6337a 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -119,6 +119,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen private final AtomicBoolean initialStateSent = new AtomicBoolean(); + private final boolean rejoinOnMasterGone; + @Nullable private NodeService nodeService; @@ -144,6 +146,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen this.masterElectionFilterClientNodes = settings.getAsBoolean("discovery.zen.master_election.filter_client", true); this.masterElectionFilterDataNodes = settings.getAsBoolean("discovery.zen.master_election.filter_data", false); + this.rejoinOnMasterGone = settings.getAsBoolean("discovery.zen.rejoin_on_master_gone", false); logger.debug("using ping.timeout [{}], join.timeout [{}], master_election.filter_client [{}], master_election.filter_data [{}]", pingTimeout, joinTimeout, masterElectionFilterClientNodes, masterElectionFilterDataNodes); @@ -495,6 +498,11 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen // make sure the old master node, which has failed, is not part of the nodes we publish .remove(masterNode.id()) .masterNodeId(null).build(); + latestDiscoNodes = discoveryNodes; + + if (rejoinOnMasterGone) { + return rejoin(ClusterState.builder(currentState).nodes(discoveryNodes).build(), "master left (reason = " + reason + ")"); + } if (!electMaster.hasEnoughMasterNodes(discoveryNodes)) { return rejoin(ClusterState.builder(currentState).nodes(discoveryNodes).build(), "not enough master nodes after master left (reason = " + reason + ")");