From 2645574a3129cf4c718a83019503c403cadab144 Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Tue, 16 Oct 2018 09:07:27 +0200 Subject: [PATCH] Watcher: Remove test-only setting (#34377) In 54cb890 a setting for testing only was introduced, that delayed the start up of watcher. With the changes of how is watcher is started/stopped over time, this is not needed anymore. --- .../elasticsearch/xpack/watcher/Watcher.java | 1 - .../xpack/watcher/WatcherLifeCycleService.java | 18 ------------------ .../AbstractWatcherIntegrationTestCase.java | 2 -- 3 files changed, 21 deletions(-) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 5eaaa5e2ed5..14e96678d14 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -476,7 +476,6 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa settings.add(Setting.simpleString("xpack.watcher.input.search.default_timeout", Setting.Property.NodeScope)); settings.add(Setting.simpleString("xpack.watcher.transform.search.default_timeout", Setting.Property.NodeScope)); settings.add(Setting.simpleString("xpack.watcher.execution.scroll.timeout", Setting.Property.NodeScope)); - settings.add(WatcherLifeCycleService.SETTING_REQUIRE_MANUAL_START); // bulk processor configuration settings.add(SETTING_BULK_ACTIONS); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java index 279d768fde8..a67101e3587 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java @@ -17,8 +17,6 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.LifecycleListener; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.index.shard.ShardId; @@ -39,23 +37,14 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; public class WatcherLifeCycleService extends AbstractComponent implements ClusterStateListener { - // this option configures watcher not to start, unless the cluster state contains information to start watcher - // if you start with an empty cluster, you can delay starting watcher until you call the API manually - // if you start with a cluster containing data, this setting might have no effect, once you called the API yourself - // this is merely for testing, to make sure that watcher only starts when manually called - public static final Setting SETTING_REQUIRE_MANUAL_START = - Setting.boolSetting("xpack.watcher.require_manual_start", false, Property.NodeScope); - private final AtomicReference state = new AtomicReference<>(WatcherState.STARTED); private final AtomicReference> previousShardRoutings = new AtomicReference<>(Collections.emptyList()); - private final boolean requireManualStart; private volatile boolean shutDown = false; // indicates that the node has been shutdown and we should never start watcher after this. private volatile WatcherService watcherService; WatcherLifeCycleService(Settings settings, ClusterService clusterService, WatcherService watcherService) { super(settings); this.watcherService = watcherService; - this.requireManualStart = SETTING_REQUIRE_MANUAL_START.get(settings); clusterService.addListener(this); // Close if the indices service is being stopped, so we don't run into search failures (locally) that will // happen because we're shutting down and an watch is scheduled. @@ -91,13 +80,6 @@ public class WatcherLifeCycleService extends AbstractComponent implements Cluste return; } - // if watcher should not be started immediately unless it is has been manually configured to do so - WatcherMetaData watcherMetaData = event.state().getMetaData().custom(WatcherMetaData.TYPE); - if (watcherMetaData == null && requireManualStart) { - clearAllocationIds(); - return; - } - if (Strings.isNullOrEmpty(event.state().nodes().getMasterNodeId())) { pauseExecution("no master node"); return; diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 8cce6fd6663..40e87af1f0b 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -49,7 +49,6 @@ import org.elasticsearch.xpack.core.watcher.support.xcontent.XContentSource; import org.elasticsearch.xpack.core.watcher.transport.actions.stats.WatcherStatsResponse; import org.elasticsearch.xpack.core.watcher.watch.ClockMock; import org.elasticsearch.xpack.core.watcher.watch.Watch; -import org.elasticsearch.xpack.watcher.WatcherLifeCycleService; import org.elasticsearch.xpack.watcher.history.HistoryStore; import org.elasticsearch.xpack.watcher.notification.email.Authentication; import org.elasticsearch.xpack.watcher.notification.email.Email; @@ -111,7 +110,6 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase // watcher settings that should work despite randomization .put("xpack.watcher.execution.scroll.size", randomIntBetween(1, 100)) .put("xpack.watcher.watch.scroll.size", randomIntBetween(1, 100)) - .put(WatcherLifeCycleService.SETTING_REQUIRE_MANUAL_START.getKey(), true) .build(); }