From cf8a4171e12a7a12e94e7e8638fdf9ed49dff96a Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Thu, 29 Aug 2019 12:45:39 -0400 Subject: [PATCH] Rename `data-science` plugin to `analytics` (#46133) Rename `data-science` plugin to `analytics`. Also removes enabled flag. Backport of #46092 --- distribution/build.gradle | 1 - docs/reference/rest-api/info.asciidoc | 2 +- .../{data-science => analytics}/build.gradle | 8 +-- .../AnalyticsAggregationBuilders.java} | 6 +- .../xpack/analytics/AnalyticsFeatureSet.java | 58 ++++++++++++++++ .../xpack/analytics/AnalyticsPlugin.java} | 20 +++--- .../action/TransportAnalyticsStatsAction.java | 58 ++++++++++++++++ ...CardinalityPipelineAggregationBuilder.java | 10 +-- ...mulativeCardinalityPipelineAggregator.java | 2 +- .../InternalSimpleLongValue.java | 2 +- .../plugin-metadata/plugin-security.policy | 0 .../analytics}/StubAggregatorFactory.java | 2 +- .../TransportAnalyticsStatsActionTests.java} | 18 ++--- .../CumulativeCardinalityAggregatorTests.java | 4 +- .../license/XPackLicenseState.java | 8 +-- .../xpack/core/XPackClientPlugin.java | 6 +- .../elasticsearch/xpack/core/XPackField.java | 4 +- .../xpack/core/XPackSettings.java | 5 -- .../AnalyticsFeatureSetUsage.java} | 18 ++--- .../action/AnalyticsStatsAction.java} | 10 +-- .../datascience/DataScienceFeatureSet.java | 67 ------------------- .../TransportDataScienceStatsAction.java | 58 ---------------- .../rest-api-spec/test/xpack/10_basic.yml | 2 +- .../rest-api-spec/test/xpack/15_basic.yml | 10 +-- 24 files changed, 182 insertions(+), 197 deletions(-) rename x-pack/plugin/{data-science => analytics}/build.gradle (74%) rename x-pack/plugin/{data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceAggregationBuilders.java => analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsAggregationBuilders.java} (69%) create mode 100644 x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsFeatureSet.java rename x-pack/plugin/{data-science/src/main/java/org/elasticsearch/xpack/datascience/DataSciencePlugin.java => analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java} (69%) create mode 100644 x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsAction.java rename x-pack/plugin/{data-science/src/main/java/org/elasticsearch/xpack/datascience => analytics/src/main/java/org/elasticsearch/xpack/analytics}/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java (95%) rename x-pack/plugin/{data-science/src/main/java/org/elasticsearch/xpack/datascience => analytics/src/main/java/org/elasticsearch/xpack/analytics}/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java (98%) rename x-pack/plugin/{data-science/src/main/java/org/elasticsearch/xpack/datascience => analytics/src/main/java/org/elasticsearch/xpack/analytics}/cumulativecardinality/InternalSimpleLongValue.java (97%) rename x-pack/plugin/{data-science => analytics}/src/main/plugin-metadata/plugin-security.policy (100%) rename x-pack/plugin/{data-science/src/test/java/org/elasticsearch/xpack/datascience => analytics/src/test/java/org/elasticsearch/xpack/analytics}/StubAggregatorFactory.java (97%) rename x-pack/plugin/{data-science/src/test/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsActionTests.java => analytics/src/test/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsActionTests.java} (78%) rename x-pack/plugin/{data-science/src/test/java/org/elasticsearch/xpack/datascience => analytics/src/test/java/org/elasticsearch/xpack/analytics}/cumulativecardinality/CumulativeCardinalityAggregatorTests.java (99%) rename x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/{datascience/DataScienceFeatureSetUsage.java => analytics/AnalyticsFeatureSetUsage.java} (69%) rename x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/{datascience/action/DataScienceStatsAction.java => analytics/action/AnalyticsStatsAction.java} (92%) delete mode 100644 x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceFeatureSet.java delete mode 100644 x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsAction.java diff --git a/distribution/build.gradle b/distribution/build.gradle index 3055ec82670..d71038f36c7 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -425,7 +425,6 @@ task run(type: RunTask) { setting 'xpack.monitoring.enabled', 'true' setting 'xpack.sql.enabled', 'true' setting 'xpack.rollup.enabled', 'true' - setting 'xpack.data-science.enabled', 'true' keystoreSetting 'bootstrap.password', 'password' } } diff --git a/docs/reference/rest-api/info.asciidoc b/docs/reference/rest-api/info.asciidoc index f48337ffd35..98a4dfda2c9 100644 --- a/docs/reference/rest-api/info.asciidoc +++ b/docs/reference/rest-api/info.asciidoc @@ -71,7 +71,7 @@ Example response: "available" : true, "enabled" : true }, - "data_science" : { + "analytics" : { "available" : true, "enabled" : true }, diff --git a/x-pack/plugin/data-science/build.gradle b/x-pack/plugin/analytics/build.gradle similarity index 74% rename from x-pack/plugin/data-science/build.gradle rename to x-pack/plugin/analytics/build.gradle index 815491451fd..19799b750fd 100644 --- a/x-pack/plugin/data-science/build.gradle +++ b/x-pack/plugin/analytics/build.gradle @@ -2,12 +2,12 @@ evaluationDependsOn(xpackModule('core')) apply plugin: 'elasticsearch.esplugin' esplugin { - name 'x-pack-data-science' - description 'Elasticsearch Expanded Pack Plugin - Data Science' - classname 'org.elasticsearch.xpack.datascience.DataSciencePlugin' + name 'x-pack-analytics' + description 'Elasticsearch Expanded Pack Plugin - Analytics' + classname 'org.elasticsearch.xpack.analytics.AnalyticsPlugin' extendedPlugins = ['x-pack-core'] } -archivesBaseName = 'x-pack-data-science' +archivesBaseName = 'x-pack-analytics' compileJava.options.compilerArgs << "-Xlint:-rawtypes" compileTestJava.options.compilerArgs << "-Xlint:-rawtypes" diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceAggregationBuilders.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsAggregationBuilders.java similarity index 69% rename from x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceAggregationBuilders.java rename to x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsAggregationBuilders.java index fa2365db1b8..e6a7b8cb9c2 100644 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceAggregationBuilders.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsAggregationBuilders.java @@ -3,11 +3,11 @@ * 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; +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) { return new CumulativeCardinalityPipelineAggregationBuilder(name, bucketsPath); diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsFeatureSet.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsFeatureSet.java new file mode 100644 index 00000000000..49ad4a3eb5c --- /dev/null +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsFeatureSet.java @@ -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 nativeCodeInfo() { + return null; + } + + @Override + public void usage(ActionListener listener) { + AnalyticsStatsAction.Request request = new AnalyticsStatsAction.Request(); + client.execute(AnalyticsStatsAction.INSTANCE, request, + ActionListener.wrap(r -> listener.onResponse(new AnalyticsFeatureSetUsage(available(), enabled(), r)), + listener::onFailure)); + } +} diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataSciencePlugin.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java similarity index 69% rename from x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataSciencePlugin.java rename to x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java index 2676d42a6a8..6dbe0ff05a6 100644 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataSciencePlugin.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/AnalyticsPlugin.java @@ -3,7 +3,7 @@ * 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; +package org.elasticsearch.xpack.analytics; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; @@ -14,10 +14,10 @@ import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.SearchPlugin; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.datascience.action.DataScienceStatsAction; -import org.elasticsearch.xpack.datascience.action.TransportDataScienceStatsAction; -import org.elasticsearch.xpack.datascience.cumulativecardinality.CumulativeCardinalityPipelineAggregationBuilder; -import org.elasticsearch.xpack.datascience.cumulativecardinality.CumulativeCardinalityPipelineAggregator; +import org.elasticsearch.xpack.core.analytics.action.AnalyticsStatsAction; +import org.elasticsearch.xpack.analytics.action.TransportAnalyticsStatsAction; +import org.elasticsearch.xpack.analytics.cumulativecardinality.CumulativeCardinalityPipelineAggregationBuilder; +import org.elasticsearch.xpack.analytics.cumulativecardinality.CumulativeCardinalityPipelineAggregator; import java.util.ArrayList; import java.util.Collection; @@ -26,13 +26,13 @@ import java.util.concurrent.atomic.AtomicLong; 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); private final boolean transportClientMode; - public DataSciencePlugin(Settings settings) { + public AnalyticsPlugin(Settings settings) { this.transportClientMode = XPackPlugin.transportClientMode(settings); } @@ -50,7 +50,7 @@ public class DataSciencePlugin extends Plugin implements SearchPlugin, ActionPlu @Override public List> getActions() { return singletonList( - new ActionHandler<>(DataScienceStatsAction.INSTANCE, TransportDataScienceStatsAction.class)); + new ActionHandler<>(AnalyticsStatsAction.INSTANCE, TransportAnalyticsStatsAction.class)); } @Override @@ -61,7 +61,7 @@ public class DataSciencePlugin extends Plugin implements SearchPlugin, ActionPlu return modules; } - modules.add(b -> XPackPlugin.bindFeatureSet(b, DataScienceFeatureSet.class)); + modules.add(b -> XPackPlugin.bindFeatureSet(b, AnalyticsFeatureSet.class)); return modules; } } diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsAction.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsAction.java new file mode 100644 index 00000000000..db17bb15f57 --- /dev/null +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsAction.java @@ -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 { + + + @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 nodes, + List 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; + } + +} diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java similarity index 95% rename from x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java rename to x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java index f24f09ccba4..a80c410a260 100644 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityPipelineAggregationBuilder.java @@ -3,7 +3,7 @@ * 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.cumulativecardinality; +package org.elasticsearch.xpack.analytics.cumulativecardinality; import org.elasticsearch.common.io.stream.StreamInput; 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.PipelineAggregator; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.datascience.DataSciencePlugin; +import org.elasticsearch.xpack.analytics.AnalyticsPlugin; import java.io.IOException; import java.util.Collection; @@ -116,13 +116,13 @@ public class CumulativeCardinalityPipelineAggregationBuilder } public static CumulativeCardinalityPipelineAggregationBuilder parse(String aggName, XContentParser parser) { - if (DataSciencePlugin.getLicenseState().isDataScienceAllowed() == false) { - throw LicenseUtils.newComplianceException(XPackField.DATA_SCIENCE); + if (AnalyticsPlugin.getLicenseState().isAnalyticsAllowed() == false) { + throw LicenseUtils.newComplianceException(XPackField.ANALYTICS); } // Increment usage here since it is a good boundary between internal and external, and should correlate 1:1 with // usage and not internal instantiations - DataSciencePlugin.cumulativeCardUsage.incrementAndGet(); + AnalyticsPlugin.cumulativeCardUsage.incrementAndGet(); return PARSER.apply(aggName).apply(parser, null); } diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java similarity index 98% rename from x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java rename to x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java index 5e79c1f3095..67cfbc6f04c 100644 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityPipelineAggregator.java @@ -3,7 +3,7 @@ * 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.cumulativecardinality; +package org.elasticsearch.xpack.analytics.cumulativecardinality; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/InternalSimpleLongValue.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/InternalSimpleLongValue.java similarity index 97% rename from x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/InternalSimpleLongValue.java rename to x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/InternalSimpleLongValue.java index bd9c7903f4a..e8db75edad5 100644 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/cumulativecardinality/InternalSimpleLongValue.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/cumulativecardinality/InternalSimpleLongValue.java @@ -3,7 +3,7 @@ * 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.cumulativecardinality; +package org.elasticsearch.xpack.analytics.cumulativecardinality; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/x-pack/plugin/data-science/src/main/plugin-metadata/plugin-security.policy b/x-pack/plugin/analytics/src/main/plugin-metadata/plugin-security.policy similarity index 100% rename from x-pack/plugin/data-science/src/main/plugin-metadata/plugin-security.policy rename to x-pack/plugin/analytics/src/main/plugin-metadata/plugin-security.policy diff --git a/x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/StubAggregatorFactory.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/StubAggregatorFactory.java similarity index 97% rename from x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/StubAggregatorFactory.java rename to x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/StubAggregatorFactory.java index fd45a15c765..edcd66ab422 100644 --- a/x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/StubAggregatorFactory.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/StubAggregatorFactory.java @@ -3,7 +3,7 @@ * 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; +package org.elasticsearch.xpack.analytics; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; diff --git a/x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsActionTests.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsActionTests.java similarity index 78% rename from x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsActionTests.java rename to x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsActionTests.java index 8ce58bbf83e..3b85e6ccc68 100644 --- a/x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsActionTests.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/action/TransportAnalyticsStatsActionTests.java @@ -3,7 +3,7 @@ * 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; +package org.elasticsearch.xpack.analytics.action; import org.elasticsearch.Version; 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.threadpool.ThreadPool; 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 java.util.Arrays; @@ -31,9 +31,9 @@ import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class TransportDataScienceStatsActionTests extends ESTestCase { +public class TransportAnalyticsStatsActionTests extends ESTestCase { - private TransportDataScienceStatsAction action; + private TransportAnalyticsStatsAction action; @Before public void setupTransportAction() { @@ -52,16 +52,16 @@ public class TransportDataScienceStatsActionTests extends ESTestCase { when(clusterService.state()).thenReturn(clusterState); - action = new TransportDataScienceStatsAction(transportService, clusterService, threadPool, new + action = new TransportAnalyticsStatsAction(transportService, clusterService, threadPool, new ActionFilters(Collections.emptySet())); } public void testCumulativeCardStats() throws Exception { - DataScienceStatsAction.Request request = new DataScienceStatsAction.Request(); - DataScienceStatsAction.NodeResponse nodeResponse1 = action.nodeOperation(new DataScienceStatsAction.NodeRequest(request)); - DataScienceStatsAction.NodeResponse nodeResponse2 = action.nodeOperation(new DataScienceStatsAction.NodeRequest(request)); + AnalyticsStatsAction.Request request = new AnalyticsStatsAction.Request(); + AnalyticsStatsAction.NodeResponse nodeResponse1 = action.nodeOperation(new AnalyticsStatsAction.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()); try (XContentBuilder builder = jsonBuilder()) { diff --git a/x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityAggregatorTests.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityAggregatorTests.java similarity index 99% rename from x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityAggregatorTests.java rename to x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityAggregatorTests.java index d2182529e6c..d4d47a5bdfe 100644 --- a/x-pack/plugin/data-science/src/test/java/org/elasticsearch/xpack/datascience/cumulativecardinality/CumulativeCardinalityAggregatorTests.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/cumulativecardinality/CumulativeCardinalityAggregatorTests.java @@ -3,7 +3,7 @@ * 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.cumulativecardinality; +package org.elasticsearch.xpack.analytics.cumulativecardinality; import org.apache.lucene.document.Document; 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.ValuesSourceType; import org.elasticsearch.search.internal.SearchContext; -import org.elasticsearch.xpack.datascience.StubAggregatorFactory; +import org.elasticsearch.xpack.analytics.StubAggregatorFactory; import java.io.IOException; import java.util.Arrays; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index ac58bdf4556..ddbf784520e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -70,8 +70,8 @@ public class XPackLicenseState { "Creating and Starting rollup jobs will no longer be allowed.", "Stopping/Deleting existing jobs, RollupCaps API and RollupSearch continue to function." }); - messages.put(XPackField.DATA_SCIENCE, new String[] { - "Aggregations provided by Data Science plugin are no longer usable." + messages.put(XPackField.ANALYTICS, new String[] { + "Aggregations provided by Analytics plugin are no longer usable." }); 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 */ - public synchronized boolean isDataScienceAllowed() { + public synchronized boolean isAnalyticsAllowed() { return status.active; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java index 3a47135db9b..9d786b815b6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java @@ -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.SyncConfig; 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.flattened.FlattenedFeatureSetUsage; 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), // Spatial new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.SPATIAL, SpatialFeatureSetUsage::new), - // data science - new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.DATA_SCIENCE, DataScienceFeatureSetUsage::new) + // analytics + new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.ANALYTICS, AnalyticsFeatureSetUsage::new) ); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java index 4f61ff03ebf..0dc58b55ae9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java @@ -47,8 +47,8 @@ public final class XPackField { public static final String FROZEN_INDICES = "frozen_indices"; /** Name constant for spatial features. */ public static final String SPATIAL = "spatial"; - /** Name constant for the data science plugin. */ - public static final String DATA_SCIENCE = "data_science"; + /** Name constant for the analytics plugin. */ + public static final String ANALYTICS = "analytics"; private XPackField() {} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 5ad38596491..625ecb98c1b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -126,10 +126,6 @@ public class XPackSettings { /** Setting for enabling or disabling vectors. Defaults to true. */ public static final Setting 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 DATA_SCIENCE_ENABLED = Setting.boolSetting("xpack.data-science.enabled", - true, Setting.Property.NodeScope); - public static final List DEFAULT_SUPPORTED_PROTOCOLS; static { @@ -262,7 +258,6 @@ public class XPackSettings { settings.add(DATA_FRAME_ENABLED); settings.add(FLATTENED_ENABLED); settings.add(VECTORS_ENABLED); - settings.add(DATA_SCIENCE_ENABLED); return Collections.unmodifiableList(settings); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datascience/DataScienceFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/AnalyticsFeatureSetUsage.java similarity index 69% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datascience/DataScienceFeatureSetUsage.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/AnalyticsFeatureSetUsage.java index f4ed1b12c9b..a7521b95f56 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datascience/DataScienceFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/AnalyticsFeatureSetUsage.java @@ -4,30 +4,30 @@ * 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.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.xpack.core.XPackFeatureSet; 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.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) { - super(XPackField.DATA_SCIENCE, available, enabled); + public AnalyticsFeatureSetUsage(boolean available, boolean enabled, AnalyticsStatsAction.Response response) { + super(XPackField.ANALYTICS, available, enabled); this.response = response; } - public DataScienceFeatureSetUsage(StreamInput input) throws IOException { + public AnalyticsFeatureSetUsage(StreamInput input) throws IOException { super(input); - this.response = new DataScienceStatsAction.Response(input); + this.response = new AnalyticsStatsAction.Response(input); } @Override @@ -57,7 +57,7 @@ public class DataScienceFeatureSetUsage extends XPackFeatureSet.Usage { if (getClass() != obj.getClass()) { return false; } - DataScienceFeatureSetUsage other = (DataScienceFeatureSetUsage) obj; + AnalyticsFeatureSetUsage other = (AnalyticsFeatureSetUsage) obj; return Objects.equals(available, other.available) && Objects.equals(enabled, other.enabled) && Objects.equals(response, other.response); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datascience/action/DataScienceStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java similarity index 92% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datascience/action/DataScienceStatsAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java index 6a06dc39227..38f84aefc43 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datascience/action/DataScienceStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java @@ -3,7 +3,7 @@ * 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.core.datascience.action; +package org.elasticsearch.xpack.core.analytics.action; import org.elasticsearch.action.ActionType; import org.elasticsearch.action.FailedNodeException; @@ -24,11 +24,11 @@ import java.io.IOException; import java.util.List; import java.util.Objects; -public class DataScienceStatsAction extends ActionType { - public static final DataScienceStatsAction INSTANCE = new DataScienceStatsAction(); - public static final String NAME = "cluster:monitor/xpack/datascience/stats"; +public class AnalyticsStatsAction extends ActionType { + public static final AnalyticsStatsAction INSTANCE = new AnalyticsStatsAction(); + public static final String NAME = "cluster:monitor/xpack/analytics/stats"; - private DataScienceStatsAction() { + private AnalyticsStatsAction() { super(NAME, Response::new); } diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceFeatureSet.java b/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceFeatureSet.java deleted file mode 100644 index 7da8d6d888e..00000000000 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/DataScienceFeatureSet.java +++ /dev/null @@ -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 nativeCodeInfo() { - return null; - } - - @Override - public void usage(ActionListener 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)); - } - } -} diff --git a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsAction.java b/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsAction.java deleted file mode 100644 index c14ee518f60..00000000000 --- a/x-pack/plugin/data-science/src/main/java/org/elasticsearch/xpack/datascience/action/TransportDataScienceStatsAction.java +++ /dev/null @@ -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 { - - - @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 nodes, - List 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; - } - -} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml index 0b593a87d7e..4fd755d5fed 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml @@ -25,4 +25,4 @@ - contains: { nodes.$master.modules: { name: x-pack-security } } - contains: { nodes.$master.modules: { name: x-pack-sql } } - 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 } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/15_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/15_basic.yml index d0e1a9b773e..5a228d1be54 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/15_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/xpack/15_basic.yml @@ -28,8 +28,8 @@ - is_true: features.monitoring - is_true: features.monitoring.enabled # - is_false: features.monitoring.available TODO fix once licensing is fixed - - is_true: features.data_science - - is_true: features.data_science.enabled + - is_true: features.analytics + - is_true: features.analytics.enabled - do: license.post: @@ -79,8 +79,8 @@ - is_true: features.monitoring - is_true: features.monitoring.enabled - is_true: features.monitoring.available - - is_true: features.data_science.enabled - - is_true: features.data_science.available + - is_true: features.analytics.enabled + - is_true: features.analytics.available - is_true: tagline - do: @@ -93,7 +93,7 @@ - is_true: graph.available - is_true: monitoring.enabled - is_true: monitoring.available - - is_true: data_science.available + - is_true: analytics.available - do: xpack.info: