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 @@ -186,8 +186,8 @@ void startTask(ClusterChangedEvent event) {
186186
187187 // visible for testing
188188 void shuttingDown (ClusterChangedEvent event ) {
189- DiscoveryNode node = clusterService . localNode ();
190- if ( isNodeShuttingDown ( event , node . getId ())) {
189+ if ( isNodeShuttingDown ( event )) {
190+ var node = event . state (). getNodes (). getLocalNode ();
191191 abortTaskIfApplicable ("node [{" + node .getName () + "}{" + node .getId () + "}] shutting down" );
192192 }
193193 }
@@ -202,9 +202,18 @@ void abortTaskIfApplicable(String reason) {
202202 }
203203 }
204204
205- private static boolean isNodeShuttingDown (ClusterChangedEvent event , String nodeId ) {
206- return event .previousState ().metadata ().nodeShutdowns ().contains (nodeId ) == false
207- && event .state ().metadata ().nodeShutdowns ().contains (nodeId );
205+ private static boolean isNodeShuttingDown (ClusterChangedEvent event ) {
206+ if (event .metadataChanged () == false ) {
207+ return false ;
208+ }
209+ var shutdownsOld = event .previousState ().metadata ().nodeShutdowns ();
210+ var shutdownsNew = event .state ().metadata ().nodeShutdowns ();
211+ if (shutdownsNew == shutdownsOld ) {
212+ return false ;
213+ }
214+ String nodeId = event .state ().nodes ().getLocalNodeId ();
215+ return shutdownsOld .contains (nodeId ) == false && shutdownsNew .contains (nodeId );
216+
208217 }
209218
210219 public static List <NamedXContentRegistry .Entry > getNamedXContentParsers () {
You can’t perform that action at this time.
0 commit comments