@@ -82,9 +82,20 @@ public static boolean discoveryIsConfigured(Settings settings) {
8282 void onFoundPeersUpdated () {
8383 final Set <DiscoveryNode > nodes = getDiscoveredNodes ();
8484 if (transportService .getLocalNode ().isMasterNode () && initialMasterNodes .isEmpty () == false
85- && nodes .stream ().noneMatch (Coordinator ::isZen1Node ) && checkWaitRequirements ( nodes ) ) {
85+ && nodes .stream ().noneMatch (Coordinator ::isZen1Node )) {
8686
87- startBootstrap (nodes );
87+ final boolean waitRequirementsPassed ;
88+ try {
89+ waitRequirementsPassed = checkWaitRequirements (nodes );
90+ } catch (IllegalStateException e ) {
91+ logger .warn ("bootstrapping cancelled" , e );
92+ bootstrappingPermitted .set (false );
93+ return ;
94+ }
95+
96+ if (waitRequirementsPassed ) {
97+ startBootstrap (nodes );
98+ }
8899 }
89100 }
90101
@@ -172,17 +183,13 @@ private boolean checkWaitRequirements(Set<DiscoveryNode> nodes) {
172183 return false ;
173184 }
174185 if (matchingNodes .size () > 1 ) {
175- bootstrappingPermitted .set (false );
176- logger .warn ("bootstrapping cancelled: requirement [{}] matches multiple nodes: {}" , requirement , matchingNodes );
177- return false ;
186+ throw new IllegalStateException ("requirement [" + requirement + "] matches multiple nodes: " + matchingNodes );
178187 }
179188
180189 for (final DiscoveryNode matchingNode : matchingNodes ) {
181190 if (selectedNodes .add (matchingNode ) == false ) {
182- bootstrappingPermitted .set (false );
183- logger .warn ("bootstrapping cancelled: node [{}] matches multiple requirements: {}" , matchingNode ,
191+ throw new IllegalStateException ("node [" + matchingNode + "] matches multiple requirements: " +
184192 initialMasterNodes .stream ().filter (r -> matchesRequirement (matchingNode , r )).collect (Collectors .toList ()));
185- return false ;
186193 }
187194 }
188195 }
0 commit comments