Rename `data-science` plugin to `analytics` (#46133)

Rename `data-science` plugin to `analytics`. 
Also removes enabled flag. Backport of #46092
This commit is contained in:
Zachary Tong 2019-08-29 12:45:39 -04:00 committed by GitHub
parent 9b2ea07b17
commit cf8a4171e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 182 additions and 197 deletions

View File

@ -425,7 +425,6 @@ task run(type: RunTask) {
setting 'xpack.monitoring.enabled', 'true' setting 'xpack.monitoring.enabled', 'true'
setting 'xpack.sql.enabled', 'true' setting 'xpack.sql.enabled', 'true'
setting 'xpack.rollup.enabled', 'true' setting 'xpack.rollup.enabled', 'true'
setting 'xpack.data-science.enabled', 'true'
keystoreSetting 'bootstrap.password', 'password' keystoreSetting 'bootstrap.password', 'password'
} }
} }

View File

@ -71,7 +71,7 @@ Example response:
"available" : true, "available" : true,
"enabled" : true "enabled" : true
}, },
"data_science" : { "analytics" : {
"available" : true, "available" : true,
"enabled" : true "enabled" : true
}, },

View File

@ -2,12 +2,12 @@ evaluationDependsOn(xpackModule('core'))
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
esplugin { esplugin {
name 'x-pack-data-science' name 'x-pack-analytics'
description 'Elasticsearch Expanded Pack Plugin - Data Science' description 'Elasticsearch Expanded Pack Plugin - Analytics'
classname 'org.elasticsearch.xpack.datascience.DataSciencePlugin' classname 'org.elasticsearch.xpack.analytics.AnalyticsPlugin'
extendedPlugins = ['x-pack-core'] extendedPlugins = ['x-pack-core']
} }
archivesBaseName = 'x-pack-data-science' archivesBaseName = 'x-pack-analytics'
compileJava.options.compilerArgs << "-Xlint:-rawtypes" compileJava.options.compilerArgs << "-Xlint:-rawtypes"
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes" compileTestJava.options.compilerArgs << "-Xlint:-rawtypes"

View File

@ -3,11 +3,11 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience; package org.elasticsearch.xpack.analytics;
import org.elasticsearch.xpack.datascience.cumulativecardinality.CumulativeCardinalityPipelineAggregationBuilder; import org.elasticsearch.xpack.analytics.cumulativecardinality.CumulativeCardinalityPipelineAggregationBuilder;
public class DataScienceAggregationBuilders { public class AnalyticsAggregationBuilders {
public static CumulativeCardinalityPipelineAggregationBuilder cumulativeCaardinality(String name, String bucketsPath) { public static CumulativeCardinalityPipelineAggregationBuilder cumulativeCaardinality(String name, String bucketsPath) {
return new CumulativeCardinalityPipelineAggregationBuilder(name, bucketsPath); return new CumulativeCardinalityPipelineAggregationBuilder(name, bucketsPath);

View File

@ -0,0 +1,58 @@
/*
* 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.analytics;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.xpack.core.XPackFeatureSet;
import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.core.analytics.AnalyticsFeatureSetUsage;
import org.elasticsearch.xpack.core.analytics.action.AnalyticsStatsAction;
import java.util.Map;
public class AnalyticsFeatureSet implements XPackFeatureSet {
private final XPackLicenseState licenseState;
private Client client;
@Inject
public AnalyticsFeatureSet(@Nullable XPackLicenseState licenseState, Client client) {
this.licenseState = licenseState;
this.client = client;
}
@Override
public String name() {
return XPackField.ANALYTICS;
}
@Override
public boolean available() {
return licenseState != null && licenseState.isAnalyticsAllowed();
}
@Override
public boolean enabled() {
return true;
}
@Override
public Map<String, Object> nativeCodeInfo() {
return null;
}
@Override
public void usage(ActionListener<XPackFeatureSet.Usage> listener) {
AnalyticsStatsAction.Request request = new AnalyticsStatsAction.Request();
client.execute(AnalyticsStatsAction.INSTANCE, request,
ActionListener.wrap(r -> listener.onResponse(new AnalyticsFeatureSetUsage(available(), enabled(), r)),
listener::onFailure));
}
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience; package org.elasticsearch.xpack.analytics;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
@ -14,10 +14,10 @@ import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.SearchPlugin; import org.elasticsearch.plugins.SearchPlugin;
import org.elasticsearch.xpack.core.XPackPlugin; import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.core.datascience.action.DataScienceStatsAction; import org.elasticsearch.xpack.core.analytics.action.AnalyticsStatsAction;
import org.elasticsearch.xpack.datascience.action.TransportDataScienceStatsAction; import org.elasticsearch.xpack.analytics.action.TransportAnalyticsStatsAction;
import org.elasticsearch.xpack.datascience.cumulativecardinality.CumulativeCardinalityPipelineAggregationBuilder; import org.elasticsearch.xpack.analytics.cumulativecardinality.CumulativeCardinalityPipelineAggregationBuilder;
import org.elasticsearch.xpack.datascience.cumulativecardinality.CumulativeCardinalityPipelineAggregator; import org.elasticsearch.xpack.analytics.cumulativecardinality.CumulativeCardinalityPipelineAggregator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -26,13 +26,13 @@ import java.util.concurrent.atomic.AtomicLong;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
public class DataSciencePlugin extends Plugin implements SearchPlugin, ActionPlugin { public class AnalyticsPlugin extends Plugin implements SearchPlugin, ActionPlugin {
// TODO this should probably become more structured once DataScience plugin has more than just one agg // TODO this should probably become more structured once Analytics plugin has more than just one agg
public static AtomicLong cumulativeCardUsage = new AtomicLong(0); public static AtomicLong cumulativeCardUsage = new AtomicLong(0);
private final boolean transportClientMode; private final boolean transportClientMode;
public DataSciencePlugin(Settings settings) { public AnalyticsPlugin(Settings settings) {
this.transportClientMode = XPackPlugin.transportClientMode(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings);
} }
@ -50,7 +50,7 @@ public class DataSciencePlugin extends Plugin implements SearchPlugin, ActionPlu
@Override @Override
public List<ActionPlugin.ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { public List<ActionPlugin.ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return singletonList( return singletonList(
new ActionHandler<>(DataScienceStatsAction.INSTANCE, TransportDataScienceStatsAction.class)); new ActionHandler<>(AnalyticsStatsAction.INSTANCE, TransportAnalyticsStatsAction.class));
} }
@Override @Override
@ -61,7 +61,7 @@ public class DataSciencePlugin extends Plugin implements SearchPlugin, ActionPlu
return modules; return modules;
} }
modules.add(b -> XPackPlugin.bindFeatureSet(b, DataScienceFeatureSet.class)); modules.add(b -> XPackPlugin.bindFeatureSet(b, AnalyticsFeatureSet.class));
return modules; return modules;
} }
} }

View File

@ -0,0 +1,58 @@
/*
* 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.analytics.action;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.analytics.action.AnalyticsStatsAction;
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
import java.io.IOException;
import java.util.List;
public class TransportAnalyticsStatsAction extends TransportNodesAction<AnalyticsStatsAction.Request, AnalyticsStatsAction.Response,
AnalyticsStatsAction.NodeRequest, AnalyticsStatsAction.NodeResponse> {
@Inject
public TransportAnalyticsStatsAction(TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(AnalyticsStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
AnalyticsStatsAction.Request::new, AnalyticsStatsAction.NodeRequest::new, ThreadPool.Names.MANAGEMENT,
AnalyticsStatsAction.NodeResponse.class);
}
@Override
protected AnalyticsStatsAction.Response newResponse(AnalyticsStatsAction.Request request,
List<AnalyticsStatsAction.NodeResponse> nodes,
List<FailedNodeException> failures) {
return new AnalyticsStatsAction.Response(clusterService.getClusterName(), nodes, failures);
}
@Override
protected AnalyticsStatsAction.NodeRequest newNodeRequest(AnalyticsStatsAction.Request request) {
return new AnalyticsStatsAction.NodeRequest(request);
}
@Override
protected AnalyticsStatsAction.NodeResponse newNodeResponse(StreamInput in) throws IOException {
return new AnalyticsStatsAction.NodeResponse(in);
}
@Override
protected AnalyticsStatsAction.NodeResponse nodeOperation(AnalyticsStatsAction.NodeRequest request) {
AnalyticsStatsAction.NodeResponse statsResponse = new AnalyticsStatsAction.NodeResponse(clusterService.localNode());
statsResponse.setCumulativeCardinalityUsage(AnalyticsPlugin.cumulativeCardUsage.get());
return statsResponse;
}
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience.cumulativecardinality; package org.elasticsearch.xpack.analytics.cumulativecardinality;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
@ -19,7 +19,7 @@ import org.elasticsearch.search.aggregations.pipeline.AbstractPipelineAggregatio
import org.elasticsearch.search.aggregations.pipeline.BucketMetricsParser; import org.elasticsearch.search.aggregations.pipeline.BucketMetricsParser;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.datascience.DataSciencePlugin; import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@ -116,13 +116,13 @@ public class CumulativeCardinalityPipelineAggregationBuilder
} }
public static CumulativeCardinalityPipelineAggregationBuilder parse(String aggName, XContentParser parser) { public static CumulativeCardinalityPipelineAggregationBuilder parse(String aggName, XContentParser parser) {
if (DataSciencePlugin.getLicenseState().isDataScienceAllowed() == false) { if (AnalyticsPlugin.getLicenseState().isAnalyticsAllowed() == false) {
throw LicenseUtils.newComplianceException(XPackField.DATA_SCIENCE); throw LicenseUtils.newComplianceException(XPackField.ANALYTICS);
} }
// Increment usage here since it is a good boundary between internal and external, and should correlate 1:1 with // Increment usage here since it is a good boundary between internal and external, and should correlate 1:1 with
// usage and not internal instantiations // usage and not internal instantiations
DataSciencePlugin.cumulativeCardUsage.incrementAndGet(); AnalyticsPlugin.cumulativeCardUsage.incrementAndGet();
return PARSER.apply(aggName).apply(parser, null); return PARSER.apply(aggName).apply(parser, null);
} }

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience.cumulativecardinality; package org.elasticsearch.xpack.analytics.cumulativecardinality;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience.cumulativecardinality; package org.elasticsearch.xpack.analytics.cumulativecardinality;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience; package org.elasticsearch.xpack.analytics;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.BigArrays;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience.action; package org.elasticsearch.xpack.analytics.action;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
@ -20,7 +20,7 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.yaml.ObjectPath; import org.elasticsearch.test.rest.yaml.ObjectPath;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.datascience.action.DataScienceStatsAction; import org.elasticsearch.xpack.core.analytics.action.AnalyticsStatsAction;
import org.junit.Before; import org.junit.Before;
import java.util.Arrays; import java.util.Arrays;
@ -31,9 +31,9 @@ import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
public class TransportDataScienceStatsActionTests extends ESTestCase { public class TransportAnalyticsStatsActionTests extends ESTestCase {
private TransportDataScienceStatsAction action; private TransportAnalyticsStatsAction action;
@Before @Before
public void setupTransportAction() { public void setupTransportAction() {
@ -52,16 +52,16 @@ public class TransportDataScienceStatsActionTests extends ESTestCase {
when(clusterService.state()).thenReturn(clusterState); when(clusterService.state()).thenReturn(clusterState);
action = new TransportDataScienceStatsAction(transportService, clusterService, threadPool, new action = new TransportAnalyticsStatsAction(transportService, clusterService, threadPool, new
ActionFilters(Collections.emptySet())); ActionFilters(Collections.emptySet()));
} }
public void testCumulativeCardStats() throws Exception { public void testCumulativeCardStats() throws Exception {
DataScienceStatsAction.Request request = new DataScienceStatsAction.Request(); AnalyticsStatsAction.Request request = new AnalyticsStatsAction.Request();
DataScienceStatsAction.NodeResponse nodeResponse1 = action.nodeOperation(new DataScienceStatsAction.NodeRequest(request)); AnalyticsStatsAction.NodeResponse nodeResponse1 = action.nodeOperation(new AnalyticsStatsAction.NodeRequest(request));
DataScienceStatsAction.NodeResponse nodeResponse2 = action.nodeOperation(new DataScienceStatsAction.NodeRequest(request)); AnalyticsStatsAction.NodeResponse nodeResponse2 = action.nodeOperation(new AnalyticsStatsAction.NodeRequest(request));
DataScienceStatsAction.Response response = action.newResponse(request, AnalyticsStatsAction.Response response = action.newResponse(request,
Arrays.asList(nodeResponse1, nodeResponse2), Collections.emptyList()); Arrays.asList(nodeResponse1, nodeResponse2), Collections.emptyList());
try (XContentBuilder builder = jsonBuilder()) { try (XContentBuilder builder = jsonBuilder()) {

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.datascience.cumulativecardinality; package org.elasticsearch.xpack.analytics.cumulativecardinality;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.document.NumericDocValuesField;
@ -44,7 +44,7 @@ import org.elasticsearch.search.aggregations.support.ValuesSource;
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig; import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
import org.elasticsearch.search.aggregations.support.ValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.xpack.datascience.StubAggregatorFactory; import org.elasticsearch.xpack.analytics.StubAggregatorFactory;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;

View File

@ -70,8 +70,8 @@ public class XPackLicenseState {
"Creating and Starting rollup jobs will no longer be allowed.", "Creating and Starting rollup jobs will no longer be allowed.",
"Stopping/Deleting existing jobs, RollupCaps API and RollupSearch continue to function." "Stopping/Deleting existing jobs, RollupCaps API and RollupSearch continue to function."
}); });
messages.put(XPackField.DATA_SCIENCE, new String[] { messages.put(XPackField.ANALYTICS, new String[] {
"Aggregations provided by Data Science plugin are no longer usable." "Aggregations provided by Analytics plugin are no longer usable."
}); });
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages); EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
} }
@ -748,11 +748,11 @@ public class XPackLicenseState {
} }
/** /**
* Datascience is always available as long as there is a valid license * Analytics is always available as long as there is a valid license
* *
* @return true if the license is active * @return true if the license is active
*/ */
public synchronized boolean isDataScienceAllowed() { public synchronized boolean isAnalyticsAllowed() {
return status.active; return status.active;
} }

View File

@ -55,7 +55,7 @@ import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransform;
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransformState; import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransformState;
import org.elasticsearch.xpack.core.dataframe.transforms.SyncConfig; import org.elasticsearch.xpack.core.dataframe.transforms.SyncConfig;
import org.elasticsearch.xpack.core.dataframe.transforms.TimeSyncConfig; import org.elasticsearch.xpack.core.dataframe.transforms.TimeSyncConfig;
import org.elasticsearch.xpack.core.datascience.DataScienceFeatureSetUsage; import org.elasticsearch.xpack.core.analytics.AnalyticsFeatureSetUsage;
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction; import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
import org.elasticsearch.xpack.core.flattened.FlattenedFeatureSetUsage; import org.elasticsearch.xpack.core.flattened.FlattenedFeatureSetUsage;
import org.elasticsearch.xpack.core.frozen.FrozenIndicesFeatureSetUsage; import org.elasticsearch.xpack.core.frozen.FrozenIndicesFeatureSetUsage;
@ -546,8 +546,8 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.FROZEN_INDICES, FrozenIndicesFeatureSetUsage::new), new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.FROZEN_INDICES, FrozenIndicesFeatureSetUsage::new),
// Spatial // Spatial
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.SPATIAL, SpatialFeatureSetUsage::new), new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.SPATIAL, SpatialFeatureSetUsage::new),
// data science // analytics
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.DATA_SCIENCE, DataScienceFeatureSetUsage::new) new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.ANALYTICS, AnalyticsFeatureSetUsage::new)
); );
} }

View File

@ -47,8 +47,8 @@ public final class XPackField {
public static final String FROZEN_INDICES = "frozen_indices"; public static final String FROZEN_INDICES = "frozen_indices";
/** Name constant for spatial features. */ /** Name constant for spatial features. */
public static final String SPATIAL = "spatial"; public static final String SPATIAL = "spatial";
/** Name constant for the data science plugin. */ /** Name constant for the analytics plugin. */
public static final String DATA_SCIENCE = "data_science"; public static final String ANALYTICS = "analytics";
private XPackField() {} private XPackField() {}

View File

@ -126,10 +126,6 @@ public class XPackSettings {
/** Setting for enabling or disabling vectors. Defaults to true. */ /** Setting for enabling or disabling vectors. Defaults to true. */
public static final Setting<Boolean> VECTORS_ENABLED = Setting.boolSetting("xpack.vectors.enabled", true, Setting.Property.NodeScope); public static final Setting<Boolean> VECTORS_ENABLED = Setting.boolSetting("xpack.vectors.enabled", true, Setting.Property.NodeScope);
/** Setting for enabling or disabling data science plugin. Defaults to true. */
public static final Setting<Boolean> DATA_SCIENCE_ENABLED = Setting.boolSetting("xpack.data-science.enabled",
true, Setting.Property.NodeScope);
public static final List<String> DEFAULT_SUPPORTED_PROTOCOLS; public static final List<String> DEFAULT_SUPPORTED_PROTOCOLS;
static { static {
@ -262,7 +258,6 @@ public class XPackSettings {
settings.add(DATA_FRAME_ENABLED); settings.add(DATA_FRAME_ENABLED);
settings.add(FLATTENED_ENABLED); settings.add(FLATTENED_ENABLED);
settings.add(VECTORS_ENABLED); settings.add(VECTORS_ENABLED);
settings.add(DATA_SCIENCE_ENABLED);
return Collections.unmodifiableList(settings); return Collections.unmodifiableList(settings);
} }

View File

@ -4,30 +4,30 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.core.datascience; package org.elasticsearch.xpack.core.analytics;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackFeatureSet;
import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.core.datascience.action.DataScienceStatsAction; import org.elasticsearch.xpack.core.analytics.action.AnalyticsStatsAction;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class DataScienceFeatureSetUsage extends XPackFeatureSet.Usage { public class AnalyticsFeatureSetUsage extends XPackFeatureSet.Usage {
private final DataScienceStatsAction.Response response; private final AnalyticsStatsAction.Response response;
public DataScienceFeatureSetUsage(boolean available, boolean enabled, DataScienceStatsAction.Response response) { public AnalyticsFeatureSetUsage(boolean available, boolean enabled, AnalyticsStatsAction.Response response) {
super(XPackField.DATA_SCIENCE, available, enabled); super(XPackField.ANALYTICS, available, enabled);
this.response = response; this.response = response;
} }
public DataScienceFeatureSetUsage(StreamInput input) throws IOException { public AnalyticsFeatureSetUsage(StreamInput input) throws IOException {
super(input); super(input);
this.response = new DataScienceStatsAction.Response(input); this.response = new AnalyticsStatsAction.Response(input);
} }
@Override @Override
@ -57,7 +57,7 @@ public class DataScienceFeatureSetUsage extends XPackFeatureSet.Usage {
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
DataScienceFeatureSetUsage other = (DataScienceFeatureSetUsage) obj; AnalyticsFeatureSetUsage other = (AnalyticsFeatureSetUsage) obj;
return Objects.equals(available, other.available) return Objects.equals(available, other.available)
&& Objects.equals(enabled, other.enabled) && Objects.equals(enabled, other.enabled)
&& Objects.equals(response, other.response); && Objects.equals(response, other.response);

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.core.datascience.action; package org.elasticsearch.xpack.core.analytics.action;
import org.elasticsearch.action.ActionType; import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.FailedNodeException;
@ -24,11 +24,11 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class DataScienceStatsAction extends ActionType<DataScienceStatsAction.Response> { public class AnalyticsStatsAction extends ActionType<AnalyticsStatsAction.Response> {
public static final DataScienceStatsAction INSTANCE = new DataScienceStatsAction(); public static final AnalyticsStatsAction INSTANCE = new AnalyticsStatsAction();
public static final String NAME = "cluster:monitor/xpack/datascience/stats"; public static final String NAME = "cluster:monitor/xpack/analytics/stats";
private DataScienceStatsAction() { private AnalyticsStatsAction() {
super(NAME, Response::new); super(NAME, Response::new);
} }

View File

@ -1,67 +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.datascience;
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.datascience.DataScienceFeatureSetUsage;
import org.elasticsearch.xpack.core.datascience.action.DataScienceStatsAction;
import java.util.Map;
public class DataScienceFeatureSet implements XPackFeatureSet {
private final boolean enabled;
private final XPackLicenseState licenseState;
private Client client;
@Inject
public DataScienceFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, Client client) {
this.enabled = XPackSettings.DATA_SCIENCE_ENABLED.get(settings);
this.licenseState = licenseState;
this.client = client;
}
@Override
public String name() {
return XPackField.DATA_SCIENCE;
}
@Override
public boolean available() {
return licenseState != null && licenseState.isDataScienceAllowed();
}
@Override
public boolean enabled() {
return enabled;
}
@Override
public Map<String, Object> nativeCodeInfo() {
return null;
}
@Override
public void usage(ActionListener<XPackFeatureSet.Usage> listener) {
if (enabled) {
DataScienceStatsAction.Request request = new DataScienceStatsAction.Request();
client.execute(DataScienceStatsAction.INSTANCE, request,
ActionListener.wrap(r -> listener.onResponse(new DataScienceFeatureSetUsage(available(), enabled(), r)),
listener::onFailure));
} else {
listener.onResponse(new DataScienceFeatureSetUsage(available(), enabled(), null));
}
}
}

View File

@ -1,58 +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.datascience.action;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.datascience.action.DataScienceStatsAction;
import org.elasticsearch.xpack.datascience.DataSciencePlugin;
import java.io.IOException;
import java.util.List;
public class TransportDataScienceStatsAction extends TransportNodesAction<DataScienceStatsAction.Request, DataScienceStatsAction.Response,
DataScienceStatsAction.NodeRequest, DataScienceStatsAction.NodeResponse> {
@Inject
public TransportDataScienceStatsAction(TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(DataScienceStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
DataScienceStatsAction.Request::new, DataScienceStatsAction.NodeRequest::new, ThreadPool.Names.MANAGEMENT,
DataScienceStatsAction.NodeResponse.class);
}
@Override
protected DataScienceStatsAction.Response newResponse(DataScienceStatsAction.Request request,
List<DataScienceStatsAction.NodeResponse> nodes,
List<FailedNodeException> failures) {
return new DataScienceStatsAction.Response(clusterService.getClusterName(), nodes, failures);
}
@Override
protected DataScienceStatsAction.NodeRequest newNodeRequest(DataScienceStatsAction.Request request) {
return new DataScienceStatsAction.NodeRequest(request);
}
@Override
protected DataScienceStatsAction.NodeResponse newNodeResponse(StreamInput in) throws IOException {
return new DataScienceStatsAction.NodeResponse(in);
}
@Override
protected DataScienceStatsAction.NodeResponse nodeOperation(DataScienceStatsAction.NodeRequest request) {
DataScienceStatsAction.NodeResponse statsResponse = new DataScienceStatsAction.NodeResponse(clusterService.localNode());
statsResponse.setCumulativeCardinalityUsage(DataSciencePlugin.cumulativeCardUsage.get());
return statsResponse;
}
}

View File

@ -25,4 +25,4 @@
- contains: { nodes.$master.modules: { name: x-pack-security } } - contains: { nodes.$master.modules: { name: x-pack-security } }
- contains: { nodes.$master.modules: { name: x-pack-sql } } - contains: { nodes.$master.modules: { name: x-pack-sql } }
- contains: { nodes.$master.modules: { name: x-pack-watcher } } - contains: { nodes.$master.modules: { name: x-pack-watcher } }
- contains: { nodes.$master.modules: { name: x-pack-data-science } } - contains: { nodes.$master.modules: { name: x-pack-analytics } }

View File

@ -28,8 +28,8 @@
- is_true: features.monitoring - is_true: features.monitoring
- is_true: features.monitoring.enabled - is_true: features.monitoring.enabled
# - is_false: features.monitoring.available TODO fix once licensing is fixed # - is_false: features.monitoring.available TODO fix once licensing is fixed
- is_true: features.data_science - is_true: features.analytics
- is_true: features.data_science.enabled - is_true: features.analytics.enabled
- do: - do:
license.post: license.post:
@ -79,8 +79,8 @@
- is_true: features.monitoring - is_true: features.monitoring
- is_true: features.monitoring.enabled - is_true: features.monitoring.enabled
- is_true: features.monitoring.available - is_true: features.monitoring.available
- is_true: features.data_science.enabled - is_true: features.analytics.enabled
- is_true: features.data_science.available - is_true: features.analytics.available
- is_true: tagline - is_true: tagline
- do: - do:
@ -93,7 +93,7 @@
- is_true: graph.available - is_true: graph.available
- is_true: monitoring.enabled - is_true: monitoring.enabled
- is_true: monitoring.available - is_true: monitoring.available
- is_true: data_science.available - is_true: analytics.available
- do: - do:
xpack.info: xpack.info: