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.
This commit is contained in:
parent
94b349cd18
commit
3499fa917c
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
<<transform-settings>>.
|
||||
|
||||
To create a dedicated {transform} node in the {default-dist}, set:
|
||||
|
|
|
@ -5,12 +5,11 @@
|
|||
<titleabbrev>SQL access settings</titleabbrev>
|
||||
++++
|
||||
|
||||
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.
|
||||
|
|
|
@ -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` (<<cluster-update-settings,Dynamic>>)::
|
||||
The number of times that a {transform} retries when it experiences a
|
||||
|
|
|
@ -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 <<security-privileges>> and <<built-in-roles>>.
|
||||
|
||||
For more information, see <<security-privileges>> and <<built-in-roles>>.
|
||||
|
|
|
@ -42,7 +42,10 @@ public class XPackSettings {
|
|||
|
||||
/**
|
||||
* Setting for controlling whether or not enrich is enabled.
|
||||
* <p>
|
||||
* 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<Boolean> 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<Boolean> DATA_FRAME_ENABLED = Setting.boolSetting("xpack.data_frame.enabled", true,
|
||||
Setting.Property.NodeScope, Setting.Property.Deprecated);
|
||||
public static final Setting<Boolean> TRANSFORM_ENABLED = Setting.boolSetting("xpack.transform.enabled", DATA_FRAME_ENABLED,
|
||||
|
||||
/**
|
||||
* Setting for enabling or disabling data frame. Defaults to true.
|
||||
* <p>
|
||||
* 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<Boolean> 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<Boolean> 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.
|
||||
* <p>
|
||||
* 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<Boolean> ROLLUP_ENABLED = Setting.boolSetting("xpack.rollup.enabled", true,
|
||||
Property.NodeScope, Property.Deprecated);
|
||||
|
||||
|
@ -92,7 +107,12 @@ public class XPackSettings {
|
|||
public static final Setting<Boolean> 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.
|
||||
* <p>
|
||||
* 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<Boolean> 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.
|
||||
* <p>
|
||||
* 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<Boolean> SNAPSHOT_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.slm.enabled", true,
|
||||
Property.NodeScope, Property.Deprecated);
|
||||
|
||||
|
@ -135,15 +158,30 @@ public class XPackSettings {
|
|||
public static final Setting<Boolean> 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.
|
||||
* <p>
|
||||
* 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<Boolean> 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.
|
||||
* <p>
|
||||
* 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<Boolean> 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.
|
||||
* <p>
|
||||
* 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<Boolean> 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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ public class SqlFeatureSetUsage extends XPackFeatureSet.Usage {
|
|||
stats = in.readMap();
|
||||
}
|
||||
|
||||
public SqlFeatureSetUsage(boolean available, boolean enabled, Map<String, Object> stats) {
|
||||
super(XPackField.SQL, available, enabled);
|
||||
public SqlFeatureSetUsage(boolean available, Map<String, Object> stats) {
|
||||
super(XPackField.SQL, available, true);
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ public class TransformFeatureSetUsage extends Usage {
|
|||
this.accumulatedStats = new TransformIndexerStats(in);
|
||||
}
|
||||
|
||||
public TransformFeatureSetUsage(boolean available, boolean enabled, Map<String, Long> transformCountByState,
|
||||
public TransformFeatureSetUsage(boolean available, Map<String, Long> transformCountByState,
|
||||
TransformIndexerStats accumulatedStats) {
|
||||
super(XPackField.TRANSFORM, available, enabled);
|
||||
super(XPackField.TRANSFORM, available, true);
|
||||
this.transformCountByState = Objects.requireNonNull(transformCountByState);
|
||||
this.accumulatedStats = Objects.requireNonNull(accumulatedStats);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<String, Processor.Factory> 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<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> 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<DiscoveryNodes> 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<RepositoriesService> repositoriesServiceSupplier
|
||||
) {
|
||||
if (enabled == false || transportClientMode) {
|
||||
if (transportClientMode) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
|
@ -253,7 +237,6 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu
|
|||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Arrays.asList(
|
||||
ENRICH_ENABLED_SETTING,
|
||||
ENRICH_FETCH_SIZE_SETTING,
|
||||
ENRICH_MAX_CONCURRENT_POLICY_EXECUTIONS,
|
||||
ENRICH_CLEANUP_PERIOD,
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(LocalStateEnrich.class);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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> snapshotRetentionService = new SetOnce<>();
|
||||
private final SetOnce<SnapshotHistoryStore> 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<DiscoveryNodes> nodesInCluster) {
|
||||
List<RestHandler> 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<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> listener) {
|
||||
listener.onResponse(new LogstashFeatureSetUsage(available(), enabled()));
|
||||
listener.onResponse(new LogstashFeatureSetUsage(available()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> 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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Module> createGuiceModules() {
|
||||
return Collections.singletonList(b -> {
|
||||
|
@ -39,9 +32,6 @@ public class FlattenedMapperPlugin extends Plugin implements MapperPlugin, Actio
|
|||
|
||||
@Override
|
||||
public Map<String, Mapper.TypeParser> getMappers() {
|
||||
if (enabled == false) {
|
||||
return emptyMap();
|
||||
}
|
||||
return singletonMap(FlatObjectFieldMapper.CONTENT_TYPE, new FlatObjectFieldMapper.TypeParser());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<TimeValue> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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> 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<DiscoveryNodes> 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<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> 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<ExecutorBuilder<?>> 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> 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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> future = new PlainActionFuture<>();
|
||||
featureSet.usage(future);
|
||||
XPackFeatureSet.Usage rollupUsage = future.get();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
testClusters.integTest {
|
||||
setting 'xpack.security.enabled', 'false'
|
||||
setting 'xpack.sql.enabled', 'false'
|
||||
setting 'xpack.license.self_generated.type', 'trial'
|
||||
}
|
||||
|
|
|
@ -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]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Object> 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<DiscoveryNodes> 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<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> 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),
|
||||
|
|
|
@ -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<SqlFeatureSet.Usage> 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());
|
||||
|
|
|
@ -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<Class<? extends Plugin>> 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
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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> 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<Boolean> 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<DiscoveryNodes> 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<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> 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<ExecutorBuilder<?>> 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<RepositoriesService> 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));
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> listener) {
|
||||
if (enabled == false) {
|
||||
listener.onResponse(new TransformFeatureSetUsage(available(), enabled(), Collections.emptyMap(), new TransformIndexerStats()));
|
||||
return;
|
||||
}
|
||||
|
||||
PersistentTasksCustomMetadata taskMetadata = PersistentTasksCustomMetadata.getPersistentTasksCustomMetadata(clusterService.state());
|
||||
Collection<PersistentTasksCustomMetadata.PersistentTask<?>> transformTasks = taskMetadata == null
|
||||
? Collections.emptyList()
|
||||
|
@ -122,7 +113,7 @@ public class TransformFeatureSet implements XPackFeatureSet {
|
|||
|
||||
ActionListener<TransformIndexerStats> 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;
|
||||
}
|
||||
|
|
|
@ -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<Usage> 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<String, Object> 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 } );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<Module> createGuiceModules() {
|
||||
return Collections.singletonList(b -> {
|
||||
|
@ -40,9 +33,6 @@ public class Vectors extends Plugin implements MapperPlugin {
|
|||
|
||||
@Override
|
||||
public Map<String, Mapper.TypeParser> getMappers() {
|
||||
if (enabled == false) {
|
||||
return emptyMap();
|
||||
}
|
||||
Map<String, Mapper.TypeParser> mappers = new LinkedHashMap<>();
|
||||
mappers.put(DenseVectorFieldMapper.CONTENT_TYPE, new DenseVectorFieldMapper.TypeParser());
|
||||
mappers.put(SparseVectorFieldMapper.CONTENT_TYPE, new SparseVectorFieldMapper.TypeParser());
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<XPackFeatureSet.Usage> 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<XPackFeatureSet.Usage> 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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue