1
0
Эх сурвалжийг харах

Move downsample feature to its own xpack plugin (#98422)

Due the fact that downsampling and rollup where in the same module, it is sometime confusing what is what and rollup and downsample terminology are easily mixed up. Splitting downsampling in its own x-pack module should reduce confusion. There are some classes, fields, methods, variables and comments that need renaming, but this PR is focussed around moving downsampling to its module and renames would make it more difficult to review. I will do renaming in a follow up PR.

The upside is that rollup no longer needs to depends on the aggregate double module, only downsampling depends on this and the downsample plugin doesn't need all the transport and rest actions and scheduler service that rollup depends on.
Martijn van Groningen 2 жил өмнө
parent
commit
4a209b4a92
36 өөрчлөгдсөн 212 нэмэгдсэн , 143 устгасан
  1. 23 0
      x-pack/plugin/downsample/build.gradle
  2. 0 0
      x-pack/plugin/downsample/qa/build.gradle
  3. 0 0
      x-pack/plugin/downsample/qa/rest/build.gradle
  4. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java
  5. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/10_basic.yml
  6. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/20_unsupported_aggs.yml
  7. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/30_date_histogram.yml
  8. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/40_runtime_fields.yml
  9. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/50_auto_date_histogram.yml
  10. 0 0
      x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/60_settings.yml
  11. 1 2
      x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleClusterDisruptionIT.java
  12. 1 2
      x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java
  13. 1 2
      x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/ILMDownsampleDisruptionIT.java
  14. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/AbstractDownsampleFieldProducer.java
  15. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/AggregateMetricFieldSerializer.java
  16. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/AggregateMetricFieldValueFetcher.java
  17. 176 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/Downsample.java
  18. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/DownsampleFieldSerializer.java
  19. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/DownsampleShardTaskParams.java
  20. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java
  21. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/LabelFieldProducer.java
  22. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/MetricFieldProducer.java
  23. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RestDownsampleAction.java
  24. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java
  25. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexerException.java
  26. 2 3
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RollupShardPersistentTaskExecutor.java
  27. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TimeseriesFieldTypeHelper.java
  28. 0 0
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java
  29. 1 2
      x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleIndexerAction.java
  30. 1 2
      x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
  31. 1 2
      x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java
  32. 0 0
      x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/LabelFieldProducerTests.java
  33. 0 0
      x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/MetricFieldProducerTests.java
  34. 0 0
      x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java
  35. 1 7
      x-pack/plugin/rollup/build.gradle
  36. 4 121
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java

+ 23 - 0
x-pack/plugin/downsample/build.gradle

@@ -0,0 +1,23 @@
+apply plugin: 'elasticsearch.internal-es-plugin'
+apply plugin: 'elasticsearch.internal-cluster-test'
+esplugin {
+  name 'x-pack-downsample'
+  description 'Elasticsearch Expanded Pack Plugin - Downsample'
+  classname 'org.elasticsearch.xpack.downsample.Downsample'
+  extendedPlugins = ['x-pack-aggregate-metric']
+}
+
+base {
+  archivesName = 'x-pack-downsample'
+}
+
+dependencies {
+  compileOnly project(path: xpackModule('core'))
+  testImplementation project(':modules:data-streams')
+  testImplementation project(path: xpackModule('ilm'))
+  compileOnly project(path: xpackModule('mapper-aggregate-metric'))
+  testImplementation(testArtifact(project(xpackModule('core'))))
+  testImplementation project(xpackModule('ccr'))
+}
+
+addQaCheckDependencies(project)

+ 0 - 0
x-pack/plugin/rollup/qa/build.gradle → x-pack/plugin/downsample/qa/build.gradle


+ 0 - 0
x-pack/plugin/rollup/qa/rest/build.gradle → x-pack/plugin/downsample/qa/rest/build.gradle


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/10_basic.yml → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/10_basic.yml


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/20_unsupported_aggs.yml → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/20_unsupported_aggs.yml


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/30_date_histogram.yml → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/30_date_histogram.yml


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/40_runtime_fields.yml → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/40_runtime_fields.yml


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/50_auto_date_histogram.yml → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/50_auto_date_histogram.yml


+ 0 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/60_settings.yml → x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample/60_settings.yml


+ 1 - 2
x-pack/plugin/rollup/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleClusterDisruptionIT.java → x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleClusterDisruptionIT.java

@@ -37,7 +37,6 @@ import org.elasticsearch.xcontent.XContentFactory;
 import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
 import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
 import org.elasticsearch.xpack.core.downsample.DownsampleAction;
-import org.elasticsearch.xpack.rollup.Rollup;
 
 import java.io.IOException;
 import java.time.Instant;
@@ -68,7 +67,7 @@ public class DownsampleClusterDisruptionIT extends ESIntegTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return List.of(LocalStateCompositeXPackPlugin.class, Rollup.class, AggregateMetricMapperPlugin.class);
+        return List.of(LocalStateCompositeXPackPlugin.class, Downsample.class, AggregateMetricMapperPlugin.class);
     }
 
     interface DisruptionListener {

+ 1 - 2
x-pack/plugin/rollup/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java → x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java

@@ -38,7 +38,6 @@ import org.elasticsearch.xcontent.XContentType;
 import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
 import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
 import org.elasticsearch.xpack.core.downsample.DownsampleAction;
-import org.elasticsearch.xpack.rollup.Rollup;
 import org.junit.Before;
 
 import java.io.IOException;
@@ -158,7 +157,7 @@ public class DownsampleTransportFailureIT extends ESIntegTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return List.of(LocalStateCompositeXPackPlugin.class, Rollup.class, AggregateMetricMapperPlugin.class);
+        return List.of(LocalStateCompositeXPackPlugin.class, Downsample.class, AggregateMetricMapperPlugin.class);
     }
 
     @Override

+ 1 - 2
x-pack/plugin/rollup/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/ILMDownsampleDisruptionIT.java → x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/ILMDownsampleDisruptionIT.java

@@ -44,7 +44,6 @@ import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
 import org.elasticsearch.xpack.core.ilm.Phase;
 import org.elasticsearch.xpack.core.ilm.action.PutLifecycleAction;
 import org.elasticsearch.xpack.ilm.IndexLifecycle;
-import org.elasticsearch.xpack.rollup.Rollup;
 
 import java.io.IOException;
 import java.time.Instant;
@@ -80,7 +79,7 @@ public class ILMDownsampleDisruptionIT extends ESIntegTestCase {
     protected Collection<Class<? extends Plugin>> nodePlugins() {
         return List.of(
             LocalStateCompositeXPackPlugin.class,
-            Rollup.class,
+            Downsample.class,
             AggregateMetricMapperPlugin.class,
             LocalStateCompositeXPackPlugin.class,
             IndexLifecycle.class,

+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AbstractDownsampleFieldProducer.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/AbstractDownsampleFieldProducer.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AggregateMetricFieldSerializer.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/AggregateMetricFieldSerializer.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AggregateMetricFieldValueFetcher.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/AggregateMetricFieldValueFetcher.java


+ 176 - 0
x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/Downsample.java

@@ -0,0 +1,176 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.downsample;
+
+import org.elasticsearch.action.ActionRequest;
+import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.client.internal.Client;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.routing.allocation.AllocationService;
+import org.elasticsearch.cluster.service.ClusterService;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.settings.ClusterSettings;
+import org.elasticsearch.common.settings.IndexScopedSettings;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.settings.SettingsFilter;
+import org.elasticsearch.common.settings.SettingsModule;
+import org.elasticsearch.common.util.concurrent.EsExecutors;
+import org.elasticsearch.env.Environment;
+import org.elasticsearch.env.NodeEnvironment;
+import org.elasticsearch.indices.IndicesService;
+import org.elasticsearch.persistent.PersistentTaskParams;
+import org.elasticsearch.persistent.PersistentTaskState;
+import org.elasticsearch.persistent.PersistentTasksExecutor;
+import org.elasticsearch.plugins.ActionPlugin;
+import org.elasticsearch.plugins.PersistentTaskPlugin;
+import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.repositories.RepositoriesService;
+import org.elasticsearch.rest.RestController;
+import org.elasticsearch.rest.RestHandler;
+import org.elasticsearch.script.ScriptService;
+import org.elasticsearch.threadpool.ExecutorBuilder;
+import org.elasticsearch.threadpool.FixedExecutorBuilder;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.tracing.Tracer;
+import org.elasticsearch.watcher.ResourceWatcherService;
+import org.elasticsearch.xcontent.NamedXContentRegistry;
+import org.elasticsearch.xcontent.ParseField;
+import org.elasticsearch.xpack.core.downsample.DownsampleAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleIndexerAction;
+import org.elasticsearch.xpack.core.rollup.action.RollupShardPersistentTaskState;
+import org.elasticsearch.xpack.core.rollup.action.RollupShardTask;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Supplier;
+
+public class Downsample extends Plugin implements ActionPlugin, PersistentTaskPlugin {
+
+    public static final String DOWSAMPLE_TASK_THREAD_POOL_NAME = "downsample_indexing";
+    private static final int DOWNSAMPLE_TASK_THREAD_POOL_QUEUE_SIZE = 256;
+
+    private IndicesService indicesService;
+
+    @Override
+    public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
+        final FixedExecutorBuilder downsample = new FixedExecutorBuilder(
+            settings,
+            DOWSAMPLE_TASK_THREAD_POOL_NAME,
+            ThreadPool.oneEighthAllocatedProcessors(EsExecutors.allocatedProcessors(settings)),
+            DOWNSAMPLE_TASK_THREAD_POOL_QUEUE_SIZE,
+            "xpack.downsample.thread_pool",
+            EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
+        );
+        return List.of(downsample);
+    }
+
+    @Override
+    public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
+        return List.of(
+            new ActionHandler<>(DownsampleIndexerAction.INSTANCE, TransportDownsampleIndexerAction.class),
+            new ActionHandler<>(DownsampleAction.INSTANCE, TransportDownsampleAction.class)
+        );
+    }
+
+    @Override
+    public List<RestHandler> getRestHandlers(
+        Settings settings,
+        RestController restController,
+        ClusterSettings clusterSettings,
+        IndexScopedSettings indexScopedSettings,
+        SettingsFilter settingsFilter,
+        IndexNameExpressionResolver indexNameExpressionResolver,
+        Supplier<DiscoveryNodes> nodesInCluster
+    ) {
+        return List.of(new RestDownsampleAction());
+    }
+
+    @Override
+    public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(
+        ClusterService clusterService,
+        ThreadPool threadPool,
+        Client client,
+        SettingsModule settingsModule,
+        IndexNameExpressionResolver expressionResolver
+    ) {
+        return List.of(
+            new RollupShardPersistentTaskExecutor(client, this.indicesService, RollupShardTask.TASK_NAME, DOWSAMPLE_TASK_THREAD_POOL_NAME)
+        );
+    }
+
+    @Override
+    public List<NamedXContentRegistry.Entry> getNamedXContent() {
+        return List.of(
+            new NamedXContentRegistry.Entry(
+                PersistentTaskState.class,
+                new ParseField(RollupShardPersistentTaskState.NAME),
+                RollupShardPersistentTaskState::fromXContent
+            ),
+            new NamedXContentRegistry.Entry(
+                PersistentTaskParams.class,
+                new ParseField(DownsampleShardTaskParams.NAME),
+                DownsampleShardTaskParams::fromXContent
+            )
+        );
+    }
+
+    @Override
+    public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
+        return List.of(
+            new NamedWriteableRegistry.Entry(
+                PersistentTaskState.class,
+                RollupShardPersistentTaskState.NAME,
+                RollupShardPersistentTaskState::readFromStream
+            ),
+            new NamedWriteableRegistry.Entry(
+                PersistentTaskParams.class,
+                DownsampleShardTaskParams.NAME,
+                DownsampleShardTaskParams::readFromStream
+            )
+        );
+    }
+
+    @Override
+    public Collection<Object> createComponents(
+        final Client client,
+        final ClusterService clusterService,
+        final ThreadPool threadPool,
+        final ResourceWatcherService resourceWatcherService,
+        final ScriptService scriptService,
+        final NamedXContentRegistry xContentRegistry,
+        final Environment environment,
+        final NodeEnvironment nodeEnvironment,
+        final NamedWriteableRegistry namedWriteableRegistry,
+        final IndexNameExpressionResolver indexNameExpressionResolver,
+        final Supplier<RepositoriesService> repositoriesServiceSupplier,
+        final Tracer tracer,
+        final AllocationService allocationService,
+        final IndicesService indicesService
+    ) {
+        final Collection<Object> components = super.createComponents(
+            client,
+            clusterService,
+            threadPool,
+            resourceWatcherService,
+            scriptService,
+            xContentRegistry,
+            environment,
+            nodeEnvironment,
+            namedWriteableRegistry,
+            indexNameExpressionResolver,
+            repositoriesServiceSupplier,
+            tracer,
+            allocationService,
+            indicesService
+        );
+
+        this.indicesService = indicesService;
+        return components;
+    }
+}

+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/DownsampleFieldSerializer.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/DownsampleFieldSerializer.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/DownsampleShardTaskParams.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/DownsampleShardTaskParams.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/LabelFieldProducer.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/LabelFieldProducer.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/MetricFieldProducer.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/MetricFieldProducer.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RestDownsampleAction.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RestDownsampleAction.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexerException.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexerException.java


+ 2 - 3
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardPersistentTaskExecutor.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/RollupShardPersistentTaskExecutor.java

@@ -30,7 +30,6 @@ import org.elasticsearch.tasks.TaskId;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardIndexerStatus;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardPersistentTaskState;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardTask;
-import org.elasticsearch.xpack.rollup.Rollup;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -73,7 +72,7 @@ public class RollupShardPersistentTaskExecutor extends PersistentTasksExecutor<D
     }
 
     private void fork(final AllocatedPersistentTask task, final DownsampleShardTaskParams params, final SearchHit[] lastRollupTsidHits) {
-        client.threadPool().executor(Rollup.DOWSAMPLE_TASK_THREAD_POOL_NAME).execute(new AbstractRunnable() {
+        client.threadPool().executor(Downsample.DOWSAMPLE_TASK_THREAD_POOL_NAME).execute(new AbstractRunnable() {
             @Override
             public void onFailure(Exception e) {
                 task.markAsFailed(e);
@@ -182,6 +181,6 @@ public class RollupShardPersistentTaskExecutor extends PersistentTasksExecutor<D
 
     @Override
     public String getExecutor() {
-        return Rollup.DOWSAMPLE_TASK_THREAD_POOL_NAME;
+        return Downsample.DOWSAMPLE_TASK_THREAD_POOL_NAME;
     }
 }

+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TimeseriesFieldTypeHelper.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TimeseriesFieldTypeHelper.java


+ 0 - 0
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java


+ 1 - 2
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleIndexerAction.java → x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleIndexerAction.java

@@ -32,7 +32,6 @@ import org.elasticsearch.xpack.core.downsample.DownsampleIndexerAction;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardIndexerStatus;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardPersistentTaskState;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardTask;
-import org.elasticsearch.xpack.rollup.Rollup;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -70,7 +69,7 @@ public class TransportDownsampleIndexerAction extends TransportBroadcastAction<
             indexNameExpressionResolver,
             DownsampleIndexerAction.Request::new,
             DownsampleIndexerAction.ShardDownsampleRequest::new,
-            Rollup.DOWSAMPLE_TASK_THREAD_POOL_NAME
+            Downsample.DOWSAMPLE_TASK_THREAD_POOL_NAME
         );
         this.client = new OriginSettingClient(client, ClientHelper.ROLLUP_ORIGIN);
         this.clusterService = clusterService;

+ 1 - 2
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java → x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java

@@ -91,7 +91,6 @@ import org.elasticsearch.xpack.core.rollup.action.RollupShardIndexerStatus;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardPersistentTaskState;
 import org.elasticsearch.xpack.core.rollup.action.RollupShardTask;
 import org.elasticsearch.xpack.ilm.IndexLifecycle;
-import org.elasticsearch.xpack.rollup.Rollup;
 import org.junit.Before;
 
 import java.io.IOException;
@@ -158,7 +157,7 @@ public class DownsampleActionSingleNodeTests extends ESSingleNodeTestCase {
     protected Collection<Class<? extends Plugin>> getPlugins() {
         return List.of(
             LocalStateCompositeXPackPlugin.class,
-            Rollup.class,
+            Downsample.class,
             AggregateMetricMapperPlugin.class,
             DataStreamsPlugin.class,
             IndexLifecycle.class

+ 1 - 2
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java → x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java

@@ -50,7 +50,6 @@ import org.elasticsearch.search.sort.SortOrder;
 import org.elasticsearch.test.ESSingleNodeTestCase;
 import org.elasticsearch.xcontent.XContentType;
 import org.elasticsearch.xpack.core.downsample.DownsampleAction;
-import org.elasticsearch.xpack.rollup.Rollup;
 import org.hamcrest.Matchers;
 
 import java.io.IOException;
@@ -71,7 +70,7 @@ public class DownsampleDataStreamTests extends ESSingleNodeTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> getPlugins() {
-        return List.of(Rollup.class, DataStreamsPlugin.class);
+        return List.of(Downsample.class, DataStreamsPlugin.class);
     }
 
     public void testDataStreamDownsample() throws ExecutionException, InterruptedException, IOException {

+ 0 - 0
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/LabelFieldProducerTests.java → x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/LabelFieldProducerTests.java


+ 0 - 0
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/MetricFieldProducerTests.java → x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/MetricFieldProducerTests.java


+ 0 - 0
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java → x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java


+ 1 - 7
x-pack/plugin/rollup/build.gradle

@@ -1,10 +1,9 @@
 apply plugin: 'elasticsearch.internal-es-plugin'
-apply plugin: 'elasticsearch.internal-cluster-test'
 esplugin {
   name 'x-pack-rollup'
   description 'Elasticsearch Expanded Pack Plugin - Rollup'
   classname 'org.elasticsearch.xpack.rollup.Rollup'
-  extendedPlugins = ['x-pack-aggregate-metric']
+  extendedPlugins = ['x-pack-core']
 }
 
 base {
@@ -12,13 +11,8 @@ base {
 }
 
 dependencies {
-  testImplementation project(path: ':test:framework')
   compileOnly project(path: xpackModule('core'))
-  testImplementation project(':modules:data-streams')
-  testImplementation project(path: xpackModule('ilm'))
-  compileOnly project(path: xpackModule('mapper-aggregate-metric'))
   testImplementation(testArtifact(project(xpackModule('core'))))
-  testImplementation project(xpackModule('ccr'))
 }
 
 addQaCheckDependencies(project)

+ 4 - 121
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java

@@ -12,9 +12,7 @@ import org.elasticsearch.action.ActionResponse;
 import org.elasticsearch.client.internal.Client;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.allocation.AllocationService;
 import org.elasticsearch.cluster.service.ClusterService;
-import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.scheduler.SchedulerEngine;
 import org.elasticsearch.common.settings.ClusterSettings;
 import org.elasticsearch.common.settings.IndexScopedSettings;
@@ -22,30 +20,17 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.settings.SettingsFilter;
 import org.elasticsearch.common.settings.SettingsModule;
 import org.elasticsearch.common.util.concurrent.EsExecutors;
-import org.elasticsearch.env.Environment;
-import org.elasticsearch.env.NodeEnvironment;
-import org.elasticsearch.indices.IndicesService;
-import org.elasticsearch.persistent.PersistentTaskParams;
-import org.elasticsearch.persistent.PersistentTaskState;
 import org.elasticsearch.persistent.PersistentTasksExecutor;
 import org.elasticsearch.plugins.ActionPlugin;
 import org.elasticsearch.plugins.PersistentTaskPlugin;
 import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.repositories.RepositoriesService;
 import org.elasticsearch.rest.RestController;
 import org.elasticsearch.rest.RestHandler;
-import org.elasticsearch.script.ScriptService;
 import org.elasticsearch.threadpool.ExecutorBuilder;
 import org.elasticsearch.threadpool.FixedExecutorBuilder;
 import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.tracing.Tracer;
-import org.elasticsearch.watcher.ResourceWatcherService;
-import org.elasticsearch.xcontent.NamedXContentRegistry;
-import org.elasticsearch.xcontent.ParseField;
 import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction;
 import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
-import org.elasticsearch.xpack.core.downsample.DownsampleAction;
-import org.elasticsearch.xpack.core.downsample.DownsampleIndexerAction;
 import org.elasticsearch.xpack.core.rollup.RollupField;
 import org.elasticsearch.xpack.core.rollup.action.DeleteRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
@@ -53,15 +38,8 @@ import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction;
 import org.elasticsearch.xpack.core.rollup.action.GetRollupJobsAction;
 import org.elasticsearch.xpack.core.rollup.action.PutRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.RollupSearchAction;
-import org.elasticsearch.xpack.core.rollup.action.RollupShardPersistentTaskState;
-import org.elasticsearch.xpack.core.rollup.action.RollupShardTask;
 import org.elasticsearch.xpack.core.rollup.action.StartRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction;
-import org.elasticsearch.xpack.downsample.DownsampleShardTaskParams;
-import org.elasticsearch.xpack.downsample.RestDownsampleAction;
-import org.elasticsearch.xpack.downsample.RollupShardPersistentTaskExecutor;
-import org.elasticsearch.xpack.downsample.TransportDownsampleAction;
-import org.elasticsearch.xpack.downsample.TransportDownsampleIndexerAction;
 import org.elasticsearch.xpack.rollup.action.TransportDeleteRollupJobAction;
 import org.elasticsearch.xpack.rollup.action.TransportGetRollupCapsAction;
 import org.elasticsearch.xpack.rollup.action.TransportGetRollupIndexCapsAction;
@@ -82,7 +60,6 @@ import org.elasticsearch.xpack.rollup.rest.RestStopRollupJobAction;
 
 import java.time.Clock;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.function.Supplier;
 
@@ -96,14 +73,11 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
     public static final int CURRENT_ROLLUP_VERSION = ROLLUP_VERSION_V2;
 
     public static final String TASK_THREAD_POOL_NAME = RollupField.NAME + "_indexing";
-    public static final String DOWSAMPLE_TASK_THREAD_POOL_NAME = "downsample_indexing";
-    public static final int DOWNSAMPLE_TASK_THREAD_POOL_QUEUE_SIZE = 256;
 
     public static final String ROLLUP_TEMPLATE_VERSION_FIELD = "rollup-version";
 
     private final SetOnce<SchedulerEngine> schedulerEngine = new SetOnce<>();
     private final Settings settings;
-    private IndicesService indicesService;
 
     public Rollup(Settings settings) {
         this.settings = settings;
@@ -127,8 +101,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
             new RestDeleteRollupJobAction(),
             new RestGetRollupJobsAction(),
             new RestGetRollupCapsAction(),
-            new RestGetRollupIndexCapsAction(),
-            new RestDownsampleAction() // TSDB Downsampling
+            new RestGetRollupIndexCapsAction()
         );
     }
 
@@ -144,9 +117,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
             new ActionHandler<>(GetRollupCapsAction.INSTANCE, TransportGetRollupCapsAction.class),
             new ActionHandler<>(GetRollupIndexCapsAction.INSTANCE, TransportGetRollupIndexCapsAction.class),
             new ActionHandler<>(XPackUsageFeatureAction.ROLLUP, RollupUsageTransportAction.class),
-            new ActionHandler<>(XPackInfoFeatureAction.ROLLUP, RollupInfoTransportAction.class),
-            new ActionHandler<>(DownsampleIndexerAction.INSTANCE, TransportDownsampleIndexerAction.class),
-            new ActionHandler<>(DownsampleAction.INSTANCE, TransportDownsampleAction.class)
+            new ActionHandler<>(XPackInfoFeatureAction.ROLLUP, RollupInfoTransportAction.class)
         );
     }
 
@@ -160,17 +131,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
             "xpack.rollup.task_thread_pool",
             EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
         );
-
-        final FixedExecutorBuilder downsample = new FixedExecutorBuilder(
-            settingsToUse,
-            Rollup.DOWSAMPLE_TASK_THREAD_POOL_NAME,
-            ThreadPool.oneEighthAllocatedProcessors(EsExecutors.allocatedProcessors(settingsToUse)),
-            Rollup.DOWNSAMPLE_TASK_THREAD_POOL_QUEUE_SIZE,
-            "xpack.downsample.thread_pool",
-            EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
-        );
-
-        return List.of(rollup, downsample);
+        return List.of(rollup);
     }
 
     @Override
@@ -182,15 +143,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
         IndexNameExpressionResolver expressionResolver
     ) {
         schedulerEngine.set(new SchedulerEngine(settings, getClock()));
-        return List.of(
-            new RollupJobTask.RollupJobPersistentTasksExecutor(client, schedulerEngine.get(), threadPool),
-            new RollupShardPersistentTaskExecutor(
-                client,
-                this.indicesService,
-                RollupShardTask.TASK_NAME,
-                Rollup.DOWSAMPLE_TASK_THREAD_POOL_NAME
-            )
-        );
+        return List.of(new RollupJobTask.RollupJobPersistentTasksExecutor(client, schedulerEngine.get(), threadPool));
     }
 
     // overridable by tests
@@ -204,74 +157,4 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
             schedulerEngine.get().stop();
         }
     }
-
-    @Override
-    public List<NamedXContentRegistry.Entry> getNamedXContent() {
-        return List.of(
-            new NamedXContentRegistry.Entry(
-                PersistentTaskState.class,
-                new ParseField(RollupShardPersistentTaskState.NAME),
-                RollupShardPersistentTaskState::fromXContent
-            ),
-            new NamedXContentRegistry.Entry(
-                PersistentTaskParams.class,
-                new ParseField(DownsampleShardTaskParams.NAME),
-                DownsampleShardTaskParams::fromXContent
-            )
-        );
-    }
-
-    @Override
-    public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
-        return List.of(
-            new NamedWriteableRegistry.Entry(
-                PersistentTaskState.class,
-                RollupShardPersistentTaskState.NAME,
-                RollupShardPersistentTaskState::readFromStream
-            ),
-            new NamedWriteableRegistry.Entry(
-                PersistentTaskParams.class,
-                DownsampleShardTaskParams.NAME,
-                DownsampleShardTaskParams::readFromStream
-            )
-        );
-    }
-
-    @Override
-    public Collection<Object> createComponents(
-        final Client client,
-        final ClusterService clusterService,
-        final ThreadPool threadPool,
-        final ResourceWatcherService resourceWatcherService,
-        final ScriptService scriptService,
-        final NamedXContentRegistry xContentRegistry,
-        final Environment environment,
-        final NodeEnvironment nodeEnvironment,
-        final NamedWriteableRegistry namedWriteableRegistry,
-        final IndexNameExpressionResolver indexNameExpressionResolver,
-        final Supplier<RepositoriesService> repositoriesServiceSupplier,
-        final Tracer tracer,
-        final AllocationService allocationService,
-        final IndicesService indicesService
-    ) {
-        final Collection<Object> components = super.createComponents(
-            client,
-            clusterService,
-            threadPool,
-            resourceWatcherService,
-            scriptService,
-            xContentRegistry,
-            environment,
-            nodeEnvironment,
-            namedWriteableRegistry,
-            indexNameExpressionResolver,
-            repositoriesServiceSupplier,
-            tracer,
-            allocationService,
-            indicesService
-        );
-
-        this.indicesService = indicesService;
-        return components;
-    }
 }