From 3499fa917cac79edfc7573671147714f1fbbcfbb Mon Sep 17 00:00:00 2001 From: William Brafford Date: Tue, 5 May 2020 10:40:49 -0400 Subject: [PATCH] Deprecated xpack "enable" settings should be no-ops (#55416) (#56167) The following settings are now no-ops: * xpack.flattened.enabled * xpack.logstash.enabled * xpack.rollup.enabled * xpack.slm.enabled * xpack.sql.enabled * xpack.transform.enabled * xpack.vectors.enabled Since these settings no longer need to be checked, we can remove settings parameters from a number of constructors and methods, and do so in this commit. We also update documentation to remove references to these settings. --- .../migration/migrate_7_0/settings.asciidoc | 19 ++-- docs/reference/modules/node.asciidoc | 9 +- docs/reference/settings/sql-settings.asciidoc | 5 +- .../settings/transform-settings.asciidoc | 32 ++---- docs/reference/transform/setup.asciidoc | 13 ++- .../xpack/core/XPackSettings.java | 51 ++++++++-- .../xpack/core/enrich/EnrichFeatureSet.java | 8 +- .../flattened/FlattenedFeatureSetUsage.java | 4 +- .../logstash/LogstashFeatureSetUsage.java | 4 +- .../core/rollup/RollupFeatureSetUsage.java | 4 +- .../xpack/core/slm/SLMFeatureSetUsage.java | 4 +- .../xpack/core/sql/SqlFeatureSetUsage.java | 4 +- .../transform/TransformFeatureSetUsage.java | 4 +- .../FlattenedFeatureSetUsageTests.java | 10 +- .../TransformFeatureSetUsageTests.java | 3 +- .../xpack/enrich/EnrichPlugin.java | 19 +--- .../xpack/enrich/EnrichDisabledIT.java | 44 --------- .../enrich/EnrichStatsCollectorTests.java | 69 ++----------- .../eql/action/AbstractEqlIntegTestCase.java | 1 - .../xpack/ilm/IndexLifecycle.java | 87 ++++++++-------- .../xpack/slm/SLMFeatureSet.java | 11 +-- .../IndexLifecycleInitialisationTests.java | 2 - .../slm/SLMSnapshotBlockingIntegTests.java | 4 - .../SnapshotLifecycleInitialisationTests.java | 2 - .../xpack/logstash/LogstashFeatureSet.java | 10 +- .../logstash/LogstashFeatureSetTests.java | 26 +---- .../xpack/flattened/FlattenedFeatureSet.java | 10 +- .../flattened/FlattenedMapperPlugin.java | 12 +-- .../xpack/ml/support/BaseMlIntegTestCase.java | 2 - .../xpack/monitoring/Monitoring.java | 2 +- .../enrich/EnrichStatsCollector.java | 13 +-- .../elasticsearch/xpack/rollup/Rollup.java | 14 +-- .../xpack/rollup/RollupFeatureSet.java | 10 +- .../xpack/rollup/RollupFeatureSetTests.java | 18 +--- x-pack/plugin/sql/qa/no-sql/build.gradle | 1 - .../xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java | 7 +- .../xpack/sql/SqlFeatureSet.java | 14 +-- .../xpack/sql/plugin/SqlPlugin.java | 17 +--- .../xpack/sql/SqlFeatureSetTests.java | 26 +---- .../xpack/sql/action/SqlDisabledIT.java | 51 ---------- .../xpack/sql/plugin/SqlPluginTests.java | 21 ++-- .../xpack/transform/Transform.java | 26 +---- .../xpack/transform/TransformFeatureSet.java | 17 +--- .../transform/TransformFeatureSetTests.java | 98 ------------------- .../xpack/transform/TransformTests.java | 7 +- .../elasticsearch/xpack/vectors/Vectors.java | 12 +-- .../xpack/vectors/VectorsFeatureSet.java | 10 +- .../xpack/vectors/VectorsFeatureSetTests.java | 36 +------ .../AbstractWatcherIntegrationTestCase.java | 9 +- 49 files changed, 207 insertions(+), 675 deletions(-) delete mode 100644 x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java delete mode 100644 x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java diff --git a/docs/reference/migration/migrate_7_0/settings.asciidoc b/docs/reference/migration/migrate_7_0/settings.asciidoc index 0346b01050d..b59bc2abd36 100644 --- a/docs/reference/migration/migrate_7_0/settings.asciidoc +++ b/docs/reference/migration/migrate_7_0/settings.asciidoc @@ -295,8 +295,15 @@ greater than `Integer.MAX_VALUE`. This leniency has been removed. In Elasticsearch 7.8.0, the following settings no longer have any effect, and have been deprecated: +* `xpack.enrich.enabled` +* `xpack.flattened.enabled` * `xpack.ilm.enabled` * `xpack.monitoring.enabled` +* `xpack.rollup.enabled` +* `xpack.slm.enabled` +* `xpack.sql.enabled` +* `xpack.transform.enabled` +* `xpack.vectors.enabled` Previously, these settings could be set to `false` in order to disable the feature's APIs in a cluster. As of 7.8.0, these basic license features are @@ -306,15 +313,3 @@ If you have disabled ILM so that you can use another tool to manage Watcher indices, the newly introduced `xpack.watcher.use_ilm_index_management` setting may be set to false. -Additionally, the following settings have been deprecated: - -* `xpack.enrich.enabled` -* `xpack.flattened.enabled` -* `xpack.rollup.enabled` -* `xpack.slm.enabled` -* `xpack.sql.enabled` -* `xpack.transform.enabled` -* `xpack.vectors.enabled` - -In future releases, it will not be possible to disable the APIs for Enrichment, -Flattened mappings, Rollup, SLM, SQL, Transforms, and Vectors. diff --git a/docs/reference/modules/node.asciidoc b/docs/reference/modules/node.asciidoc index 14600044439..94f6297eaf2 100644 --- a/docs/reference/modules/node.asciidoc +++ b/docs/reference/modules/node.asciidoc @@ -404,12 +404,9 @@ node.remote_cluster_client: false <8> {transform-cap} nodes run {transforms} and handle {transform} API requests. -If you want to use {transforms} in your cluster, you must not have -`xpack.transform.enabled` set to `false` on any master-eligible or data -nodes. To use {transforms} in clients (including {kib}), do not disable this -setting on any coordinating nodes. You must also have `node.transform` set to -`true` on at least one node. This is the default behavior. If you have the -{oss-dist}, do not use these settings. For more information, see +If you want to use {transforms} in your cluster, you must have `node.transform` +set to `true` on at least one node. This is the default behavior. If you have +the {oss-dist}, do not use these settings. For more information, see <>. To create a dedicated {transform} node in the {default-dist}, set: diff --git a/docs/reference/settings/sql-settings.asciidoc b/docs/reference/settings/sql-settings.asciidoc index 76358dd814f..ac5ef9434c7 100644 --- a/docs/reference/settings/sql-settings.asciidoc +++ b/docs/reference/settings/sql-settings.asciidoc @@ -5,12 +5,11 @@ SQL access settings ++++ -SQL Access is enabled by default. You can configure -these SQL Access settings in the `elasticsearch.yml` file. +SQL Access is always enabled. [float] [[general-sql-settings]] ==== General SQL Access Settings `xpack.sql.enabled`:: deprecated:[7.8.0,Basic License features should always be enabled] + -Set to `false` to disable SQL Access on the node. +This deprecated setting no longer has any effect. diff --git a/docs/reference/settings/transform-settings.asciidoc b/docs/reference/settings/transform-settings.asciidoc index fb6202c6c09..ff8b26da435 100644 --- a/docs/reference/settings/transform-settings.asciidoc +++ b/docs/reference/settings/transform-settings.asciidoc @@ -21,34 +21,20 @@ file. ==== General {transforms} settings `node.transform`:: -Set to `true` to identify the node as a _transform node_. If either `node.data` -or `xpack.transform.enabled` is `false` for the node, the default value is -`false`. Otherwise, the default value is `true`. +Set to `true` to identify the node as a _transform node_. If `node.data` +is `false` for the node, the default value is `false`. Otherwise, the default +value is `true`. + -If set to `false` in `elasticsearch.yml`, the node cannot run transforms. If set to -`true` but `xpack.transform.enabled` is set to `false`, the `node.transform` setting is -ignored and the node cannot run transforms. If you want to run transforms, there must be at -least one transform node in your cluster. + +If set to `false` in `elasticsearch.yml`, the node cannot run transforms. If +you want to run transforms, there must be at least one transform node in your +cluster. + + -IMPORTANT: It is advised to use the `node.transform` setting to constrain the execution -of transforms to certain nodes instead of using `xpack.transform.enabled`. On dedicated -coordinating nodes or dedicated master nodes, disable the node.transform role. +IMPORTANT: On dedicated coordinating nodes or dedicated master nodes, disable +the node.transform role. `xpack.transform.enabled`:: deprecated:[7.8.0,Basic License features should always be enabled] + -Set to `true` (default) to enable {transforms} on the node. -+ -If set to `false` in `elasticsearch.yml`, the {transform} APIs are disabled on -the node. Therefore the node cannot start or administrate {transforms} or -receive transport (internal) communication requests related to {transform} APIs. -If the node is a coordinating node, {transform} requests from clients (including -{kib}) also fail. -+ -IMPORTANT: If you want to use {transform} features in your cluster, it is -recommended that you set `xpack.transform.enabled` to `true` on all nodes. This -is the default behavior. At a minimum, it must be enabled on all master-eligible -nodes and all data nodes. If you want to use {transforms} in clients or {kib}, -it must also be enabled on all coordinating nodes. +This deprecated setting no longer has any effect. `xpack.transform.num_transform_failure_retries` (<>):: The number of times that a {transform} retries when it experiences a diff --git a/docs/reference/transform/setup.asciidoc b/docs/reference/transform/setup.asciidoc index dae8297e7d1..5b8cc77874d 100644 --- a/docs/reference/transform/setup.asciidoc +++ b/docs/reference/transform/setup.asciidoc @@ -16,9 +16,8 @@ To use the {transforms}, you must have the ==== {transform-cap} nodes To use {transforms}, there must be at least one node in your cluster with -`xpack.transform.enabled` and `node.transform` set to `true`. By default, all -nodes are {transform} nodes unless you explicitly change these settings or set -`node.data` to `false`. +`node.transform` set to `true`. By default, all nodes are {transform} nodes +unless you explicitly change these settings or set `node.data` to `false`. If you want to control which nodes run {transforms}, set `node.transform` to `false` on some nodes. @@ -35,14 +34,14 @@ which users can manage or view {transforms}. To _view_ the configuration and status of {transforms}, you must have: -* `transform_user` built-in role or `monitor_transform` +* `transform_user` built-in role or `monitor_transform` cluster privileges To _manage_ {transforms}, you must have: -* `transform_admin` built-in role or `manage_transform` +* `transform_admin` built-in role or `manage_transform` cluster privileges * `read` and `view_index_metadata` index privileges on source indices * `read`, `create_index`, and `index` index privileges on destination indices - -For more information, see <> and <>. \ No newline at end of file + +For more information, see <> and <>. diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index afb635f6497..57539e27366 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -42,7 +42,10 @@ public class XPackSettings { /** * Setting for controlling whether or not enrich is enabled. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. */ + @Deprecated // since = "7.8.0" public static final Setting ENRICH_ENABLED_SETTING = Setting.boolSetting("xpack.enrich.enabled", true, Property.NodeScope, Property.Deprecated); @@ -55,7 +58,14 @@ public class XPackSettings { @Deprecated // replaced by TRANSFORM_ENABLED private static final Setting DATA_FRAME_ENABLED = Setting.boolSetting("xpack.data_frame.enabled", true, Setting.Property.NodeScope, Setting.Property.Deprecated); - public static final Setting TRANSFORM_ENABLED = Setting.boolSetting("xpack.transform.enabled", DATA_FRAME_ENABLED, + + /** + * Setting for enabling or disabling data frame. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated // since = "7.8.0" + public static final Setting TRANSFORM_ENABLED = Setting.boolSetting("xpack.transform.enabled", true, Property.NodeScope, Property.Deprecated); /** Setting for enabling or disabling security. Defaults to true. */ @@ -80,7 +90,12 @@ public class XPackSettings { public static final Setting MACHINE_LEARNING_ENABLED = Setting.boolSetting("xpack.ml.enabled", true, Setting.Property.NodeScope); - /** Setting for enabling or disabling rollup. Defaults to true. */ + /** + * Setting for enabling or disabling rollup. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated // since = "7.8.0" public static final Setting ROLLUP_ENABLED = Setting.boolSetting("xpack.rollup.enabled", true, Property.NodeScope, Property.Deprecated); @@ -92,7 +107,12 @@ public class XPackSettings { public static final Setting DLS_FLS_ENABLED = Setting.boolSetting("xpack.security.dls_fls.enabled", true, Setting.Property.NodeScope); - /** Setting for enabling or disabling Logstash extensions. Defaults to true. */ + /** + * Setting for enabling or disabling Logstash extensions. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated // since = "7.8.0" public static final Setting LOGSTASH_ENABLED = Setting.boolSetting("xpack.logstash.enabled", true, Setting.Property.NodeScope, Property.Deprecated); @@ -107,7 +127,10 @@ public class XPackSettings { /** * Setting for enabling or disabling the snapshot lifecycle extension. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. */ + @Deprecated // since = "7.8.0" public static final Setting SNAPSHOT_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.slm.enabled", true, Property.NodeScope, Property.Deprecated); @@ -135,15 +158,30 @@ public class XPackSettings { public static final Setting FIPS_MODE_ENABLED = Setting.boolSetting("xpack.security.fips_mode.enabled", false, Property.NodeScope); - /** Setting for enabling or disabling sql. Defaults to true. */ + /** + * Setting for enabling or disabling sql. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated // since = "7.8.0" public static final Setting SQL_ENABLED = Setting.boolSetting("xpack.sql.enabled", true, Property.NodeScope, Property.Deprecated); - /** Setting for enabling or disabling flattened fields. Defaults to true. */ + /** + * Setting for enabling or disabling flattened fields. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated // since = "7.8.0" public static final Setting FLATTENED_ENABLED = Setting.boolSetting("xpack.flattened.enabled", true, Property.NodeScope, Property.Deprecated); - /** Setting for enabling or disabling vectors. Defaults to true. */ + /** + * Setting for enabling or disabling vectors. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated // since = "7.8.0" public static final Setting VECTORS_ENABLED = Setting.boolSetting("xpack.vectors.enabled", true, Property.NodeScope, Property.Deprecated); @@ -284,6 +322,7 @@ public class XPackSettings { settings.add(TRANSFORM_ENABLED); settings.add(FLATTENED_ENABLED); settings.add(VECTORS_ENABLED); + settings.add(ENRICH_ENABLED_SETTING); settings.add(DIAGNOSE_TRUST_EXCEPTIONS_SETTING); settings.add(FIPS_MODE_ENABLED); return Collections.unmodifiableList(settings); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSet.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSet.java index d843ba6addf..47c9604718e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSet.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSet.java @@ -10,23 +10,19 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import java.io.IOException; import java.util.Map; public class EnrichFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject - public EnrichFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState) { - this.enabled = XPackSettings.ENRICH_ENABLED_SETTING.get(settings); + public EnrichFeatureSet(@Nullable XPackLicenseState licenseState) { this.licenseState = licenseState; } @@ -42,7 +38,7 @@ public class EnrichFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java index d9069685199..8ba4d302837 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java @@ -24,8 +24,8 @@ public class FlattenedFeatureSetUsage extends XPackFeatureSet.Usage { this.fieldCount = input.getVersion().onOrAfter(Version.V_7_6_0) ? input.readInt() : 0; } - public FlattenedFeatureSetUsage(boolean available, boolean enabled, int fieldCount) { - super(XPackField.FLATTENED, available, enabled); + public FlattenedFeatureSetUsage(boolean available, int fieldCount) { + super(XPackField.FLATTENED, available, true); this.fieldCount = fieldCount; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java index 2c113372dc5..12a89831bff 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java @@ -18,8 +18,8 @@ public class LogstashFeatureSetUsage extends XPackFeatureSet.Usage { super(in); } - public LogstashFeatureSetUsage(boolean available, boolean enabled) { - super(XPackField.LOGSTASH, available, enabled); + public LogstashFeatureSetUsage(boolean available) { + super(XPackField.LOGSTASH, available, true); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java index baa823c2835..9beb9e01b82 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java @@ -18,8 +18,8 @@ public class RollupFeatureSetUsage extends XPackFeatureSet.Usage { super(input); } - public RollupFeatureSetUsage(boolean available, boolean enabled) { - super(XPackField.ROLLUP, available, enabled); + public RollupFeatureSetUsage(boolean available) { + super(XPackField.ROLLUP, available, true); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java index 42048086cea..b0cf3059207 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java @@ -33,8 +33,8 @@ public class SLMFeatureSetUsage extends XPackFeatureSet.Usage { out.writeOptionalWriteable(this.slmStats); } - public SLMFeatureSetUsage(boolean available, boolean enabled, @Nullable SnapshotLifecycleStats slmStats) { - super(XPackField.SNAPSHOT_LIFECYCLE, available, enabled); + public SLMFeatureSetUsage(boolean available, @Nullable SnapshotLifecycleStats slmStats) { + super(XPackField.SNAPSHOT_LIFECYCLE, available, true); this.slmStats = slmStats; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java index 6483fb6f47b..c0dae08cb48 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java @@ -25,8 +25,8 @@ public class SqlFeatureSetUsage extends XPackFeatureSet.Usage { stats = in.readMap(); } - public SqlFeatureSetUsage(boolean available, boolean enabled, Map stats) { - super(XPackField.SQL, available, enabled); + public SqlFeatureSetUsage(boolean available, Map stats) { + super(XPackField.SQL, available, true); this.stats = stats; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java index 27270fbb556..77ce99c2eae 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java @@ -31,9 +31,9 @@ public class TransformFeatureSetUsage extends Usage { this.accumulatedStats = new TransformIndexerStats(in); } - public TransformFeatureSetUsage(boolean available, boolean enabled, Map transformCountByState, + public TransformFeatureSetUsage(boolean available, Map transformCountByState, TransformIndexerStats accumulatedStats) { - super(XPackField.TRANSFORM, available, enabled); + super(XPackField.TRANSFORM, available, true); this.transformCountByState = Objects.requireNonNull(transformCountByState); this.accumulatedStats = Objects.requireNonNull(accumulatedStats); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java index e5e1a6342de..e73c91e5f5c 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java @@ -14,29 +14,25 @@ public class FlattenedFeatureSetUsageTests extends AbstractWireSerializingTestCa @Override protected FlattenedFeatureSetUsage createTestInstance() { - return new FlattenedFeatureSetUsage(randomBoolean(), randomBoolean(), randomIntBetween(0, 1000)); + return new FlattenedFeatureSetUsage(randomBoolean(), randomIntBetween(0, 1000)); } @Override protected FlattenedFeatureSetUsage mutateInstance(FlattenedFeatureSetUsage instance) throws IOException { boolean available = instance.available(); - boolean enabled = instance.enabled(); int fieldCount = instance.fieldCount(); - switch (between(0, 2)) { + switch (between(0, 1)) { case 0: available = !available; break; case 1: - enabled = !enabled; - break; - case 2: fieldCount = randomValueOtherThan(instance.fieldCount(), () -> randomIntBetween(0, 1000)); break; } - return new FlattenedFeatureSetUsage(available, enabled, fieldCount); + return new FlattenedFeatureSetUsage(available, fieldCount); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java index 5cf462f50ba..057c7d973aa 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java @@ -24,8 +24,7 @@ public class TransformFeatureSetUsageTests extends AbstractWireSerializingTestCa transformCountByState.put(randomFrom(IndexerState.values()).toString(), randomLong()); } - return new TransformFeatureSetUsage(randomBoolean(), randomBoolean(), transformCountByState, - TransformIndexerStatsTests.randomStats()); + return new TransformFeatureSetUsage(randomBoolean(), transformCountByState, TransformIndexerStatsTests.randomStats()); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java index 110c6304dfc..3ca606343fe 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java @@ -67,8 +67,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; -import static org.elasticsearch.xpack.core.XPackSettings.ENRICH_ENABLED_SETTING; import static org.elasticsearch.xpack.core.enrich.EnrichPolicy.ENRICH_INDEX_PATTERN; public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlugin { @@ -126,21 +124,15 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu }, val -> Setting.parseInt(val, 1, Integer.MAX_VALUE, QUEUE_CAPACITY_SETTING_NAME), Setting.Property.NodeScope); private final Settings settings; - private final Boolean enabled; private final boolean transportClientMode; public EnrichPlugin(final Settings settings) { this.settings = settings; - this.enabled = ENRICH_ENABLED_SETTING.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); } @Override public Map getProcessors(Processor.Parameters parameters) { - if (enabled == false) { - return emptyMap(); - } - EnrichProcessorFactory factory = new EnrichProcessorFactory(parameters.client, parameters.scriptService); parameters.ingestService.addIngestClusterStateListener(factory); return Collections.singletonMap(EnrichProcessorFactory.TYPE, factory); @@ -151,10 +143,6 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu } public List> getActions() { - if (enabled == false) { - return emptyList(); - } - return Arrays.asList( new ActionHandler<>(GetEnrichPolicyAction.INSTANCE, TransportGetEnrichPolicyAction.class), new ActionHandler<>(DeleteEnrichPolicyAction.INSTANCE, TransportDeleteEnrichPolicyAction.class), @@ -176,10 +164,6 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster ) { - if (enabled == false) { - return emptyList(); - } - return Arrays.asList( new RestGetEnrichPolicyAction(), new RestDeleteEnrichPolicyAction(), @@ -203,7 +187,7 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu IndexNameExpressionResolver expressionResolver, Supplier repositoriesServiceSupplier ) { - if (enabled == false || transportClientMode) { + if (transportClientMode) { return emptyList(); } @@ -253,7 +237,6 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu @Override public List> getSettings() { return Arrays.asList( - ENRICH_ENABLED_SETTING, ENRICH_FETCH_SIZE_SETTING, ENRICH_MAX_CONCURRENT_POLICY_EXECUTIONS, ENRICH_CLEANUP_PERIOD, diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java deleted file mode 100644 index 5ee43f1b5a9..00000000000 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.enrich; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.protocol.xpack.XPackInfoRequest; -import org.elasticsearch.protocol.xpack.XPackInfoResponse; -import org.elasticsearch.test.ESSingleNodeTestCase; -import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.core.action.XPackInfoAction; - -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; - -import static org.hamcrest.Matchers.is; - -public class EnrichDisabledIT extends ESSingleNodeTestCase { - - public void testEnrichAvailableButNotEnabled() { - ensureGreen(); - - XPackInfoRequest infoRequest = new XPackInfoRequest(); - infoRequest.setCategories(EnumSet.of(XPackInfoRequest.Category.FEATURES)); - XPackInfoResponse infoResponse = client().execute(XPackInfoAction.INSTANCE, infoRequest).actionGet(); - assertThat(infoResponse.getFeatureSetsInfo().getFeatureSets().get(XPackField.ENRICH).available(), is(true)); - assertThat(infoResponse.getFeatureSetsInfo().getFeatureSets().get(XPackField.ENRICH).enabled(), is(false)); - } - - @Override - protected Settings nodeSettings() { - return Settings.builder().put(XPackSettings.ENRICH_ENABLED_SETTING.getKey(), false).build(); - } - - @Override - protected Collection> getPlugins() { - return Collections.singleton(LocalStateEnrich.class); - } -} diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java index 6a3146b2b7b..56284371679 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java @@ -8,12 +8,10 @@ package org.elasticsearch.xpack.monitoring.collector.enrich; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction.Response.CoordinatorStats; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction.Response.ExecutingPolicy; @@ -40,7 +38,6 @@ import static org.mockito.Mockito.when; public class EnrichStatsCollectorTests extends BaseCollectorTestCase { public void testShouldCollectReturnsFalseIfMonitoringNotAllowed() { - final Settings settings = randomFrom(enrichEnabledSettings(), enrichDisabledSettings()); final boolean enrichAllowed = randomBoolean(); final boolean isElectedMaster = randomBoolean(); whenLocalNodeElectedMaster(isElectedMaster); @@ -49,7 +46,7 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase { when(licenseState.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(false); when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).thenReturn(enrichAllowed); - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(false)); if (isElectedMaster) { @@ -58,47 +55,17 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase { } public void testShouldCollectReturnsFalseIfNotMaster() { - // regardless of enrich being enabled - final Settings settings = randomFrom(enrichEnabledSettings(), enrichDisabledSettings()); - when(licenseState.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(randomBoolean()); when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).thenReturn(randomBoolean()); // this controls the blockage final boolean isElectedMaster = false; - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(false)); } - public void testShouldCollectReturnsFalseIfEnrichIsDisabled() { - // this is controls the blockage - final Settings settings = enrichDisabledSettings(); - - boolean isMonitoringAllowed = randomBoolean(); - when(licenseState.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(isMonitoringAllowed); - when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).thenReturn(randomBoolean()); - - final boolean isElectedMaster = randomBoolean(); - whenLocalNodeElectedMaster(isElectedMaster); - - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); - - assertThat(collector.shouldCollect(isElectedMaster), is(false)); - - if (isElectedMaster) { - verify(licenseState).isAllowed(XPackLicenseState.Feature.MONITORING); - } - if (isElectedMaster && isMonitoringAllowed) { - // The enrich setting is only checked if the node is master and monitoring is allowed, - // so in other cases we won't have a deprecation warning. - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ENRICH_ENABLED_SETTING }); - } - } - public void testShouldCollectReturnsFalseIfEnrichIsNotAllowed() { - final Settings settings = randomFrom(enrichEnabledSettings(), enrichDisabledSettings()); - boolean isMonitoringAllowed = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(isMonitoringAllowed); // this is controls the blockage @@ -106,33 +73,25 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase { final boolean isElectedMaster = randomBoolean(); whenLocalNodeElectedMaster(isElectedMaster); - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(false)); if (isElectedMaster) { verify(licenseState).isAllowed(XPackLicenseState.Feature.MONITORING); } - if (isElectedMaster && isMonitoringAllowed && settings.get(XPackSettings.ENRICH_ENABLED_SETTING.getKey()) != null) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ENRICH_ENABLED_SETTING }); - } } public void testShouldCollectReturnsTrue() { - final Settings settings = enrichEnabledSettings(); - when(licenseState.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(true); when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).thenReturn(true); final boolean isElectedMaster = true; - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(true)); verify(licenseState).isAllowed(XPackLicenseState.Feature.MONITORING); - if (settings.get(XPackSettings.ENRICH_ENABLED_SETTING.getKey()) != null) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ENRICH_ENABLED_SETTING }); - } } public void testDoCollect() throws Exception { @@ -172,7 +131,7 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase { when(client.execute(eq(EnrichStatsAction.INSTANCE), any(EnrichStatsAction.Request.class))).thenReturn(future); when(future.actionGet(timeout)).thenReturn(response); - final EnrichStatsCollector collector = new EnrichStatsCollector(clusterService, licenseState, client, threadContext, settings); + final EnrichStatsCollector collector = new EnrichStatsCollector(clusterService, licenseState, client, threadContext); assertEquals(timeout, collector.getCollectionTimeout()); final long interval = randomNonNegativeLong(); @@ -211,22 +170,8 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase { } } - private EnrichStatsCollector createCollector( - Settings settings, - ClusterService clusterService, - XPackLicenseState licenseState, - Client client - ) { - return new EnrichStatsCollector(clusterService, licenseState, client, settings); - } - - private Settings enrichEnabledSettings() { - // since it's the default, we want to ensure we test both with/without it - return randomBoolean() ? Settings.EMPTY : Settings.builder().put(XPackSettings.ENRICH_ENABLED_SETTING.getKey(), true).build(); - } - - private Settings enrichDisabledSettings() { - return Settings.builder().put(XPackSettings.ENRICH_ENABLED_SETTING.getKey(), false).build(); + private EnrichStatsCollector createCollector(ClusterService clusterService, XPackLicenseState licenseState, Client client) { + return new EnrichStatsCollector(clusterService, licenseState, client); } } diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java index 180eef39e31..039d7e848a7 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java @@ -28,7 +28,6 @@ public abstract class AbstractEqlIntegTestCase extends ESIntegTestCase { settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); - settings.put(XPackSettings.SQL_ENABLED.getKey(), false); settings.put(EqlPlugin.EQL_ENABLED_SETTING.getKey(), true); settings.put(LicenseService.SELF_GENERATED_LICENSE_TYPE.getKey(), "trial"); return settings.build(); diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java index 12b2ca9369c..7e624d5f9d1 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java @@ -38,7 +38,6 @@ import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.ilm.AllocateAction; import org.elasticsearch.xpack.core.ilm.DeleteAction; import org.elasticsearch.xpack.core.ilm.ForceMergeAction; @@ -141,12 +140,10 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { private final SetOnce snapshotRetentionService = new SetOnce<>(); private final SetOnce snapshotHistoryStore = new SetOnce<>(); private Settings settings; - private boolean slmEnabled; private boolean transportClientMode; public IndexLifecycle(Settings settings) { this.settings = settings; - this.slmEnabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); } @@ -204,20 +201,20 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { indexLifecycleInitialisationService.set(new IndexLifecycleService(settings, client, clusterService, threadPool, getClock(), System::currentTimeMillis, xContentRegistry, ilmHistoryStore.get())); components.add(indexLifecycleInitialisationService.get()); - if (slmEnabled) { - // the template registry is a cluster state listener - @SuppressWarnings("unused") - SnapshotLifecycleTemplateRegistry templateRegistry = new SnapshotLifecycleTemplateRegistry(settings, clusterService, threadPool, - client, xContentRegistry); - snapshotHistoryStore.set(new SnapshotHistoryStore(settings, new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN), - clusterService)); - snapshotLifecycleService.set(new SnapshotLifecycleService(settings, - () -> new SnapshotLifecycleTask(client, clusterService, snapshotHistoryStore.get()), clusterService, getClock())); - snapshotRetentionService.set(new SnapshotRetentionService(settings, - () -> new SnapshotRetentionTask(client, clusterService, System::nanoTime, snapshotHistoryStore.get(), threadPool), - clusterService, getClock())); - components.addAll(Arrays.asList(snapshotLifecycleService.get(), snapshotHistoryStore.get(), snapshotRetentionService.get())); - } + + // the template registry is a cluster state listener + @SuppressWarnings("unused") + SnapshotLifecycleTemplateRegistry templateRegistry = new SnapshotLifecycleTemplateRegistry(settings, clusterService, threadPool, + client, xContentRegistry); + snapshotHistoryStore.set(new SnapshotHistoryStore(settings, new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN), + clusterService)); + snapshotLifecycleService.set(new SnapshotLifecycleService(settings, + () -> new SnapshotLifecycleTask(client, clusterService, snapshotHistoryStore.get()), clusterService, getClock())); + snapshotRetentionService.set(new SnapshotRetentionService(settings, + () -> new SnapshotRetentionTask(client, clusterService, System::nanoTime, snapshotHistoryStore.get(), threadPool), + clusterService, getClock())); + components.addAll(Arrays.asList(snapshotLifecycleService.get(), snapshotHistoryStore.get(), snapshotRetentionService.get())); + return components; } @@ -259,8 +256,9 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { List handlers = new ArrayList<>(); - // add ILM rest handlers handlers.addAll(Arrays.asList( + + // add ILM rest handlers new RestPutLifecycleAction(), new RestGetLifecycleAction(), new RestDeleteLifecycleAction(), @@ -270,21 +268,19 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { new RestRetryAction(), new RestStopAction(), new RestStartILMAction(), - new RestGetStatusAction() + new RestGetStatusAction(), + + // add SLM rest headers + new RestPutSnapshotLifecycleAction(), + new RestDeleteSnapshotLifecycleAction(), + new RestGetSnapshotLifecycleAction(), + new RestExecuteSnapshotLifecycleAction(), + new RestGetSnapshotLifecycleStatsAction(), + new RestExecuteSnapshotRetentionAction(), + new RestStopSLMAction(), + new RestStartSLMAction(), + new RestGetSLMStatusAction() )); - if (slmEnabled) { - handlers.addAll(Arrays.asList( - new RestPutSnapshotLifecycleAction(), - new RestDeleteSnapshotLifecycleAction(), - new RestGetSnapshotLifecycleAction(), - new RestExecuteSnapshotLifecycleAction(), - new RestGetSnapshotLifecycleStatsAction(), - new RestExecuteSnapshotRetentionAction(), - new RestStopSLMAction(), - new RestStartSLMAction(), - new RestGetSLMStatusAction() - )); - } return handlers; } @@ -293,6 +289,7 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { List> actions = new ArrayList<>(); // add ILM actions actions.addAll(Arrays.asList( + // add ILM actions new ActionHandler<>(PutLifecycleAction.INSTANCE, TransportPutLifecycleAction.class), new ActionHandler<>(GetLifecycleAction.INSTANCE, TransportGetLifecycleAction.class), new ActionHandler<>(DeleteLifecycleAction.INSTANCE, TransportDeleteLifecycleAction.class), @@ -302,21 +299,19 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { new ActionHandler<>(RetryAction.INSTANCE, TransportRetryAction.class), new ActionHandler<>(StartILMAction.INSTANCE, TransportStartILMAction.class), new ActionHandler<>(StopILMAction.INSTANCE, TransportStopILMAction.class), - new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class) - )); - if (slmEnabled) { - actions.addAll(Arrays.asList( - new ActionHandler<>(PutSnapshotLifecycleAction.INSTANCE, TransportPutSnapshotLifecycleAction.class), - new ActionHandler<>(DeleteSnapshotLifecycleAction.INSTANCE, TransportDeleteSnapshotLifecycleAction.class), - new ActionHandler<>(GetSnapshotLifecycleAction.INSTANCE, TransportGetSnapshotLifecycleAction.class), - new ActionHandler<>(ExecuteSnapshotLifecycleAction.INSTANCE, TransportExecuteSnapshotLifecycleAction.class), - new ActionHandler<>(GetSnapshotLifecycleStatsAction.INSTANCE, TransportGetSnapshotLifecycleStatsAction.class), - new ActionHandler<>(ExecuteSnapshotRetentionAction.INSTANCE, TransportExecuteSnapshotRetentionAction.class), - new ActionHandler<>(StartSLMAction.INSTANCE, TransportStartSLMAction.class), - new ActionHandler<>(StopSLMAction.INSTANCE, TransportStopSLMAction.class), - new ActionHandler<>(GetSLMStatusAction.INSTANCE, TransportGetSLMStatusAction.class) + new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class), + + // add SLM actions + new ActionHandler<>(PutSnapshotLifecycleAction.INSTANCE, TransportPutSnapshotLifecycleAction.class), + new ActionHandler<>(DeleteSnapshotLifecycleAction.INSTANCE, TransportDeleteSnapshotLifecycleAction.class), + new ActionHandler<>(GetSnapshotLifecycleAction.INSTANCE, TransportGetSnapshotLifecycleAction.class), + new ActionHandler<>(ExecuteSnapshotLifecycleAction.INSTANCE, TransportExecuteSnapshotLifecycleAction.class), + new ActionHandler<>(GetSnapshotLifecycleStatsAction.INSTANCE, TransportGetSnapshotLifecycleStatsAction.class), + new ActionHandler<>(ExecuteSnapshotRetentionAction.INSTANCE, TransportExecuteSnapshotRetentionAction.class), + new ActionHandler<>(StartSLMAction.INSTANCE, TransportStartSLMAction.class), + new ActionHandler<>(StopSLMAction.INSTANCE, TransportStopSLMAction.class), + new ActionHandler<>(GetSLMStatusAction.INSTANCE, TransportGetSLMStatusAction.class) )); - } return actions; } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMFeatureSet.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMFeatureSet.java index 91a42410a81..a112e70e631 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMFeatureSet.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMFeatureSet.java @@ -11,11 +11,9 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.slm.SLMFeatureSetUsage; import org.elasticsearch.xpack.core.slm.SnapshotLifecycleMetadata; @@ -23,14 +21,12 @@ import java.util.Map; public class SLMFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; private ClusterService clusterService; @Inject - public SLMFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, ClusterService clusterService) { + public SLMFeatureSet(@Nullable XPackLicenseState licenseState, ClusterService clusterService) { this.clusterService = clusterService; - this.enabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); this.licenseState = licenseState; } @@ -46,7 +42,7 @@ public class SLMFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -59,8 +55,7 @@ public class SLMFeatureSet implements XPackFeatureSet { final ClusterState state = clusterService.state(); boolean available = licenseState.isAllowed(XPackLicenseState.Feature.ILM); final SnapshotLifecycleMetadata slmMeta = state.metadata().custom(SnapshotLifecycleMetadata.TYPE); - final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, enabled, - slmMeta == null ? null : slmMeta.getStats()); + final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, slmMeta == null ? null : slmMeta.getStats()); listener.onResponse(usage); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java index 684febd19bf..bc034ba12f6 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java @@ -118,9 +118,7 @@ public class IndexLifecycleInitialisationTests extends ESIntegTestCase { settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); - settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); - settings.put(XPackSettings.LOGSTASH_ENABLED.getKey(), false); return settings.build(); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java index 97d1086e928..e9b0f3c3a08 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java @@ -90,9 +90,7 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase { settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); - settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); - settings.put(XPackSettings.LOGSTASH_ENABLED.getKey(), false); settings.put(LifecycleSettings.LIFECYCLE_HISTORY_INDEX_ENABLED, false); return settings.build(); } @@ -108,9 +106,7 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase { settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); - settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); - settings.put(XPackSettings.LOGSTASH_ENABLED.getKey(), false); return settings.build(); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java index 339b6570f1f..c8fc8756090 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java @@ -49,8 +49,6 @@ public class SnapshotLifecycleInitialisationTests extends ESSingleNodeTestCase { settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); settings.put(Environment.PATH_REPO_SETTING.getKey(), repositoryLocation); - - settings.put(XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.getKey(), true); return settings.build(); } diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java index 3839ae93ed9..607de9fa94d 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java @@ -8,23 +8,19 @@ package org.elasticsearch.xpack.logstash; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.logstash.LogstashFeatureSetUsage; import java.util.Map; public class LogstashFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject - public LogstashFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState) { - this.enabled = XPackSettings.LOGSTASH_ENABLED.get(settings); + public LogstashFeatureSet(@Nullable XPackLicenseState licenseState) { this.licenseState = licenseState; } @@ -40,7 +36,7 @@ public class LogstashFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -50,7 +46,7 @@ public class LogstashFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { - listener.onResponse(new LogstashFeatureSetUsage(available(), enabled())); + listener.onResponse(new LogstashFeatureSetUsage(available())); } } diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java index 186e5d87853..b6027670994 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java @@ -7,12 +7,9 @@ package org.elasticsearch.xpack.logstash; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.logstash.LogstashFeatureSetUsage; import static org.mockito.Mockito.mock; @@ -21,33 +18,14 @@ import static org.mockito.Mockito.when; public class LogstashFeatureSetTests extends ESTestCase { - public void testEnabledSetting() throws Exception { - boolean enabled = randomBoolean(); - Settings settings = Settings.builder().put("path.home", createTempDir()).put("xpack.logstash.enabled", enabled).build(); - LogstashFeatureSet featureSet = new LogstashFeatureSet(settings, null); - assertThat(featureSet.enabled(), is(enabled)); - - PlainActionFuture future = new PlainActionFuture<>(); - featureSet.usage(future); - XPackFeatureSet.Usage usage = future.get(); - - BytesStreamOutput out = new BytesStreamOutput(); - usage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new LogstashFeatureSetUsage(out.bytes().streamInput()); - assertThat(serializedUsage.enabled(), is(enabled)); - - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.LOGSTASH_ENABLED }); - } - public void testEnabledDefault() throws Exception { - Settings settings = Settings.builder().put("path.home", createTempDir()).build(); - LogstashFeatureSet featureSet = new LogstashFeatureSet(settings, null); + LogstashFeatureSet featureSet = new LogstashFeatureSet(null); assertThat(featureSet.enabled(), is(true)); } public void testAvailable() throws Exception { final XPackLicenseState licenseState = mock(XPackLicenseState.class); - LogstashFeatureSet featureSet = new LogstashFeatureSet(Settings.EMPTY, licenseState); + LogstashFeatureSet featureSet = new LogstashFeatureSet(licenseState); boolean available = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.LOGSTASH)).thenReturn(available); assertThat(featureSet.available(), is(available)); diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedFeatureSet.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedFeatureSet.java index 1af1452c47c..8efaf001122 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedFeatureSet.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedFeatureSet.java @@ -10,11 +10,9 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.flattened.FlattenedFeatureSetUsage; import org.elasticsearch.xpack.flattened.mapper.FlatObjectFieldMapper; @@ -22,13 +20,11 @@ import java.util.Map; public class FlattenedFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; private final ClusterService clusterService; @Inject - public FlattenedFeatureSet(Settings settings, XPackLicenseState licenseState, ClusterService clusterService) { - this.enabled = XPackSettings.FLATTENED_ENABLED.get(settings); + public FlattenedFeatureSet(XPackLicenseState licenseState, ClusterService clusterService) { this.licenseState = licenseState; this.clusterService = clusterService; } @@ -45,7 +41,7 @@ public class FlattenedFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -78,6 +74,6 @@ public class FlattenedFeatureSet implements XPackFeatureSet { } } - listener.onResponse(new FlattenedFeatureSetUsage(available(), enabled(), fieldCount)); + listener.onResponse(new FlattenedFeatureSetUsage(available(), fieldCount)); } } diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java index 1854f1b6f91..d95e8f3f8fc 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java @@ -7,29 +7,22 @@ package org.elasticsearch.xpack.flattened; import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.flattened.mapper.FlatObjectFieldMapper; import java.util.Collection; import java.util.Collections; import java.util.Map; -import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; public class FlattenedMapperPlugin extends Plugin implements MapperPlugin, ActionPlugin { - private final boolean enabled; - - public FlattenedMapperPlugin(Settings settings) { - this.enabled = XPackSettings.FLATTENED_ENABLED.get(settings); - } + public FlattenedMapperPlugin() { } public Collection createGuiceModules() { return Collections.singletonList(b -> { @@ -39,9 +32,6 @@ public class FlattenedMapperPlugin extends Plugin implements MapperPlugin, Actio @Override public Map getMappers() { - if (enabled == false) { - return emptyMap(); - } return singletonMap(FlatObjectFieldMapper.CONTENT_TYPE, new FlatObjectFieldMapper.TypeParser()); } } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index a0e38af629b..05c37a69f89 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -44,7 +44,6 @@ import org.elasticsearch.xpack.core.ml.action.GetDatafeedsStatsAction; import org.elasticsearch.xpack.core.ml.action.GetJobsAction; import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.core.ml.action.StopDatafeedAction; -import org.elasticsearch.xpack.core.action.util.QueryPage; import org.elasticsearch.xpack.core.ml.client.MachineLearningClient; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedState; @@ -106,7 +105,6 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), true); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); - settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); return settings.build(); } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java index 3ffcd5d0587..c3589e4dc26 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java @@ -140,7 +140,7 @@ public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin collectors.add(new IndexRecoveryCollector(clusterService, getLicenseState(), client)); collectors.add(new JobStatsCollector(settings, clusterService, getLicenseState(), client)); collectors.add(new StatsCollector(settings, clusterService, getLicenseState(), client)); - collectors.add(new EnrichStatsCollector(clusterService, getLicenseState(), client, settings)); + collectors.add(new EnrichStatsCollector(clusterService, getLicenseState(), client)); final MonitoringService monitoringService = new MonitoringService(settings, clusterService, threadPool, collectors, exporters); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java index 78eda5b4e72..43baf6eac31 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java @@ -9,11 +9,9 @@ import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction; import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringDoc; import org.elasticsearch.xpack.monitoring.collector.Collector; @@ -29,24 +27,20 @@ public final class EnrichStatsCollector extends Collector { public static final Setting STATS_TIMEOUT = collectionTimeoutSetting("enrich.stats.timeout"); private final Client client; - private final Settings settings; private final ThreadContext threadContext; public EnrichStatsCollector(ClusterService clusterService, XPackLicenseState licenseState, - Client client, - Settings settings) { - this(clusterService, licenseState, client, client.threadPool().getThreadContext(), settings); + Client client) { + this(clusterService, licenseState, client, client.threadPool().getThreadContext()); } EnrichStatsCollector(ClusterService clusterService, XPackLicenseState licenseState, Client client, - ThreadContext threadContext, - Settings settings) { + ThreadContext threadContext) { super(EnrichCoordinatorDoc.TYPE, clusterService, STATS_TIMEOUT, licenseState); this.client = client; - this.settings = settings; this.threadContext = threadContext; } @@ -54,7 +48,6 @@ public final class EnrichStatsCollector extends Collector { protected boolean shouldCollect(final boolean isElectedMaster) { return isElectedMaster && super.shouldCollect(isElectedMaster) - && XPackSettings.ENRICH_ENABLED_SETTING.get(settings) && licenseState.isAllowed(XPackLicenseState.Feature.ENRICH); } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java index cb2082306df..fb2287852ec 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java @@ -36,7 +36,6 @@ import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.rollup.RollupField; import org.elasticsearch.xpack.core.rollup.action.DeleteRollupJobAction; import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction; @@ -97,12 +96,10 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin private final SetOnce schedulerEngine = new SetOnce<>(); private final Settings settings; - private final boolean enabled; private final boolean transportClientMode; public Rollup(Settings settings) { this.settings = settings; - this.enabled = XPackSettings.ROLLUP_ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); } @@ -134,10 +131,6 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { - if (!enabled) { - return emptyList(); - } - return Arrays.asList( new RestRollupSearchAction(), new RestPutRollupJobAction(), @@ -153,9 +146,6 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin @Override public List> getActions() { - if (!enabled) { - return emptyList(); - } return Arrays.asList( new ActionHandler<>(RollupSearchAction.INSTANCE, TransportRollupSearchAction.class), new ActionHandler<>(PutRollupJobAction.INSTANCE, TransportPutRollupJobAction.class), @@ -170,7 +160,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin @Override public List> getExecutorBuilders(Settings settings) { - if (false == enabled || transportClientMode) { + if (transportClientMode) { return emptyList(); } @@ -186,7 +176,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin Client client, SettingsModule settingsModule, IndexNameExpressionResolver expressionResolver) { - if (enabled == false || transportClientMode ) { + if (transportClientMode ) { return emptyList(); } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupFeatureSet.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupFeatureSet.java index 8674374ffc2..36efafa4a65 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupFeatureSet.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupFeatureSet.java @@ -8,23 +8,19 @@ package org.elasticsearch.xpack.rollup; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.rollup.RollupFeatureSetUsage; import java.util.Map; public class RollupFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject - public RollupFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState) { - this.enabled = XPackSettings.ROLLUP_ENABLED.get(settings); + public RollupFeatureSet(@Nullable XPackLicenseState licenseState) { this.licenseState = licenseState; } @@ -40,7 +36,7 @@ public class RollupFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -51,6 +47,6 @@ public class RollupFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { // TODO expose the currently running rollup tasks on this node? Unclear the best way to do that - listener.onResponse(new RollupFeatureSetUsage(available(), enabled())); + listener.onResponse(new RollupFeatureSetUsage(available())); } } diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupFeatureSetTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupFeatureSetTests.java index 3586b5e3e1e..0c6a5694174 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupFeatureSetTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupFeatureSetTests.java @@ -7,12 +7,9 @@ package org.elasticsearch.xpack.rollup; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.rollup.RollupFeatureSetUsage; import org.junit.Before; @@ -33,28 +30,19 @@ public class RollupFeatureSetTests extends ESTestCase { } public void testAvailable() { - RollupFeatureSet featureSet = new RollupFeatureSet(Settings.EMPTY, licenseState); + RollupFeatureSet featureSet = new RollupFeatureSet(licenseState); boolean available = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.ROLLUP)).thenReturn(available); assertThat(featureSet.available(), is(available)); } - public void testEnabledSetting() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.rollup.enabled", enabled); - RollupFeatureSet featureSet = new RollupFeatureSet(settings.build(), licenseState); - assertThat(featureSet.enabled(), is(enabled)); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ROLLUP_ENABLED } ); - } - public void testEnabledDefault() { - RollupFeatureSet featureSet = new RollupFeatureSet(Settings.EMPTY, licenseState); + RollupFeatureSet featureSet = new RollupFeatureSet(licenseState); assertThat(featureSet.enabled(), is(true)); } public void testUsage() throws ExecutionException, InterruptedException, IOException { - RollupFeatureSet featureSet = new RollupFeatureSet(Settings.EMPTY, licenseState); + RollupFeatureSet featureSet = new RollupFeatureSet(licenseState); PlainActionFuture future = new PlainActionFuture<>(); featureSet.usage(future); XPackFeatureSet.Usage rollupUsage = future.get(); diff --git a/x-pack/plugin/sql/qa/no-sql/build.gradle b/x-pack/plugin/sql/qa/no-sql/build.gradle index d0f8a3007c4..137ffed68ad 100644 --- a/x-pack/plugin/sql/qa/no-sql/build.gradle +++ b/x-pack/plugin/sql/qa/no-sql/build.gradle @@ -1,5 +1,4 @@ testClusters.integTest { setting 'xpack.security.enabled', 'false' - setting 'xpack.sql.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java b/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java index 1b4e37dbc2b..7fbe2dd8b05 100644 --- a/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java +++ b/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java @@ -9,13 +9,14 @@ package org.elasticsearch.xpack.sql.qa.jdbc; import java.sql.Connection; import java.sql.SQLException; +import static org.hamcrest.Matchers.startsWith; + public class JdbcNoSqlTestCase extends JdbcIntegrationTestCase { - + public void testJdbcExceptionMessage() throws SQLException { try (Connection c = esJdbc()) { SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT * FROM bla").executeQuery()); - assertTrue(e.getMessage().startsWith("X-Pack/SQL does not seem to be available on the Elasticsearch" - + " node using the access path")); + assertThat(e.getMessage(), startsWith("Found 1 problem\nline 1:15: Unknown index [bla]")); } } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlFeatureSet.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlFeatureSet.java index 3f8ea70ea34..e2f65837566 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlFeatureSet.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlFeatureSet.java @@ -10,11 +10,9 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.sql.SqlFeatureSetUsage; import org.elasticsearch.xpack.core.watcher.common.stats.Counters; import org.elasticsearch.xpack.sql.plugin.SqlStatsAction; @@ -29,13 +27,11 @@ import java.util.stream.Collectors; public class SqlFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; private final Client client; @Inject - public SqlFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, Client client) { - this.enabled = XPackSettings.SQL_ENABLED.get(settings); + public SqlFeatureSet(@Nullable XPackLicenseState licenseState, Client client) { this.licenseState = licenseState; this.client = client; } @@ -52,7 +48,7 @@ public class SqlFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -62,7 +58,7 @@ public class SqlFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { - if (enabled) { + if (true) { SqlStatsRequest request = new SqlStatsRequest(); request.includeStats(true); client.execute(SqlStatsAction.INSTANCE, request, ActionListener.wrap(r -> { @@ -72,10 +68,10 @@ public class SqlFeatureSet implements XPackFeatureSet { .filter(Objects::nonNull) .collect(Collectors.toList()); Counters mergedCounters = Counters.merge(countersPerNode); - listener.onResponse(new SqlFeatureSetUsage(available(), enabled(), mergedCounters.toNestedMap())); + listener.onResponse(new SqlFeatureSetUsage(available(), mergedCounters.toNestedMap())); }, listener::onFailure)); } else { - listener.onResponse(new SqlFeatureSetUsage(available(), enabled(), Collections.emptyMap())); + listener.onResponse(new SqlFeatureSetUsage(available(), Collections.emptyMap())); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java index a6718e07e27..37f01d2827e 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java @@ -32,7 +32,6 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.ql.index.IndexResolver; import org.elasticsearch.xpack.sql.SqlFeatureSet; import org.elasticsearch.xpack.sql.action.SqlClearCursorAction; @@ -47,11 +46,8 @@ import java.util.Collection; import java.util.List; import java.util.function.Supplier; -import static java.util.Collections.emptyList; - public class SqlPlugin extends Plugin implements ActionPlugin { - private final boolean enabled; private final SqlLicenseChecker sqlLicenseChecker = new SqlLicenseChecker( (mode) -> { XPackLicenseState licenseState = getLicenseState(); @@ -78,8 +74,8 @@ public class SqlPlugin extends Plugin implements ActionPlugin { } ); + // remove unneeded Settings public SqlPlugin(Settings settings) { - this.enabled = XPackSettings.SQL_ENABLED.get(settings); } // overridable by tests @@ -100,9 +96,6 @@ public class SqlPlugin extends Plugin implements ActionPlugin { * Create components used by the sql plugin. */ Collection createComponents(Client client, String clusterName, NamedWriteableRegistry namedWriteableRegistry) { - if (false == enabled) { - return emptyList(); - } IndexResolver indexResolver = new IndexResolver(client, clusterName, SqlDataTypeRegistry.INSTANCE); return Arrays.asList(sqlLicenseChecker, indexResolver, new PlanExecutor(client, indexResolver, namedWriteableRegistry)); } @@ -120,10 +113,6 @@ public class SqlPlugin extends Plugin implements ActionPlugin { SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { - if (false == enabled) { - return emptyList(); - } - return Arrays.asList(new RestSqlQueryAction(), new RestSqlTranslateAction(), new RestSqlClearCursorAction(), @@ -132,10 +121,6 @@ public class SqlPlugin extends Plugin implements ActionPlugin { @Override public List> getActions() { - if (false == enabled) { - return emptyList(); - } - return Arrays.asList(new ActionHandler<>(SqlQueryAction.INSTANCE, TransportSqlQueryAction.class), new ActionHandler<>(SqlTranslateAction.INSTANCE, TransportSqlTranslateAction.class), new ActionHandler<>(SqlClearCursorAction.INSTANCE, TransportSqlClearCursorAction.class), diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlFeatureSetTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlFeatureSetTests.java index 44561393a43..881c5854c97 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlFeatureSetTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlFeatureSetTests.java @@ -11,14 +11,12 @@ import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.ObjectPath; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.sql.SqlFeatureSetUsage; import org.elasticsearch.xpack.core.watcher.common.stats.Counters; import org.elasticsearch.xpack.sql.plugin.SqlStatsAction; @@ -53,32 +51,12 @@ public class SqlFeatureSetTests extends ESTestCase { } public void testAvailable() { - SqlFeatureSet featureSet = new SqlFeatureSet(Settings.EMPTY, licenseState, client); + SqlFeatureSet featureSet = new SqlFeatureSet(licenseState, client); boolean available = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.SQL)).thenReturn(available); assertThat(featureSet.available(), is(available)); } - public void testEnabled() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - boolean isExplicitlySet = false; - if (enabled) { - if (randomBoolean()) { - settings.put("xpack.sql.enabled", enabled); - isExplicitlySet = true; - } - } else { - settings.put("xpack.sql.enabled", enabled); - isExplicitlySet = true; - } - SqlFeatureSet featureSet = new SqlFeatureSet(settings.build(), licenseState, client); - assertThat(featureSet.enabled(), is(enabled)); - if (isExplicitlySet) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.SQL_ENABLED } ); - } - } - @SuppressWarnings("unchecked") public void testUsageStats() throws Exception { doAnswer(mock -> { @@ -107,7 +85,7 @@ public class SqlFeatureSetTests extends ESTestCase { }).when(client).execute(eq(SqlStatsAction.INSTANCE), any(), any()); PlainActionFuture future = new PlainActionFuture<>(); - new SqlFeatureSet(Settings.EMPTY, licenseState, client).usage(future); + new SqlFeatureSet(licenseState, client).usage(future); SqlFeatureSetUsage sqlUsage = (SqlFeatureSetUsage) future.get(); long fooBarBaz = ObjectPath.eval("foo.bar.baz", sqlUsage.stats()); diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java deleted file mode 100644 index 0f814becb31..00000000000 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.action; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; - -import java.util.Collection; -import java.util.Collections; - -import static org.hamcrest.CoreMatchers.either; -import static org.hamcrest.CoreMatchers.startsWith; - -public class SqlDisabledIT extends AbstractSqlIntegTestCase { - - @Override - protected Collection> nodePlugins() { - return Collections.singletonList(LocalStateCompositeXPackPlugin.class); - } - - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder() - .put(super.nodeSettings(nodeOrdinal)) - .put(XPackSettings.SQL_ENABLED.getKey(), false) - .build(); - } - - @Override - protected Settings transportClientSettings() { - return Settings.builder() - .put(super.transportClientSettings()) - .put(XPackSettings.SQL_ENABLED.getKey(), randomBoolean()) - .build(); - } - - public void testSqlAction() { - Throwable throwable = expectThrows(Throwable.class, - () -> new SqlQueryRequestBuilder(client(), SqlQueryAction.INSTANCE).query("SHOW tables").get()); - assertThat(throwable.getMessage(), - either(startsWith("no proxy found for action")) // disabled on client - .or(startsWith("failed to find action")) // disabled on proxy client - .or(startsWith("No handler for action [indices:data/read/sql]"))); // disabled on server - } -} - diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java index 9a86b34d602..423201e3cae 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java @@ -11,31 +11,30 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.IndexScopedSettings; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import org.elasticsearch.rest.RestController; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.sql.session.Cursors; import java.util.Collections; -import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasSize; import static org.mockito.Mockito.mock; public class SqlPluginTests extends ESTestCase { - public void testSqlDisabled() { + public void testSqlDisabledIsNoOp() { Settings settings = Settings.builder().put("xpack.sql.enabled", false).build(); SqlPlugin plugin = new SqlPlugin(settings); assertThat(plugin.createComponents(mock(Client.class), "cluster", new NamedWriteableRegistry(Cursors.getNamedWriteables())), - empty()); - assertThat(plugin.getActions(), empty()); - assertThat(plugin.getRestHandlers(Settings.EMPTY, mock(RestController.class), - new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), - IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, new SettingsFilter(Collections.emptyList()), - mock(IndexNameExpressionResolver.class), () -> mock(DiscoveryNodes.class)), empty()); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.SQL_ENABLED } ); + hasSize(3)); + assertThat(plugin.getActions(), hasSize(4)); + assertThat( + plugin.getRestHandlers(Settings.EMPTY, mock(RestController.class), + new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), + IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, new SettingsFilter(Collections.emptyList()), + mock(IndexNameExpressionResolver.class), () -> mock(DiscoveryNodes.class)), + hasSize(4)); } } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java index fcf7b475097..bcb05c317b9 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java @@ -47,7 +47,6 @@ import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.scheduler.SchedulerEngine; import org.elasticsearch.xpack.core.transform.TransformNamedXContentProvider; import org.elasticsearch.xpack.core.transform.action.DeleteTransformAction; @@ -128,7 +127,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa private static final Logger logger = LogManager.getLogger(Transform.class); - private final boolean enabled; private final Settings settings; private final boolean transportClientMode; private final SetOnce transformServices = new SetOnce<>(); @@ -152,12 +150,11 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa public static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node"; /** - * Setting whether transform (the coordinator task) can run on this node and REST API's are available, - * respects xpack.transform.enabled (for the whole plugin) as fallback + * Setting whether transform (the coordinator task) can run on this node. */ public static final Setting TRANSFORM_ENABLED_NODE = Setting.boolSetting( "node.transform", - settings -> Boolean.toString(XPackSettings.TRANSFORM_ENABLED.get(settings) && DiscoveryNode.isDataNode(settings)), + settings -> Boolean.toString(DiscoveryNode.isDataNode(settings)), Property.NodeScope ); @@ -172,7 +169,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa public Transform(Settings settings) { this.settings = settings; - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); } @@ -203,10 +199,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa final Supplier nodesInCluster ) { - if (!enabled) { - return emptyList(); - } - return Arrays.asList( new RestPutTransformAction(), new RestStartTransformAction(), @@ -232,10 +224,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa @Override public List> getActions() { - if (!enabled) { - return emptyList(); - } - return Arrays.asList( new ActionHandler<>(PutTransformAction.INSTANCE, TransportPutTransformAction.class), new ActionHandler<>(StartTransformAction.INSTANCE, TransportStartTransformAction.class), @@ -260,7 +248,7 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa @Override public List> getExecutorBuilders(Settings settings) { - if (false == enabled || transportClientMode) { + if (transportClientMode) { return emptyList(); } @@ -289,7 +277,7 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa IndexNameExpressionResolver expressionResolver, Supplier repositoriesServiceSupplier ) { - if (enabled == false || transportClientMode) { + if (transportClientMode) { return emptyList(); } @@ -339,7 +327,7 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa SettingsModule settingsModule, IndexNameExpressionResolver expressionResolver ) { - if (enabled == false || transportClientMode) { + if (transportClientMode) { return emptyList(); } @@ -373,10 +361,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa ); } - if (enabled == false) { - return Settings.EMPTY; - } - Settings.Builder additionalSettings = Settings.builder(); additionalSettings.put(transformEnabledNodeAttribute, TRANSFORM_ENABLED_NODE.get(settings)); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformFeatureSet.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformFeatureSet.java index c71d2e659f9..a08b25b2609 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformFeatureSet.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformFeatureSet.java @@ -17,7 +17,6 @@ import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.license.XPackLicenseState; @@ -28,7 +27,6 @@ import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.transform.TransformFeatureSetUsage; import org.elasticsearch.xpack.core.transform.TransformField; import org.elasticsearch.xpack.core.transform.transforms.TransformConfig; @@ -50,7 +48,6 @@ import java.util.Objects; public class TransformFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final Client client; private final XPackLicenseState licenseState; private final ClusterService clusterService; @@ -75,8 +72,7 @@ public class TransformFeatureSet implements XPackFeatureSet { TransformIndexerStats.EXPONENTIAL_AVG_DOCUMENTS_PROCESSED.getPreferredName(), }; @Inject - public TransformFeatureSet(Settings settings, ClusterService clusterService, Client client, @Nullable XPackLicenseState licenseState) { - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); + public TransformFeatureSet(ClusterService clusterService, Client client, @Nullable XPackLicenseState licenseState) { this.client = Objects.requireNonNull(client); this.clusterService = Objects.requireNonNull(clusterService); this.licenseState = licenseState; @@ -94,7 +90,7 @@ public class TransformFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -104,11 +100,6 @@ public class TransformFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { - if (enabled == false) { - listener.onResponse(new TransformFeatureSetUsage(available(), enabled(), Collections.emptyMap(), new TransformIndexerStats())); - return; - } - PersistentTasksCustomMetadata taskMetadata = PersistentTasksCustomMetadata.getPersistentTasksCustomMetadata(clusterService.state()); Collection> transformTasks = taskMetadata == null ? Collections.emptyList() @@ -122,7 +113,7 @@ public class TransformFeatureSet implements XPackFeatureSet { ActionListener totalStatsListener = ActionListener.wrap( statSummations -> listener.onResponse( - new TransformFeatureSetUsage(available(), enabled(), transformsCountByState, statSummations) + new TransformFeatureSetUsage(available(), transformsCountByState, statSummations) ), listener::onFailure ); @@ -137,7 +128,7 @@ public class TransformFeatureSet implements XPackFeatureSet { long totalTransforms = transformCountSuccess.getHits().getTotalHits().value; if (totalTransforms == 0) { listener.onResponse( - new TransformFeatureSetUsage(available(), enabled(), transformsCountByState, new TransformIndexerStats()) + new TransformFeatureSetUsage(available(), transformsCountByState, new TransformIndexerStats()) ); return; } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformFeatureSetTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformFeatureSetTests.java index 12e2c74c16e..097a66771b5 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformFeatureSetTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformFeatureSetTests.java @@ -7,33 +7,19 @@ package org.elasticsearch.xpack.transform; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackFeatureSet.Usage; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats; import org.junit.Before; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; import static org.elasticsearch.xpack.transform.TransformFeatureSet.PROVIDED_STATS; import static org.hamcrest.CoreMatchers.equalTo; @@ -51,7 +37,6 @@ public class TransformFeatureSetTests extends ESTestCase { public void testAvailable() { TransformFeatureSet featureSet = new TransformFeatureSet( - Settings.EMPTY, mock(ClusterService.class), mock(Client.class), licenseState @@ -62,66 +47,12 @@ public class TransformFeatureSetTests extends ESTestCase { } public void testEnabledSetting() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.transform.enabled", enabled); TransformFeatureSet featureSet = new TransformFeatureSet( - settings.build(), - mock(ClusterService.class), - mock(Client.class), - licenseState - ); - assertThat(featureSet.enabled(), is(enabled)); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.TRANSFORM_ENABLED } ); - } - - public void testEnabledSettingFallback() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - // use the deprecated setting - settings.put("xpack.data_frame.enabled", enabled); - TransformFeatureSet featureSet = new TransformFeatureSet( - settings.build(), - mock(ClusterService.class), - mock(Client.class), - licenseState - ); - assertThat(featureSet.enabled(), is(enabled)); - assertWarnings( - "[xpack.data_frame.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! " - + "See the breaking changes documentation for the next major version." - ); - } - - public void testEnabledSettingFallbackMix() { - Settings.Builder settings = Settings.builder(); - // use the older deprecated setting - settings.put("xpack.data_frame.enabled", false); - // ...and also the more recently deprecated setting - settings.put("xpack.transform.enabled", true); - TransformFeatureSet featureSet = new TransformFeatureSet( - settings.build(), mock(ClusterService.class), mock(Client.class), licenseState ); assertThat(featureSet.enabled(), is(true)); - assertWarnings( - "[xpack.data_frame.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! " - + "See the breaking changes documentation for the next major version.", - "[xpack.transform.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! " - + "See the breaking changes documentation for the next major version." - ); - } - - public void testEnabledDefault() { - TransformFeatureSet featureSet = new TransformFeatureSet( - Settings.EMPTY, - mock(ClusterService.class), - mock(Client.class), - licenseState - ); - assertTrue(featureSet.enabled()); } public void testParseSearchAggs() { @@ -167,33 +98,4 @@ public class TransformFeatureSetTests extends ESTestCase { when(agg.value()).thenReturn(value); return agg; } - - public void testUsageDisabled() throws IOException, InterruptedException, ExecutionException { - when(licenseState.isAllowed(XPackLicenseState.Feature.TRANSFORM)).thenReturn(true); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.transform.enabled", false); - TransformFeatureSet featureSet = new TransformFeatureSet( - settings.build(), - mock(ClusterService.class), - mock(Client.class), - licenseState - ); - PlainActionFuture future = new PlainActionFuture<>(); - featureSet.usage(future); - XPackFeatureSet.Usage usage = future.get(); - - assertFalse(usage.enabled()); - try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - usage.toXContent(builder, ToXContent.EMPTY_PARAMS); - - XContentParser parser = createParser(builder); - Map usageAsMap = parser.map(); - assertTrue((boolean) XContentMapValues.extractValue("available", usageAsMap)); - assertFalse((boolean) XContentMapValues.extractValue("enabled", usageAsMap)); - // not enabled -> no transforms, no stats - assertEquals(null, XContentMapValues.extractValue("transforms", usageAsMap)); - assertEquals(null, XContentMapValues.extractValue("stats", usageAsMap)); - } - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.TRANSFORM_ENABLED } ); - } } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java index 213e271c5a0..260370cdbcf 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java @@ -6,11 +6,9 @@ package org.elasticsearch.xpack.transform; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.core.XPackSettings; import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; @@ -35,12 +33,9 @@ public class TransformTests extends ESTestCase { Transform transform = createTransform(builder.build()); assertNotNull(transform.additionalSettings()); assertEquals( - transformPluginEnabled && transformEnabled, + transformEnabled, Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.node")) ); - if (transformPluginEnabled == false) { - assertSettingDeprecationsAndWarnings(new Setting[]{XPackSettings.TRANSFORM_ENABLED}); - } } public void testNodeAttributesDirectlyGiven() { diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java index 1c24a11303e..a4d3ac98495 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java @@ -7,12 +7,10 @@ package org.elasticsearch.xpack.vectors; import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.vectors.mapper.DenseVectorFieldMapper; import org.elasticsearch.xpack.vectors.mapper.SparseVectorFieldMapper; @@ -21,16 +19,11 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import static java.util.Collections.emptyMap; - public class Vectors extends Plugin implements MapperPlugin { public static final String NAME = "vectors"; - protected final boolean enabled; - public Vectors(Settings settings) { - this.enabled = XPackSettings.VECTORS_ENABLED.get(settings); - } + public Vectors() { } public Collection createGuiceModules() { return Collections.singletonList(b -> { @@ -40,9 +33,6 @@ public class Vectors extends Plugin implements MapperPlugin { @Override public Map getMappers() { - if (enabled == false) { - return emptyMap(); - } Map mappers = new LinkedHashMap<>(); mappers.put(DenseVectorFieldMapper.CONTENT_TYPE, new DenseVectorFieldMapper.TypeParser()); mappers.put(SparseVectorFieldMapper.CONTENT_TYPE, new SparseVectorFieldMapper.TypeParser()); diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsFeatureSet.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsFeatureSet.java index 5ab410e3204..5ef646389c6 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsFeatureSet.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsFeatureSet.java @@ -10,11 +10,9 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.vectors.VectorsFeatureSetUsage; import org.elasticsearch.xpack.vectors.mapper.DenseVectorFieldMapper; import org.elasticsearch.xpack.vectors.mapper.SparseVectorFieldMapper; @@ -23,13 +21,11 @@ import java.util.Map; public class VectorsFeatureSet implements XPackFeatureSet { - private final boolean enabled; private final XPackLicenseState licenseState; private final ClusterService clusterService; @Inject - public VectorsFeatureSet(Settings settings, XPackLicenseState licenseState, ClusterService clusterService) { - this.enabled = XPackSettings.VECTORS_ENABLED.get(settings); + public VectorsFeatureSet(XPackLicenseState licenseState, ClusterService clusterService) { this.licenseState = licenseState; this.clusterService = clusterService; } @@ -46,7 +42,7 @@ public class VectorsFeatureSet implements XPackFeatureSet { @Override public boolean enabled() { - return enabled; + return true; } @Override @@ -62,7 +58,7 @@ public class VectorsFeatureSet implements XPackFeatureSet { int numSparseVectorFields = 0; int avgDenseVectorDims = 0; - if (vectorsAvailable && vectorsEnabled && clusterService.state() != null) { + if (vectorsAvailable && clusterService.state() != null) { for (IndexMetadata indexMetadata : clusterService.state().metadata()) { MappingMetadata mappingMetadata = indexMetadata.mapping(); if (mappingMetadata != null) { diff --git a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsFeatureSetTests.java b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsFeatureSetTests.java index bd91dc97f56..2aa91c7be4a 100644 --- a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsFeatureSetTests.java +++ b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsFeatureSetTests.java @@ -13,12 +13,9 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.vectors.VectorsFeatureSetUsage; import org.junit.Before; import org.mockito.Mockito; @@ -38,7 +35,7 @@ public class VectorsFeatureSetTests extends ESTestCase { } public void testAvailable() throws Exception { - VectorsFeatureSet featureSet = new VectorsFeatureSet(Settings.EMPTY, licenseState, clusterService); + VectorsFeatureSet featureSet = new VectorsFeatureSet(licenseState, clusterService); boolean available = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.VECTORS)).thenReturn(available); assertEquals(available, featureSet.available()); @@ -54,35 +51,6 @@ public class VectorsFeatureSetTests extends ESTestCase { assertEquals(available, serializedUsage.available()); } - public void testEnabled() throws Exception { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - boolean isExplicitlySet = false; - if (enabled) { - if (randomBoolean()) { - settings.put("xpack.vectors.enabled", enabled); - isExplicitlySet = true; - } - } else { - settings.put("xpack.vectors.enabled", enabled); - isExplicitlySet = true; - } - VectorsFeatureSet featureSet = new VectorsFeatureSet(settings.build(), licenseState, clusterService); - assertEquals(enabled, featureSet.enabled()); - PlainActionFuture future = new PlainActionFuture<>(); - featureSet.usage(future); - XPackFeatureSet.Usage usage = future.get(); - assertEquals(enabled, usage.enabled()); - - BytesStreamOutput out = new BytesStreamOutput(); - usage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new VectorsFeatureSetUsage(out.bytes().streamInput()); - assertEquals(enabled, serializedUsage.enabled()); - if (isExplicitlySet) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.VECTORS_ENABLED } ); - } - } - public void testUsageStats() throws Exception { Metadata.Builder metadata = Metadata.builder(); IndexMetadata.Builder index1 = IndexMetadata.builder("test-index1") @@ -103,7 +71,7 @@ public class VectorsFeatureSetTests extends ESTestCase { when(licenseState.isAllowed(XPackLicenseState.Feature.VECTORS)).thenReturn(true); PlainActionFuture future = new PlainActionFuture<>(); - VectorsFeatureSet vectorsFeatureSet = new VectorsFeatureSet(Settings.EMPTY, licenseState, clusterService); + VectorsFeatureSet vectorsFeatureSet = new VectorsFeatureSet(licenseState, clusterService); vectorsFeatureSet.usage(future); VectorsFeatureSetUsage vectorUsage = (VectorsFeatureSetUsage) future.get(); assertEquals(true, vectorUsage.enabled()); 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 48a44197514..dff1f9d3957 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 @@ -99,6 +99,12 @@ import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.mockito.Mockito.mock; +/** + * Base class for Watcher integration tests + * + * Note that SLM has been observed to cause timing issues during testsuite teardown: + * https://github.com/elastic/elasticsearch/issues/50302 + */ @ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, maxNumDataNodes = 3) public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase { @@ -118,9 +124,6 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase .put("xpack.watcher.execution.scroll.size", randomIntBetween(1, 100)) .put("xpack.watcher.watch.scroll.size", randomIntBetween(1, 100)) .put("indices.lifecycle.history_index_enabled", false) - // SLM can cause timing issues during testsuite teardown: https://github.com/elastic/elasticsearch/issues/50302 - // SLM is not required for tests extending from this base class and only add noise. - .put("xpack.slm.enabled", false) .build(); }