Change manual stop semantics.

This change sets the manually stopped flag even if manual stop is requested but the watcher is not started.
Also clears the manually stopped flag if a manual start is initiated.

Original commit: elastic/x-pack-elasticsearch@6d5fd897ba
This commit is contained in:
Brian Murphy 2015-07-02 16:58:42 -04:00 committed by Martijn van Groningen
parent 287a612179
commit 3051cca896
1 changed files with 8 additions and 1 deletions

View File

@ -55,13 +55,15 @@ public class WatcherLifeCycleService extends AbstractComponent implements Cluste
} }
private synchronized void stop(boolean manual) { private synchronized void stop(boolean manual) {
//This is set here since even if we are not started if we have requested a manual stop we do not want an automatic start to start watcher
manuallyStopped = manual;
WatcherState watcherState = watcherService.state(); WatcherState watcherState = watcherService.state();
if (watcherState != WatcherState.STARTED) { if (watcherState != WatcherState.STARTED) {
logger.debug("not stopping watcher. watcher can only stop if its current state is [{}], but its current state now is [{}]", WatcherState.STARTED, watcherState); logger.debug("not stopping watcher. watcher can only stop if its current state is [{}], but its current state now is [{}]", WatcherState.STARTED, watcherState);
return; return;
} }
manuallyStopped = manual;
watcherService.stop(); watcherService.stop();
} }
@ -79,6 +81,11 @@ public class WatcherLifeCycleService extends AbstractComponent implements Cluste
return; return;
} }
//If we are manually starting we should clear the manuallyStopped flag
if (manual && manuallyStopped) {
manuallyStopped = false;
}
if (!watcherService.validate(state)) { if (!watcherService.validate(state)) {
logger.debug("not starting watcher. because the cluster isn't ready yet to run watcher"); logger.debug("not starting watcher. because the cluster isn't ready yet to run watcher");
return; return;