File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
server/src/main/java/org/elasticsearch/health/node/selection Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -182,8 +182,8 @@ void startTask(ClusterChangedEvent event) {
182182
183183 // visible for testing
184184 void shuttingDown (ClusterChangedEvent event ) {
185- DiscoveryNode node = clusterService . localNode ();
186- if ( isNodeShuttingDown ( event , node . getId ())) {
185+ if ( isNodeShuttingDown ( event )) {
186+ var node = event . state (). getNodes (). getLocalNode ();
187187 abortTaskIfApplicable ("node [{" + node .getName () + "}{" + node .getId () + "}] shutting down" );
188188 }
189189 }
@@ -198,9 +198,18 @@ void abortTaskIfApplicable(String reason) {
198198 }
199199 }
200200
201- private static boolean isNodeShuttingDown (ClusterChangedEvent event , String nodeId ) {
202- return event .previousState ().metadata ().nodeShutdowns ().contains (nodeId ) == false
203- && event .state ().metadata ().nodeShutdowns ().contains (nodeId );
201+ private static boolean isNodeShuttingDown (ClusterChangedEvent event ) {
202+ if (event .metadataChanged () == false ) {
203+ return false ;
204+ }
205+ var shutdownsOld = event .previousState ().metadata ().nodeShutdowns ();
206+ var shutdownsNew = event .state ().metadata ().nodeShutdowns ();
207+ if (shutdownsNew == shutdownsOld ) {
208+ return false ;
209+ }
210+ String nodeId = event .state ().nodes ().getLocalNodeId ();
211+ return shutdownsOld .contains (nodeId ) == false && shutdownsNew .contains (nodeId );
212+
204213 }
205214
206215 public static List <NamedXContentRegistry .Entry > getNamedXContentParsers () {
You can’t perform that action at this time.
0 commit comments