Skip to content

Commit cdf41cf

Browse files
authored
Watcher: use same value of watcher state (elastic/x-pack-elasticsearch#4430)
This commit updates the WatcherLifecycleService to use the same value for the watcher service state when making comparisons to determine the actions that need to be taken. See elastic/x-pack-elasticsearch#4429 Original commit: elastic/x-pack-elasticsearch@c6c24fc
1 parent 03ecbc0 commit cdf41cf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private synchronized void start(ClusterState state) {
8787
if (shutDown) {
8888
return;
8989
}
90-
WatcherState watcherState = watcherService.state();
90+
final WatcherState watcherState = watcherService.state();
9191
if (watcherState != WatcherState.STOPPED) {
9292
logger.debug("not starting watcher. watcher can only start if its current state is [{}], but its current state now is [{}]",
9393
WatcherState.STOPPED, watcherState);
@@ -162,9 +162,10 @@ public void clusterChanged(ClusterChangedEvent event) {
162162
clearAllocationIds();
163163
executor.execute(() -> this.stop("watcher manually marked to shutdown by cluster state update"));
164164
} else {
165-
if (watcherService.state() == WatcherState.STARTED && event.state().nodes().getLocalNode().isDataNode()) {
165+
final WatcherState watcherState = watcherService.state();
166+
if (watcherState == WatcherState.STARTED && event.state().nodes().getLocalNode().isDataNode()) {
166167
checkAndSetAllocationIds(event.state(), true);
167-
} else if (watcherService.state() != WatcherState.STARTED && watcherService.state() != WatcherState.STARTING) {
168+
} else if (watcherState != WatcherState.STARTED && watcherState != WatcherState.STARTING) {
168169
IndexMetaData watcherIndexMetaData = WatchStoreUtils.getConcreteIndex(Watch.INDEX, event.state().metaData());
169170
IndexMetaData triggeredWatchesIndexMetaData = WatchStoreUtils.getConcreteIndex(TriggeredWatchStoreField.INDEX_NAME,
170171
event.state().metaData());

0 commit comments

Comments
 (0)