Ver código fonte

[TSDB] Rename rollup public API to downsample (#89809)

This PR renames all public APIs for downsampling so that they contain the downsample 
keyword instead of the rollup that we had until now.

1. The API endpoint for the downsampling action is renamed to:

/source-index/_downsample/target-index

2. The ILM action is renamed to

PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "actions": {
          "downsample": {
  	    "fixed_interval": "24h"
  	  }
  	}
      }
    }
  }
}

3.  unsupported_aggregation_on_rollup_index was renamed to unsupported_aggregation_on_downsampled_index

4. Internal trasport actions were renamed:

    indices:admin/xpack/rollup -> indices:admin/xpack/downsample
    indices:admin/xpack/rollup_indexer -> indices:admin/xpack/downsample_indexer

5. Renamed the following index settings:

    index.rollup.source.uuid -> index.downsample.source.uuid
    index.rollup.source.name -> index.downsample.source.name
    index.rollup.status -> index.downsample.status

Finally, we renamed many internal variables and classes from *Rollup* to *Downsample*. 
However, this effort will be completed in more than one PRs so that we minimize conflicts with other in-flight PRs.

Relates to #74660
Christos Soulios 3 anos atrás
pai
commit
f8d1d2afa6
47 arquivos alterados com 365 adições e 343 exclusões
  1. 7 7
      rest-api-spec/src/main/resources/rest-api-spec/api/indices.downsample.json
  2. 4 4
      server/src/main/java/org/elasticsearch/ElasticsearchException.java
  3. 19 19
      server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java
  4. 3 3
      server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
  5. 3 3
      server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnDownsampledIndex.java
  6. 2 2
      server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java
  7. 2 2
      server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
  8. 1 0
      x-pack/plugin/core/src/main/java/module-info.java
  9. 4 5
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
  10. 29 30
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleAction.java
  11. 14 15
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleConfig.java
  12. 19 12
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupIndexerAction.java
  13. 4 5
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupTask.java
  14. 23 23
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java
  15. 12 8
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupStep.java
  16. 5 5
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java
  17. 18 18
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DownsampleActionTests.java
  18. 2 2
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyMetadataTests.java
  19. 3 3
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyTests.java
  20. 13 9
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupStepTests.java
  21. 8 8
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleTypeTests.java
  22. 3 3
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/action/PutLifecycleRequestTests.java
  23. 11 10
      x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/DownsampleActionConfigTests.java
  24. 17 16
      x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java
  25. 1 1
      x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java
  26. 2 2
      x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java
  27. 3 3
      x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java
  28. 2 2
      x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/ReservedLifecycleStateServiceTests.java
  29. 2 2
      x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/aggregations/support/AggregateMetricsValuesSourceType.java
  30. 2 2
      x-pack/plugin/rollup/qa/rest/build.gradle
  31. 17 15
      x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/10_basic.yml
  32. 16 16
      x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/20_unsupported_aggs.yml
  33. 3 3
      x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/30_date_histogram.yml
  34. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AbstractRollupFieldProducer.java
  35. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java
  36. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/LabelFieldProducer.java
  37. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/MetricFieldProducer.java
  38. 10 10
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RestDownsampleAction.java
  39. 5 5
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java
  40. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TimeseriesFieldTypeHelper.java
  41. 27 23
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupAction.java
  42. 2 2
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupIndexerAction.java
  43. 7 7
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java
  44. 31 29
      x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
  45. 1 1
      x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/LabelFieldProducerTests.java
  46. 1 1
      x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/MetricFieldProducerTests.java
  47. 2 2
      x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java

+ 7 - 7
rest-api-spec/src/main/resources/rest-api-spec/api/rollup.rollup.json → rest-api-spec/src/main/resources/rest-api-spec/api/indices.downsample.json

@@ -1,8 +1,8 @@
 {
-  "rollup.rollup":{
+  "indices.downsample":{
     "documentation":{
       "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-rollup.html",
-      "description":"Rollup an index"
+      "description":"Downsample an index"
     },
     "stability":"experimental",
     "visibility":"public",
@@ -13,19 +13,19 @@
     "url": {
       "paths": [
         {
-          "path": "/{index}/_rollup/{rollup_index}",
+          "path": "/{index}/_downsample/{target_index}",
           "methods": [
             "POST"
           ],
           "parts": {
             "index": {
               "type": "string",
-              "description": "The index to roll up",
+              "description": "The index to downsample",
               "required": true
             },
-            "rollup_index": {
+            "target_index": {
               "type": "string",
-              "description": "The name of the rollup index to create",
+              "description": "The name of the target index to store downsampled data",
               "required": true
             }
           }
@@ -34,7 +34,7 @@
     },
     "params":{},
     "body":{
-      "description":"The rollup configuration",
+      "description":"The downsampling configuration",
       "required":true
     }
   }

+ 4 - 4
server/src/main/java/org/elasticsearch/ElasticsearchException.java

@@ -23,7 +23,7 @@ import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.search.SearchException;
 import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
-import org.elasticsearch.search.aggregations.UnsupportedAggregationOnRollupIndex;
+import org.elasticsearch.search.aggregations.UnsupportedAggregationOnDownsampledIndex;
 import org.elasticsearch.transport.TcpTransport;
 import org.elasticsearch.xcontent.ParseField;
 import org.elasticsearch.xcontent.ToXContentFragment;
@@ -1580,9 +1580,9 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
             166,
             Version.V_8_5_0
         ),
-        UNSUPPORTED_AGGREGATION_ON_DOWNSAMPLED_FIELD_EXCEPTION(
-            UnsupportedAggregationOnRollupIndex.class,
-            UnsupportedAggregationOnRollupIndex::new,
+        UNSUPPORTED_AGGREGATION_ON_DOWNSAMPLED_INDEX_EXCEPTION(
+            UnsupportedAggregationOnDownsampledIndex.class,
+            UnsupportedAggregationOnDownsampledIndex::new,
             167,
             Version.V_8_5_0
         );

+ 19 - 19
server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java

@@ -128,14 +128,14 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
         EnumSet.of(ClusterBlockLevel.WRITE)
     );
 
-    // TODO: refactor this method after adding more rollup metadata
-    public boolean isRollupIndex() {
-        final String sourceIndex = settings.get(IndexMetadata.INDEX_ROLLUP_SOURCE_NAME_KEY);
-        final String indexRollupStatus = settings.get(IndexMetadata.INDEX_ROLLUP_STATUS_KEY);
-        final boolean rollupSuccess = IndexMetadata.RollupTaskStatus.SUCCESS.name()
+    // TODO: refactor this method after adding more downsampling metadata
+    public boolean isDownsampledIndex() {
+        final String sourceIndex = settings.get(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME_KEY);
+        final String indexDownsamplingStatus = settings.get(IndexMetadata.INDEX_DOWNSAMPLE_STATUS_KEY);
+        final boolean downsamplingSuccess = DownsampleTaskStatus.SUCCESS.name()
             .toLowerCase(Locale.ROOT)
-            .equals(indexRollupStatus != null ? indexRollupStatus.toLowerCase(Locale.ROOT) : IndexMetadata.RollupTaskStatus.UNKNOWN);
-        return Strings.isNullOrEmpty(sourceIndex) == false && rollupSuccess;
+            .equals(indexDownsamplingStatus != null ? indexDownsamplingStatus.toLowerCase(Locale.ROOT) : DownsampleTaskStatus.UNKNOWN);
+        return Strings.isNullOrEmpty(sourceIndex) == false && downsamplingSuccess;
     }
 
     public enum State implements Writeable {
@@ -1132,22 +1132,22 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
             : null;
     }
 
-    public static final String INDEX_ROLLUP_SOURCE_UUID_KEY = "index.rollup.source.uuid";
-    public static final String INDEX_ROLLUP_SOURCE_NAME_KEY = "index.rollup.source.name";
+    public static final String INDEX_DOWNSAMPLE_SOURCE_UUID_KEY = "index.downsample.source.uuid";
+    public static final String INDEX_DOWNSAMPLE_SOURCE_NAME_KEY = "index.downsample.source.name";
 
-    public static final String INDEX_ROLLUP_STATUS_KEY = "index.rollup.status";
-    public static final Setting<String> INDEX_ROLLUP_SOURCE_UUID = Setting.simpleString(
-        INDEX_ROLLUP_SOURCE_UUID_KEY,
+    public static final String INDEX_DOWNSAMPLE_STATUS_KEY = "index.downsample.status";
+    public static final Setting<String> INDEX_DOWNSAMPLE_SOURCE_UUID = Setting.simpleString(
+        INDEX_DOWNSAMPLE_SOURCE_UUID_KEY,
         Property.IndexScope,
         Property.PrivateIndex
     );
-    public static final Setting<String> INDEX_ROLLUP_SOURCE_NAME = Setting.simpleString(
-        INDEX_ROLLUP_SOURCE_NAME_KEY,
+    public static final Setting<String> INDEX_DOWNSAMPLE_SOURCE_NAME = Setting.simpleString(
+        INDEX_DOWNSAMPLE_SOURCE_NAME_KEY,
         Property.IndexScope,
         Property.PrivateIndex
     );
 
-    public enum RollupTaskStatus {
+    public enum DownsampleTaskStatus {
         UNKNOWN,
         STARTED,
         SUCCESS;
@@ -1158,10 +1158,10 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
         }
     }
 
-    public static final Setting<RollupTaskStatus> INDEX_ROLLUP_STATUS = Setting.enumSetting(
-        RollupTaskStatus.class,
-        INDEX_ROLLUP_STATUS_KEY,
-        RollupTaskStatus.UNKNOWN,
+    public static final Setting<DownsampleTaskStatus> INDEX_DOWNSAMPLE_STATUS = Setting.enumSetting(
+        DownsampleTaskStatus.class,
+        INDEX_DOWNSAMPLE_STATUS_KEY,
+        DownsampleTaskStatus.UNKNOWN,
         Property.IndexScope,
         Property.InternalIndex
     );

+ 3 - 3
server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java

@@ -71,9 +71,9 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
         IndexMetadata.INDEX_DATA_PATH_SETTING,
         IndexMetadata.INDEX_HIDDEN_SETTING,
         IndexMetadata.INDEX_FORMAT_SETTING,
-        IndexMetadata.INDEX_ROLLUP_SOURCE_NAME,
-        IndexMetadata.INDEX_ROLLUP_SOURCE_UUID,
-        IndexMetadata.INDEX_ROLLUP_STATUS,
+        IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME,
+        IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID,
+        IndexMetadata.INDEX_DOWNSAMPLE_STATUS,
         SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_DEBUG_SETTING,
         SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_WARN_SETTING,
         SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_INFO_SETTING,

+ 3 - 3
server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnRollupIndex.java → server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnDownsampledIndex.java

@@ -20,13 +20,13 @@ import java.io.IOException;
  * Downsampling uses specific types while aggregating some fields (like 'aggregate_metric_double').
  * Such field types do not support some aggregations.
  */
-public class UnsupportedAggregationOnRollupIndex extends AggregationExecutionException {
+public class UnsupportedAggregationOnDownsampledIndex extends AggregationExecutionException {
 
-    public UnsupportedAggregationOnRollupIndex(final String msg) {
+    public UnsupportedAggregationOnDownsampledIndex(final String msg) {
         super(msg);
     }
 
-    public UnsupportedAggregationOnRollupIndex(final StreamInput in) throws IOException {
+    public UnsupportedAggregationOnDownsampledIndex(final StreamInput in) throws IOException {
         super(in);
     }
 

+ 2 - 2
server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java

@@ -419,7 +419,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
     ) throws IOException {
         final DateIntervalWrapper.IntervalTypeEnum dateHistogramIntervalType = dateHistogramInterval.getIntervalType();
 
-        if (context.getIndexSettings().getIndexMetadata().isRollupIndex()
+        if (context.getIndexSettings().getIndexMetadata().isDownsampledIndex()
             && DateIntervalWrapper.IntervalTypeEnum.CALENDAR.equals(dateHistogramIntervalType)) {
             throw new IllegalArgumentException(
                 config.getDescription()
@@ -432,7 +432,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
         }
 
         final ZoneId tz = timeZone();
-        if (context.getIndexSettings().getIndexMetadata().isRollupIndex() && tz != null && ZoneId.of("UTC").equals(tz) == false) {
+        if (context.getIndexSettings().getIndexMetadata().isDownsampledIndex() && tz != null && ZoneId.of("UTC").equals(tz) == false) {
             throw new IllegalArgumentException(
                 config.getDescription() + " is not supported for aggregation [" + getName() + "] with timezone [" + tz + "]"
             );

+ 2 - 2
server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java

@@ -73,7 +73,7 @@ import org.elasticsearch.search.SearchException;
 import org.elasticsearch.search.SearchParseException;
 import org.elasticsearch.search.SearchShardTarget;
 import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
-import org.elasticsearch.search.aggregations.UnsupportedAggregationOnRollupIndex;
+import org.elasticsearch.search.aggregations.UnsupportedAggregationOnDownsampledIndex;
 import org.elasticsearch.search.internal.ShardSearchContextId;
 import org.elasticsearch.snapshots.Snapshot;
 import org.elasticsearch.snapshots.SnapshotException;
@@ -832,7 +832,7 @@ public class ExceptionSerializationTests extends ESTestCase {
         ids.put(164, VersionConflictException.class);
         ids.put(165, SnapshotNameAlreadyInUseException.class);
         ids.put(166, HealthNodeNotDiscoveredException.class);
-        ids.put(167, UnsupportedAggregationOnRollupIndex.class);
+        ids.put(167, UnsupportedAggregationOnDownsampledIndex.class);
 
         Map<Class<? extends ElasticsearchException>, Integer> reverse = new HashMap<>();
         for (Map.Entry<Integer, Class<? extends ElasticsearchException>> entry : ids.entrySet()) {

+ 1 - 0
x-pack/plugin/core/src/main/java/module-info.java

@@ -53,6 +53,7 @@ module org.elasticsearch.xcore {
     exports org.elasticsearch.xpack.core.common;
     exports org.elasticsearch.xpack.core.datastreams;
     exports org.elasticsearch.xpack.core.deprecation;
+    exports org.elasticsearch.xpack.core.downsample;
     exports org.elasticsearch.xpack.core.enrich.action;
     exports org.elasticsearch.xpack.core.enrich;
     exports org.elasticsearch.xpack.core.eql;

+ 4 - 5
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

@@ -40,6 +40,7 @@ import org.elasticsearch.xpack.core.archive.ArchiveFeatureSetUsage;
 import org.elasticsearch.xpack.core.async.DeleteAsyncResultAction;
 import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
 import org.elasticsearch.xpack.core.datastreams.DataStreamFeatureSetUsage;
+import org.elasticsearch.xpack.core.downsample.RollupIndexerAction;
 import org.elasticsearch.xpack.core.enrich.EnrichFeatureSetUsage;
 import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus;
 import org.elasticsearch.xpack.core.eql.EqlFeatureSetUsage;
@@ -49,6 +50,7 @@ import org.elasticsearch.xpack.core.graph.GraphFeatureSetUsage;
 import org.elasticsearch.xpack.core.graph.action.GraphExploreAction;
 import org.elasticsearch.xpack.core.ilm.AllocateAction;
 import org.elasticsearch.xpack.core.ilm.DeleteAction;
+import org.elasticsearch.xpack.core.ilm.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
 import org.elasticsearch.xpack.core.ilm.FreezeAction;
 import org.elasticsearch.xpack.core.ilm.IndexLifecycleFeatureSetUsage;
@@ -58,7 +60,6 @@ import org.elasticsearch.xpack.core.ilm.LifecycleType;
 import org.elasticsearch.xpack.core.ilm.MigrateAction;
 import org.elasticsearch.xpack.core.ilm.ReadOnlyAction;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
-import org.elasticsearch.xpack.core.ilm.RollupILMAction;
 import org.elasticsearch.xpack.core.ilm.SearchableSnapshotAction;
 import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
 import org.elasticsearch.xpack.core.ilm.ShrinkAction;
@@ -150,8 +151,6 @@ import org.elasticsearch.xpack.core.rollup.action.DeleteRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
 import org.elasticsearch.xpack.core.rollup.action.GetRollupJobsAction;
 import org.elasticsearch.xpack.core.rollup.action.PutRollupJobAction;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
-import org.elasticsearch.xpack.core.rollup.action.RollupIndexerAction;
 import org.elasticsearch.xpack.core.rollup.action.RollupSearchAction;
 import org.elasticsearch.xpack.core.rollup.action.StartRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction;
@@ -416,7 +415,7 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
         // TSDB Downsampling / Rollup
         if (IndexSettings.isTimeSeriesModeEnabled()) {
             actions.add(RollupIndexerAction.INSTANCE);
-            actions.add(RollupAction.INSTANCE);
+            actions.add(org.elasticsearch.xpack.core.downsample.DownsampleAction.INSTANCE);
         }
 
         return actions;
@@ -574,7 +573,7 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
 
         // TSDB Downsampling / Rollup
         if (IndexSettings.isTimeSeriesModeEnabled()) {
-            namedWriteables.add(new NamedWriteableRegistry.Entry(LifecycleAction.class, RollupILMAction.NAME, RollupILMAction::new));
+            namedWriteables.add(new NamedWriteableRegistry.Entry(LifecycleAction.class, DownsampleAction.NAME, DownsampleAction::new));
         }
 
         return namedWriteables;

+ 29 - 30
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupAction.java → x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleAction.java

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.core.rollup.action;
+package org.elasticsearch.xpack.core.downsample;
 
 import org.elasticsearch.action.ActionRequestBuilder;
 import org.elasticsearch.action.ActionRequestValidationException;
@@ -20,7 +20,6 @@ import org.elasticsearch.tasks.Task;
 import org.elasticsearch.tasks.TaskId;
 import org.elasticsearch.xcontent.ToXContentObject;
 import org.elasticsearch.xcontent.XContentBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
 
 import java.io.IOException;
 import java.util.Map;
@@ -28,23 +27,23 @@ import java.util.Objects;
 
 import static org.elasticsearch.action.ValidateActions.addValidationError;
 
-public class RollupAction extends ActionType<AcknowledgedResponse> {
-    public static final RollupAction INSTANCE = new RollupAction();
-    public static final String NAME = "indices:admin/xpack/rollup";
+public class DownsampleAction extends ActionType<AcknowledgedResponse> {
+    public static final DownsampleAction INSTANCE = new DownsampleAction();
+    public static final String NAME = "indices:admin/xpack/downsample";
 
-    private RollupAction() {
+    private DownsampleAction() {
         super(NAME, AcknowledgedResponse::readFrom);
     }
 
     public static class Request extends MasterNodeRequest<Request> implements IndicesRequest, ToXContentObject {
         private String sourceIndex;
-        private String rollupIndex;
-        private RollupActionConfig rollupConfig;
+        private String targetIndex;
+        private DownsampleConfig downsampleConfig;
 
-        public Request(String sourceIndex, String rollupIndex, RollupActionConfig rollupConfig) {
+        public Request(String sourceIndex, String targetIndex, DownsampleConfig downsampleConfig) {
             this.sourceIndex = sourceIndex;
-            this.rollupIndex = rollupIndex;
-            this.rollupConfig = rollupConfig;
+            this.targetIndex = targetIndex;
+            this.downsampleConfig = downsampleConfig;
         }
 
         public Request() {}
@@ -52,8 +51,8 @@ public class RollupAction extends ActionType<AcknowledgedResponse> {
         public Request(StreamInput in) throws IOException {
             super(in);
             sourceIndex = in.readString();
-            rollupIndex = in.readString();
-            rollupConfig = new RollupActionConfig(in);
+            targetIndex = in.readString();
+            downsampleConfig = new DownsampleConfig(in);
         }
 
         @Override
@@ -68,27 +67,27 @@ public class RollupAction extends ActionType<AcknowledgedResponse> {
 
         @Override
         public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
-            return new RollupTask(id, type, action, parentTaskId, rollupIndex, rollupConfig, headers);
+            return new RollupTask(id, type, action, parentTaskId, targetIndex, downsampleConfig, headers);
         }
 
         @Override
         public void writeTo(StreamOutput out) throws IOException {
             super.writeTo(out);
             out.writeString(sourceIndex);
-            out.writeString(rollupIndex);
-            rollupConfig.writeTo(out);
+            out.writeString(targetIndex);
+            downsampleConfig.writeTo(out);
         }
 
         public String getSourceIndex() {
             return sourceIndex;
         }
 
-        public String getRollupIndex() {
-            return rollupIndex;
+        public String getTargetIndex() {
+            return targetIndex;
         }
 
-        public RollupActionConfig getRollupConfig() {
-            return rollupConfig;
+        public DownsampleConfig getDownsampleConfig() {
+            return downsampleConfig;
         }
 
         @Override
@@ -97,11 +96,11 @@ public class RollupAction extends ActionType<AcknowledgedResponse> {
             if (sourceIndex == null) {
                 validationException = addValidationError("source index is missing", validationException);
             }
-            if (rollupIndex == null) {
-                validationException = addValidationError("rollup index name is missing", validationException);
+            if (targetIndex == null) {
+                validationException = addValidationError("target index name is missing", validationException);
             }
-            if (rollupConfig == null) {
-                validationException = addValidationError("rollup configuration is missing", validationException);
+            if (downsampleConfig == null) {
+                validationException = addValidationError("downsample configuration is missing", validationException);
             }
             return validationException;
         }
@@ -110,15 +109,15 @@ public class RollupAction extends ActionType<AcknowledgedResponse> {
         public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
             builder.startObject();
             builder.field("source_index", sourceIndex);
-            builder.field("rollup_index", rollupIndex);
-            rollupConfig.toXContent(builder, params);
+            builder.field("target_index", targetIndex);
+            downsampleConfig.toXContent(builder, params);
             builder.endObject();
             return builder;
         }
 
         @Override
         public int hashCode() {
-            return Objects.hash(sourceIndex, rollupIndex, rollupConfig);
+            return Objects.hash(sourceIndex, targetIndex, downsampleConfig);
         }
 
         @Override
@@ -131,14 +130,14 @@ public class RollupAction extends ActionType<AcknowledgedResponse> {
             }
             Request other = (Request) obj;
             return Objects.equals(sourceIndex, other.sourceIndex)
-                && Objects.equals(rollupIndex, other.rollupIndex)
-                && Objects.equals(rollupConfig, other.rollupConfig);
+                && Objects.equals(targetIndex, other.targetIndex)
+                && Objects.equals(downsampleConfig, other.downsampleConfig);
         }
     }
 
     public static class RequestBuilder extends ActionRequestBuilder<Request, AcknowledgedResponse> {
 
-        protected RequestBuilder(ElasticsearchClient client, RollupAction action) {
+        protected RequestBuilder(ElasticsearchClient client, DownsampleAction action) {
             super(client, action, new Request());
         }
     }

+ 14 - 15
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupActionConfig.java → x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleConfig.java

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.core.rollup;
+package org.elasticsearch.xpack.core.downsample;
 
 import org.elasticsearch.common.Rounding;
 import org.elasticsearch.common.Strings;
@@ -21,7 +21,6 @@ import org.elasticsearch.xcontent.ParseField;
 import org.elasticsearch.xcontent.ToXContentObject;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentParser;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
 
 import java.io.IOException;
 import java.time.ZoneId;
@@ -30,7 +29,7 @@ import java.util.Objects;
 import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg;
 
 /**
- * This class holds the configuration details of a {@link RollupAction} that downsamples time series
+ * This class holds the configuration details of a {@link DownsampleAction} that downsamples time series
  * (TSDB) indices. We have made great effort to simplify the rollup configuration and currently
  * only requires a fixed time interval. So, it has the following format:
  *
@@ -45,13 +44,13 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
  * Also, the rollup configuration uses the UTC time zone by default and the "@timestamp" field as
  * the index field that stores the timestamp of the time series index.
  *
- * Finally, we have left methods such as {@link RollupActionConfig#getTimestampField()},
- * {@link RollupActionConfig#getTimeZone()} and  {@link RollupActionConfig#getIntervalType()} for
+ * Finally, we have left methods such as {@link DownsampleConfig#getTimestampField()},
+ * {@link DownsampleConfig#getTimeZone()} and  {@link DownsampleConfig#getIntervalType()} for
  * future extensions.
  */
-public class RollupActionConfig implements NamedWriteable, ToXContentObject {
+public class DownsampleConfig implements NamedWriteable, ToXContentObject {
 
-    private static final String NAME = "rollup/action/config";
+    private static final String NAME = "downsample/action/config";
     public static final String FIXED_INTERVAL = "fixed_interval";
     public static final String TIME_ZONE = "time_zone";
     public static final String DEFAULT_TIMEZONE = ZoneId.of("UTC").getId();
@@ -61,12 +60,12 @@ public class RollupActionConfig implements NamedWriteable, ToXContentObject {
     private final String timeZone = DEFAULT_TIMEZONE;
     private final String intervalType = FIXED_INTERVAL;
 
-    private static final ConstructingObjectParser<RollupActionConfig, Void> PARSER;
+    private static final ConstructingObjectParser<DownsampleConfig, Void> PARSER;
     static {
         PARSER = new ConstructingObjectParser<>(NAME, a -> {
             DateHistogramInterval fixedInterval = (DateHistogramInterval) a[0];
             if (fixedInterval != null) {
-                return new RollupActionConfig(fixedInterval);
+                return new DownsampleConfig(fixedInterval);
             } else {
                 throw new IllegalArgumentException("Parameter [" + FIXED_INTERVAL + "] is required.");
             }
@@ -81,10 +80,10 @@ public class RollupActionConfig implements NamedWriteable, ToXContentObject {
     }
 
     /**
-     * Create a new {@link RollupActionConfig} using the given configuration parameters.
+     * Create a new {@link DownsampleConfig} using the given configuration parameters.
      * @param fixedInterval the fixed interval to use for computing the date histogram for the rolled up documents (required).
      */
-    public RollupActionConfig(final DateHistogramInterval fixedInterval) {
+    public DownsampleConfig(final DateHistogramInterval fixedInterval) {
         if (fixedInterval == null) {
             throw new IllegalArgumentException("Parameter [" + FIXED_INTERVAL + "] is required.");
         }
@@ -94,7 +93,7 @@ public class RollupActionConfig implements NamedWriteable, ToXContentObject {
         createRounding(this.fixedInterval.toString(), this.timeZone);
     }
 
-    public RollupActionConfig(final StreamInput in) throws IOException {
+    public DownsampleConfig(final StreamInput in) throws IOException {
         fixedInterval = new DateHistogramInterval(in);
     }
 
@@ -160,7 +159,7 @@ public class RollupActionConfig implements NamedWriteable, ToXContentObject {
         return builder.endObject();
     }
 
-    public static RollupActionConfig fromXContent(final XContentParser parser) throws IOException {
+    public static DownsampleConfig fromXContent(final XContentParser parser) throws IOException {
         return PARSER.parse(parser, null);
     }
 
@@ -169,10 +168,10 @@ public class RollupActionConfig implements NamedWriteable, ToXContentObject {
         if (this == other) {
             return true;
         }
-        if (other == null || other instanceof RollupActionConfig == false) {
+        if (other == null || other instanceof DownsampleConfig == false) {
             return false;
         }
-        final RollupActionConfig that = (RollupActionConfig) other;
+        final DownsampleConfig that = (DownsampleConfig) other;
         return Objects.equals(fixedInterval, that.fixedInterval)
             && Objects.equals(intervalType, that.intervalType)
             && ZoneId.of(timeZone, ZoneId.SHORT_IDS).getRules().equals(ZoneId.of(that.timeZone, ZoneId.SHORT_IDS).getRules());

+ 19 - 12
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupIndexerAction.java → x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupIndexerAction.java

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.core.rollup.action;
+package org.elasticsearch.xpack.core.downsample;
 
 import org.elasticsearch.action.ActionRequestBuilder;
 import org.elasticsearch.action.ActionRequestValidationException;
@@ -24,7 +24,6 @@ import org.elasticsearch.tasks.Task;
 import org.elasticsearch.tasks.TaskId;
 import org.elasticsearch.xcontent.ToXContentObject;
 import org.elasticsearch.xcontent.XContentBuilder;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -34,20 +33,20 @@ import java.util.Objects;
 public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response> {
 
     public static final RollupIndexerAction INSTANCE = new RollupIndexerAction();
-    public static final String NAME = "indices:admin/xpack/rollup_indexer";
+    public static final String NAME = "indices:admin/xpack/downsample_indexer";
 
     private RollupIndexerAction() {
         super(NAME, RollupIndexerAction.Response::new);
     }
 
     public static class Request extends BroadcastRequest<Request> implements IndicesRequest, ToXContentObject {
-        private RollupAction.Request rollupRequest;
+        private DownsampleAction.Request rollupRequest;
         private String[] dimensionFields;
         private String[] metricFields;
         private String[] labelFields;
 
         public Request(
-            RollupAction.Request rollupRequest,
+            DownsampleAction.Request rollupRequest,
             final String[] dimensionFields,
             final String[] metricFields,
             final String[] labelFields
@@ -63,7 +62,7 @@ public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response
 
         public Request(StreamInput in) throws IOException {
             super(in);
-            this.rollupRequest = new RollupAction.Request(in);
+            this.rollupRequest = new DownsampleAction.Request(in);
             this.dimensionFields = in.readStringArray();
             this.metricFields = in.readStringArray();
             this.labelFields = in.readStringArray();
@@ -79,7 +78,7 @@ public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response
             return rollupRequest.indicesOptions();
         }
 
-        public RollupAction.Request getRollupRequest() {
+        public DownsampleAction.Request getRollupRequest() {
             return rollupRequest;
         }
 
@@ -97,7 +96,15 @@ public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response
 
         @Override
         public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
-            return new RollupTask(id, type, action, parentTaskId, rollupRequest.getRollupIndex(), rollupRequest.getRollupConfig(), headers);
+            return new RollupTask(
+                id,
+                type,
+                action,
+                parentTaskId,
+                rollupRequest.getTargetIndex(),
+                rollupRequest.getDownsampleConfig(),
+                headers
+            );
         }
 
         @Override
@@ -117,7 +124,7 @@ public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response
         @Override
         public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
             builder.startObject();
-            builder.field("rollup_request", rollupRequest);
+            builder.field("downsample_request", rollupRequest);
             builder.array("dimension_fields", dimensionFields);
             builder.array("metric_fields", metricFields);
             builder.array("label_fields", labelFields);
@@ -227,11 +234,11 @@ public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response
         }
 
         public String getRollupIndex() {
-            return request.getRollupRequest().getRollupIndex();
+            return request.getRollupRequest().getTargetIndex();
         }
 
-        public RollupActionConfig getRollupConfig() {
-            return request.getRollupRequest().getRollupConfig();
+        public DownsampleConfig getRollupConfig() {
+            return request.getRollupRequest().getDownsampleConfig();
         }
 
         public String[] getDimensionFields() {

+ 4 - 5
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupTask.java → x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupTask.java

@@ -4,11 +4,10 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.core.rollup.action;
+package org.elasticsearch.xpack.core.downsample;
 
 import org.elasticsearch.tasks.CancellableTask;
 import org.elasticsearch.tasks.TaskId;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
 import org.elasticsearch.xpack.core.rollup.RollupField;
 import org.elasticsearch.xpack.core.rollup.job.RollupJobStatus;
 
@@ -20,7 +19,7 @@ import java.util.Map;
  */
 public class RollupTask extends CancellableTask {
     private String rollupIndex;
-    private RollupActionConfig config;
+    private DownsampleConfig config;
     private RollupJobStatus status;
 
     RollupTask(
@@ -29,7 +28,7 @@ public class RollupTask extends CancellableTask {
         String action,
         TaskId parentTask,
         String rollupIndex,
-        RollupActionConfig config,
+        DownsampleConfig config,
         Map<String, String> headers
     ) {
         super(id, type, action, RollupField.NAME + "_" + rollupIndex, parentTask, headers);
@@ -41,7 +40,7 @@ public class RollupTask extends CancellableTask {
         return rollupIndex;
     }
 
-    public RollupActionConfig config() {
+    public DownsampleConfig config() {
         return config;
     }
 

+ 23 - 23
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupILMAction.java → x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java

@@ -19,8 +19,8 @@ import org.elasticsearch.xcontent.ObjectParser;
 import org.elasticsearch.xcontent.ParseField;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentParser;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
 import org.elasticsearch.xpack.core.ilm.Step.StepKey;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
 
 import java.io.IOException;
 import java.util.List;
@@ -29,19 +29,19 @@ import java.util.Objects;
 import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg;
 
 /**
- * A {@link LifecycleAction} which calls {@link org.elasticsearch.xpack.core.rollup.action.RollupAction} on an index
+ * A {@link LifecycleAction} which calls {@link org.elasticsearch.xpack.core.downsample.DownsampleAction} on an index
  */
-public class RollupILMAction implements LifecycleAction {
+public class DownsampleAction implements LifecycleAction {
 
-    public static final String NAME = "rollup";
-    public static final String ROLLUP_INDEX_PREFIX = "rollup-";
+    public static final String NAME = "downsample";
+    public static final String DOWNSAMPLED_INDEX_PREFIX = "downsample-";
     public static final String CONDITIONAL_DATASTREAM_CHECK_KEY = BranchingStep.NAME + "-on-datastream-check";
-    public static final String GENERATE_ROLLUP_STEP_NAME = "generate-rollup-name";
-    private static final ParseField FIXED_INTERVAL_FIELD = new ParseField(RollupActionConfig.FIXED_INTERVAL);
+    public static final String GENERATE_DOWNSAMPLE_STEP_NAME = "generate-downsampled-index-name";
+    private static final ParseField FIXED_INTERVAL_FIELD = new ParseField(DownsampleConfig.FIXED_INTERVAL);
 
-    private static final ConstructingObjectParser<RollupILMAction, Void> PARSER = new ConstructingObjectParser<>(
+    private static final ConstructingObjectParser<DownsampleAction, Void> PARSER = new ConstructingObjectParser<>(
         NAME,
-        a -> new RollupILMAction((DateHistogramInterval) a[0])
+        a -> new DownsampleAction((DateHistogramInterval) a[0])
     );
 
     static {
@@ -55,18 +55,18 @@ public class RollupILMAction implements LifecycleAction {
 
     private final DateHistogramInterval fixedInterval;
 
-    public static RollupILMAction parse(XContentParser parser) {
+    public static DownsampleAction parse(XContentParser parser) {
         return PARSER.apply(parser, null);
     }
 
-    public RollupILMAction(DateHistogramInterval fixedInterval) {
+    public DownsampleAction(DateHistogramInterval fixedInterval) {
         if (fixedInterval == null) {
             throw new IllegalArgumentException("Parameter [" + FIXED_INTERVAL_FIELD.getPreferredName() + "] is required.");
         }
         this.fixedInterval = fixedInterval;
     }
 
-    public RollupILMAction(StreamInput in) throws IOException {
+    public DownsampleAction(StreamInput in) throws IOException {
         this(new DateHistogramInterval(in));
     }
 
@@ -103,7 +103,7 @@ public class RollupILMAction implements LifecycleAction {
         StepKey waitForNoFollowerStepKey = new StepKey(phase, NAME, WaitForNoFollowersStep.NAME);
         StepKey readOnlyKey = new StepKey(phase, NAME, ReadOnlyStep.NAME);
         StepKey cleanupRollupIndexKey = new StepKey(phase, NAME, CleanupTargetIndexStep.NAME);
-        StepKey generateRollupIndexNameKey = new StepKey(phase, NAME, GENERATE_ROLLUP_STEP_NAME);
+        StepKey generateRollupIndexNameKey = new StepKey(phase, NAME, GENERATE_DOWNSAMPLE_STEP_NAME);
         StepKey rollupKey = new StepKey(phase, NAME, RollupStep.NAME);
         StepKey waitForRollupIndexKey = new StepKey(phase, NAME, WaitForIndexColorStep.NAME);
         StepKey copyMetadataKey = new StepKey(phase, NAME, CopyExecutionStateStep.NAME);
@@ -125,7 +125,7 @@ public class RollupILMAction implements LifecycleAction {
             cleanupRollupIndexKey,
             readOnlyKey,
             client,
-            (indexMetadata) -> IndexMetadata.INDEX_ROLLUP_SOURCE_NAME.get(indexMetadata.getSettings()),
+            (indexMetadata) -> IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME.get(indexMetadata.getSettings()),
             (indexMetadata) -> indexMetadata.getLifecycleExecutionState().rollupIndexName()
         );
         // Mark source index as read-only
@@ -135,17 +135,17 @@ public class RollupILMAction implements LifecycleAction {
         GenerateUniqueIndexNameStep generateRollupIndexNameStep = new GenerateUniqueIndexNameStep(
             generateRollupIndexNameKey,
             rollupKey,
-            ROLLUP_INDEX_PREFIX,
+            DOWNSAMPLED_INDEX_PREFIX,
             (rollupIndexName, lifecycleStateBuilder) -> lifecycleStateBuilder.setRollupIndexName(rollupIndexName)
         );
 
         // Here is where the actual rollup action takes place
         RollupStep rollupStep = new RollupStep(rollupKey, waitForRollupIndexKey, client, fixedInterval);
 
-        // Wait until the rollup index is recovered. We again wait until the configured threshold is breached and
-        // if the rollup index has not successfully recovered until then, we rewind to the "cleanup-rollup-index"
-        // step to delete this unsuccessful rollup index and retry the operation by generating a new rollup index
-        // name and attempting to rollup again
+        // Wait until the downsampled index is recovered. We again wait until the configured threshold is breached and
+        // if the downsampled index has not successfully recovered until then, we rewind to the "cleanup-rollup-index"
+        // step to delete this unsuccessful downsampled index and retry the operation by generating a new downsampled index
+        // name and attempting to downsample again.
         ClusterStateWaitUntilThresholdStep rollupAllocatedStep = new ClusterStateWaitUntilThresholdStep(
             new WaitForIndexColorStep(
                 waitForRollupIndexKey,
@@ -163,9 +163,9 @@ public class RollupILMAction implements LifecycleAction {
             nextStepKey
         );
 
-        // By the time we get to this step we have 2 indices, the source and the rollup one. We now need to choose an index
-        // swapping strategy such that the rollup index takes the place of the source index (which will also be deleted).
-        // If the source index is part of a data stream it's a matter of replacing it with the rollup index one in the data stream and
+        // By the time we get to this step we have 2 indices, the source and the downsampled one. We now need to choose an index
+        // swapping strategy such that the downsampled index takes the place of the source index (which will also be deleted).
+        // If the source index is part of a data stream it's a matter of replacing it with the downsampled index one in the data stream and
         // then deleting the source index.
         BranchingStep isDataStreamBranchingStep = new BranchingStep(
             dataStreamCheckBranchingKey,
@@ -214,7 +214,7 @@ public class RollupILMAction implements LifecycleAction {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 
-        RollupILMAction that = (RollupILMAction) o;
+        DownsampleAction that = (DownsampleAction) o;
         return Objects.equals(this.fixedInterval, that.fixedInterval);
     }
 

+ 12 - 8
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupStep.java

@@ -18,8 +18,8 @@ import org.elasticsearch.cluster.metadata.LifecycleExecutionState;
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
 
 import java.util.Objects;
 
@@ -72,10 +72,12 @@ public class RollupStep extends AsyncActionStep {
 
         IndexMetadata rollupIndexMetadata = currentState.metadata().index(rollupIndexName);
         if (rollupIndexMetadata != null) {
-            IndexMetadata.RollupTaskStatus rollupIndexStatus = IndexMetadata.INDEX_ROLLUP_STATUS.get(rollupIndexMetadata.getSettings());
+            IndexMetadata.DownsampleTaskStatus rollupIndexStatus = IndexMetadata.INDEX_DOWNSAMPLE_STATUS.get(
+                rollupIndexMetadata.getSettings()
+            );
             // Rollup index has already been created with the generated name and its status is "success".
             // So we skip index rollup creation.
-            if (IndexMetadata.RollupTaskStatus.SUCCESS.equals(rollupIndexStatus)) {
+            if (IndexMetadata.DownsampleTaskStatus.SUCCESS.equals(rollupIndexStatus)) {
                 logger.warn(
                     "skipping [{}] step for index [{}] as part of policy [{}] as the rollup index [{}] already exists",
                     RollupStep.NAME,
@@ -124,11 +126,13 @@ public class RollupStep extends AsyncActionStep {
     }
 
     private void performRollupIndex(String indexName, String rollupIndexName, ActionListener<Void> listener) {
-        RollupActionConfig config = new RollupActionConfig(fixedInterval);
-        RollupAction.Request request = new RollupAction.Request(indexName, rollupIndexName, config).masterNodeTimeout(TimeValue.MAX_VALUE);
-        // Currently, RollupAction always acknowledges action was complete when no exceptions are thrown.
+        DownsampleConfig config = new DownsampleConfig(fixedInterval);
+        DownsampleAction.Request request = new DownsampleAction.Request(indexName, rollupIndexName, config).masterNodeTimeout(
+            TimeValue.MAX_VALUE
+        );
+        // Currently, DownsampleAction always acknowledges action was complete when no exceptions are thrown.
         getClient().execute(
-            RollupAction.INSTANCE,
+            DownsampleAction.INSTANCE,
             request,
             ActionListener.wrap(response -> listener.onResponse(null), listener::onFailure)
         );

+ 5 - 5
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java

@@ -56,7 +56,7 @@ public class TimeseriesLifecycleType implements LifecycleType {
         UnfollowAction.NAME,
         RolloverAction.NAME,
         ReadOnlyAction.NAME,
-        IndexSettings.isTimeSeriesModeEnabled() ? RollupILMAction.NAME : null,
+        IndexSettings.isTimeSeriesModeEnabled() ? DownsampleAction.NAME : null,
         ShrinkAction.NAME,
         ForceMergeAction.NAME,
         SearchableSnapshotAction.NAME
@@ -65,7 +65,7 @@ public class TimeseriesLifecycleType implements LifecycleType {
         SetPriorityAction.NAME,
         UnfollowAction.NAME,
         ReadOnlyAction.NAME,
-        IndexSettings.isTimeSeriesModeEnabled() ? RollupILMAction.NAME : null,
+        IndexSettings.isTimeSeriesModeEnabled() ? DownsampleAction.NAME : null,
         AllocateAction.NAME,
         MigrateAction.NAME,
         ShrinkAction.NAME,
@@ -75,7 +75,7 @@ public class TimeseriesLifecycleType implements LifecycleType {
         SetPriorityAction.NAME,
         UnfollowAction.NAME,
         ReadOnlyAction.NAME,
-        IndexSettings.isTimeSeriesModeEnabled() ? RollupILMAction.NAME : null,
+        IndexSettings.isTimeSeriesModeEnabled() ? DownsampleAction.NAME : null,
         SearchableSnapshotAction.NAME,
         AllocateAction.NAME,
         MigrateAction.NAME,
@@ -107,13 +107,13 @@ public class TimeseriesLifecycleType implements LifecycleType {
         ReadOnlyAction.NAME,
         ShrinkAction.NAME,
         ForceMergeAction.NAME,
-        RollupILMAction.NAME,
+        DownsampleAction.NAME,
         SearchableSnapshotAction.NAME
     );
     // Set of actions that cannot be defined (executed) after the managed index has been mounted as searchable snapshot.
     // It's ordered to produce consistent error messages which can be unit tested.
     public static final Set<String> ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT = Collections.unmodifiableSet(
-        new LinkedHashSet<>(Arrays.asList(ForceMergeAction.NAME, FreezeAction.NAME, ShrinkAction.NAME, RollupILMAction.NAME))
+        new LinkedHashSet<>(Arrays.asList(ForceMergeAction.NAME, FreezeAction.NAME, ShrinkAction.NAME, DownsampleAction.NAME))
     );
 
     private TimeseriesLifecycleType() {}

+ 18 - 18
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupILMActionTests.java → x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DownsampleActionTests.java

@@ -15,29 +15,29 @@ import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
 
 import java.util.List;
 
-import static org.elasticsearch.xpack.core.ilm.RollupILMAction.CONDITIONAL_DATASTREAM_CHECK_KEY;
-import static org.elasticsearch.xpack.core.ilm.RollupILMAction.GENERATE_ROLLUP_STEP_NAME;
+import static org.elasticsearch.xpack.core.ilm.DownsampleAction.CONDITIONAL_DATASTREAM_CHECK_KEY;
+import static org.elasticsearch.xpack.core.ilm.DownsampleAction.GENERATE_DOWNSAMPLE_STEP_NAME;
 import static org.hamcrest.Matchers.equalTo;
 
-public class RollupILMActionTests extends AbstractActionTestCase<RollupILMAction> {
+public class DownsampleActionTests extends AbstractActionTestCase<DownsampleAction> {
 
-    static RollupILMAction randomInstance() {
-        return new RollupILMAction(ConfigTestHelpers.randomInterval());
+    static DownsampleAction randomInstance() {
+        return new DownsampleAction(ConfigTestHelpers.randomInterval());
     }
 
     @Override
-    protected RollupILMAction doParseInstance(XContentParser parser) {
-        return RollupILMAction.parse(parser);
+    protected DownsampleAction doParseInstance(XContentParser parser) {
+        return DownsampleAction.parse(parser);
     }
 
     @Override
-    protected RollupILMAction createTestInstance() {
+    protected DownsampleAction createTestInstance() {
         return randomInstance();
     }
 
     @Override
-    protected Reader<RollupILMAction> instanceReader() {
-        return RollupILMAction::new;
+    protected Reader<DownsampleAction> instanceReader() {
+        return DownsampleAction::new;
     }
 
     @Override
@@ -47,7 +47,7 @@ public class RollupILMActionTests extends AbstractActionTestCase<RollupILMAction
 
     @Override
     public void testToSteps() {
-        RollupILMAction action = new RollupILMAction(ConfigTestHelpers.randomInterval());
+        DownsampleAction action = new DownsampleAction(ConfigTestHelpers.randomInterval());
         String phase = randomAlphaOfLengthBetween(1, 10);
         StepKey nextStepKey = new StepKey(
             randomAlphaOfLengthBetween(1, 10),
@@ -72,10 +72,10 @@ public class RollupILMActionTests extends AbstractActionTestCase<RollupILMAction
 
         assertTrue(steps.get(3) instanceof ReadOnlyStep);
         assertThat(steps.get(3).getKey().getName(), equalTo(ReadOnlyStep.NAME));
-        assertThat(steps.get(3).getNextStepKey().getName(), equalTo(GENERATE_ROLLUP_STEP_NAME));
+        assertThat(steps.get(3).getNextStepKey().getName(), equalTo(GENERATE_DOWNSAMPLE_STEP_NAME));
 
         assertTrue(steps.get(4) instanceof GenerateUniqueIndexNameStep);
-        assertThat(steps.get(4).getKey().getName(), equalTo(GENERATE_ROLLUP_STEP_NAME));
+        assertThat(steps.get(4).getKey().getName(), equalTo(GENERATE_DOWNSAMPLE_STEP_NAME));
         assertThat(steps.get(4).getNextStepKey().getName(), equalTo(RollupStep.NAME));
 
         assertTrue(steps.get(5) instanceof RollupStep);
@@ -113,12 +113,12 @@ public class RollupILMActionTests extends AbstractActionTestCase<RollupILMAction
         EqualsHashCodeTestUtils.checkEqualsAndHashCode(createTestInstance(), this::copy, this::notCopy);
     }
 
-    RollupILMAction copy(RollupILMAction rollupILMAction) {
-        return new RollupILMAction(rollupILMAction.fixedInterval());
+    DownsampleAction copy(DownsampleAction downsampleAction) {
+        return new DownsampleAction(downsampleAction.fixedInterval());
     }
 
-    RollupILMAction notCopy(RollupILMAction rollupILMAction) {
-        DateHistogramInterval fixedInterval = randomValueOtherThan(rollupILMAction.fixedInterval(), ConfigTestHelpers::randomInterval);
-        return new RollupILMAction(fixedInterval);
+    DownsampleAction notCopy(DownsampleAction downsampleAction) {
+        DateHistogramInterval fixedInterval = randomValueOtherThan(downsampleAction.fixedInterval(), ConfigTestHelpers::randomInterval);
+        return new DownsampleAction(fixedInterval);
     }
 }

+ 2 - 2
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyMetadataTests.java

@@ -56,7 +56,7 @@ public class LifecyclePolicyMetadataTests extends AbstractSerializingTestCase<Li
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, SetPriorityAction.NAME, SetPriorityAction::new),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, MigrateAction.NAME, MigrateAction::readFrom),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, UnfollowAction.NAME, in -> UnfollowAction.INSTANCE),
-                new NamedWriteableRegistry.Entry(LifecycleAction.class, RollupILMAction.NAME, RollupILMAction::new)
+                new NamedWriteableRegistry.Entry(LifecycleAction.class, DownsampleAction.NAME, DownsampleAction::new)
             )
         );
     }
@@ -91,7 +91,7 @@ public class LifecyclePolicyMetadataTests extends AbstractSerializingTestCase<Li
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(SetPriorityAction.NAME), SetPriorityAction::parse),
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(MigrateAction.NAME), MigrateAction::parse),
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse),
-                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RollupILMAction.NAME), RollupILMAction::parse)
+                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DownsampleAction.NAME), DownsampleAction::parse)
             )
         );
         return new NamedXContentRegistry(entries);

+ 3 - 3
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyTests.java

@@ -66,7 +66,7 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase<LifecycleP
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, UnfollowAction.NAME, in -> UnfollowAction.INSTANCE),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, MigrateAction.NAME, MigrateAction::readFrom),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, SearchableSnapshotAction.NAME, SearchableSnapshotAction::new),
-                new NamedWriteableRegistry.Entry(LifecycleAction.class, RollupILMAction.NAME, RollupILMAction::new)
+                new NamedWriteableRegistry.Entry(LifecycleAction.class, DownsampleAction.NAME, DownsampleAction::new)
             )
         );
     }
@@ -101,7 +101,7 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase<LifecycleP
                     new ParseField(SearchableSnapshotAction.NAME),
                     SearchableSnapshotAction::parse
                 ),
-                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RollupILMAction.NAME), RollupILMAction::parse)
+                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DownsampleAction.NAME), DownsampleAction::parse)
             )
         );
         return new NamedXContentRegistry(entries);
@@ -259,7 +259,7 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase<LifecycleP
             case UnfollowAction.NAME -> UnfollowAction.INSTANCE;
             case SearchableSnapshotAction.NAME -> new SearchableSnapshotAction("repo", randomBoolean());
             case MigrateAction.NAME -> MigrateAction.DISABLED;
-            case RollupILMAction.NAME -> RollupILMActionTests.randomInstance();
+            case DownsampleAction.NAME -> DownsampleActionTests.randomInstance();
             default -> throw new IllegalArgumentException("invalid action [" + action + "]");
         };
     }

+ 13 - 9
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupStepTests.java

@@ -17,9 +17,9 @@ import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.cluster.metadata.LifecycleExecutionState;
 import org.elasticsearch.cluster.metadata.Metadata;
 import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
+import org.elasticsearch.xpack.core.downsample.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.Step.StepKey;
 import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
 import org.mockito.Mockito;
 
 import java.util.List;
@@ -27,7 +27,7 @@ import java.util.Map;
 
 import static org.elasticsearch.cluster.metadata.DataStreamTestHelper.newInstance;
 import static org.elasticsearch.cluster.metadata.LifecycleExecutionState.ILM_CUSTOM_METADATA_KEY;
-import static org.elasticsearch.xpack.core.ilm.RollupILMAction.ROLLUP_INDEX_PREFIX;
+import static org.elasticsearch.xpack.core.ilm.DownsampleAction.DOWNSAMPLED_INDEX_PREFIX;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.is;
@@ -79,10 +79,10 @@ public class RollupStepTests extends AbstractStepTestCase<RollupStep> {
             .build();
     }
 
-    private static void assertRollupActionRequest(RollupAction.Request request, String sourceIndex) {
+    private static void assertRollupActionRequest(DownsampleAction.Request request, String sourceIndex) {
         assertNotNull(request);
         assertThat(request.getSourceIndex(), equalTo(sourceIndex));
-        assertThat(request.getRollupIndex(), equalTo("rollup-index"));
+        assertThat(request.getTargetIndex(), equalTo("rollup-index"));
     }
 
     public void testPerformAction() throws Exception {
@@ -162,7 +162,7 @@ public class RollupStepTests extends AbstractStepTestCase<RollupStep> {
         lifecycleState.setStep(step.getKey().getName());
         lifecycleState.setIndexCreationDate(randomNonNegativeLong());
 
-        String rollupIndex = GenerateUniqueIndexNameStep.generateValidIndexName(ROLLUP_INDEX_PREFIX, sourceIndexName);
+        String rollupIndex = GenerateUniqueIndexNameStep.generateValidIndexName(DOWNSAMPLED_INDEX_PREFIX, sourceIndexName);
         lifecycleState.setRollupIndexName(rollupIndex);
 
         IndexMetadata sourceIndexMetadata = IndexMetadata.builder(sourceIndexName)
@@ -174,7 +174,9 @@ public class RollupStepTests extends AbstractStepTestCase<RollupStep> {
 
         // Create a successfully completed rollup index (index.rollup.status: success)
         IndexMetadata indexMetadata = IndexMetadata.builder(rollupIndex)
-            .settings(settings(Version.CURRENT).put(IndexMetadata.INDEX_ROLLUP_STATUS.getKey(), IndexMetadata.RollupTaskStatus.SUCCESS))
+            .settings(
+                settings(Version.CURRENT).put(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey(), IndexMetadata.DownsampleTaskStatus.SUCCESS)
+            )
             .numberOfShards(1)
             .numberOfReplicas(0)
             .build();
@@ -210,7 +212,7 @@ public class RollupStepTests extends AbstractStepTestCase<RollupStep> {
         lifecycleState.setStep(step.getKey().getName());
         lifecycleState.setIndexCreationDate(randomNonNegativeLong());
 
-        String rollupIndex = GenerateUniqueIndexNameStep.generateValidIndexName(ROLLUP_INDEX_PREFIX, sourceIndexName);
+        String rollupIndex = GenerateUniqueIndexNameStep.generateValidIndexName(DOWNSAMPLED_INDEX_PREFIX, sourceIndexName);
         lifecycleState.setRollupIndexName(rollupIndex);
 
         IndexMetadata sourceIndexMetadata = IndexMetadata.builder(sourceIndexName)
@@ -222,7 +224,9 @@ public class RollupStepTests extends AbstractStepTestCase<RollupStep> {
 
         // Create an in-progress rollup index (index.rollup.status: started)
         IndexMetadata indexMetadata = IndexMetadata.builder(rollupIndex)
-            .settings(settings(Version.CURRENT).put(IndexMetadata.INDEX_ROLLUP_STATUS.getKey(), IndexMetadata.RollupTaskStatus.STARTED))
+            .settings(
+                settings(Version.CURRENT).put(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey(), IndexMetadata.DownsampleTaskStatus.STARTED)
+            )
             .numberOfShards(1)
             .numberOfReplicas(0)
             .build();
@@ -245,7 +249,7 @@ public class RollupStepTests extends AbstractStepTestCase<RollupStep> {
 
     private void mockClientRollupCall(String sourceIndex) {
         Mockito.doAnswer(invocation -> {
-            RollupAction.Request request = (RollupAction.Request) invocation.getArguments()[1];
+            DownsampleAction.Request request = (DownsampleAction.Request) invocation.getArguments()[1];
             @SuppressWarnings("unchecked")
             ActionListener<AcknowledgedResponse> listener = (ActionListener<AcknowledgedResponse>) invocation.getArguments()[2];
             assertRollupActionRequest(request, sourceIndex);

+ 8 - 8
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleTypeTests.java

@@ -82,7 +82,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
     // keeping the migrate action disabled as otherwise it could conflict with the allocate action if both are randomly selected for the
     // same phase
     private static final MigrateAction TEST_MIGRATE_ACTION = MigrateAction.DISABLED;
-    private static final RollupILMAction TEST_ROLLUP_ACTION = new RollupILMAction(DateHistogramInterval.DAY);
+    private static final DownsampleAction TEST_DOWNSAMPLE_ACTION = new DownsampleAction(DateHistogramInterval.DAY);
 
     public void testValidatePhases() {
         boolean invalid = randomBoolean();
@@ -253,7 +253,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
         assertThat(ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT.size(), is(4));
         assertThat(
             ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT,
-            containsInAnyOrder(ShrinkAction.NAME, FreezeAction.NAME, ForceMergeAction.NAME, RollupILMAction.NAME)
+            containsInAnyOrder(ShrinkAction.NAME, FreezeAction.NAME, ForceMergeAction.NAME, DownsampleAction.NAME)
         );
     }
 
@@ -269,7 +269,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
             assertThat(
                 e.getMessage(),
                 is(
-                    "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, rollup] actions"
+                    "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, downsample] actions"
                         + " which are not allowed after a managed index is mounted as a searchable snapshot"
                 )
             );
@@ -290,7 +290,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
             assertThat(
                 e.getMessage(),
                 is(
-                    "phases [frozen] define one or more of [forcemerge, freeze, shrink, rollup] actions"
+                    "phases [frozen] define one or more of [forcemerge, freeze, shrink, downsample] actions"
                         + " which are not allowed after a managed index is mounted as a searchable snapshot"
                 )
             );
@@ -314,7 +314,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
             assertThat(
                 e.getMessage(),
                 is(
-                    "phases [warm,frozen] define one or more of [forcemerge, freeze, shrink, rollup] actions"
+                    "phases [warm,frozen] define one or more of [forcemerge, freeze, shrink, downsample] actions"
                         + " which are not allowed after a managed index is mounted as a searchable snapshot"
                 )
             );
@@ -340,7 +340,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
             assertThat(
                 e.getMessage(),
                 is(
-                    "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, rollup] actions"
+                    "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, downsample] actions"
                         + " which are not allowed after a managed index is mounted as a searchable snapshot"
                 )
             );
@@ -1114,7 +1114,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
                 case SetPriorityAction.NAME -> new SetPriorityAction(0);
                 case UnfollowAction.NAME -> UnfollowAction.INSTANCE;
                 case MigrateAction.NAME -> MigrateAction.ENABLED;
-                case RollupILMAction.NAME -> TEST_ROLLUP_ACTION;
+                case DownsampleAction.NAME -> TEST_DOWNSAMPLE_ACTION;
                 case SearchableSnapshotAction.NAME -> TEST_SEARCHABLE_SNAPSHOT_ACTION;
                 default -> DeleteAction.WITH_SNAPSHOT_DELETE;
             };
@@ -1179,7 +1179,7 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
             case UnfollowAction.NAME -> UnfollowAction.INSTANCE;
             case SearchableSnapshotAction.NAME -> TEST_SEARCHABLE_SNAPSHOT_ACTION;
             case MigrateAction.NAME -> TEST_MIGRATE_ACTION;
-            case RollupILMAction.NAME -> TEST_ROLLUP_ACTION;
+            case DownsampleAction.NAME -> TEST_DOWNSAMPLE_ACTION;
             default -> throw new IllegalArgumentException("unsupported timeseries phase action [" + actionName + "]");
         };
     }

+ 3 - 3
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/action/PutLifecycleRequestTests.java

@@ -15,6 +15,7 @@ import org.elasticsearch.xcontent.ParseField;
 import org.elasticsearch.xcontent.XContentParser;
 import org.elasticsearch.xpack.core.ilm.AllocateAction;
 import org.elasticsearch.xpack.core.ilm.DeleteAction;
+import org.elasticsearch.xpack.core.ilm.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
 import org.elasticsearch.xpack.core.ilm.FreezeAction;
 import org.elasticsearch.xpack.core.ilm.LifecycleAction;
@@ -24,7 +25,6 @@ import org.elasticsearch.xpack.core.ilm.LifecycleType;
 import org.elasticsearch.xpack.core.ilm.MigrateAction;
 import org.elasticsearch.xpack.core.ilm.ReadOnlyAction;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
-import org.elasticsearch.xpack.core.ilm.RollupILMAction;
 import org.elasticsearch.xpack.core.ilm.SearchableSnapshotAction;
 import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
 import org.elasticsearch.xpack.core.ilm.ShrinkAction;
@@ -83,7 +83,7 @@ public class PutLifecycleRequestTests extends AbstractSerializingTestCase<Reques
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, UnfollowAction.NAME, in -> UnfollowAction.INSTANCE),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, MigrateAction.NAME, MigrateAction::readFrom),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, SearchableSnapshotAction.NAME, SearchableSnapshotAction::new),
-                new NamedWriteableRegistry.Entry(LifecycleAction.class, RollupILMAction.NAME, RollupILMAction::new)
+                new NamedWriteableRegistry.Entry(LifecycleAction.class, DownsampleAction.NAME, DownsampleAction::new)
             )
         );
     }
@@ -118,7 +118,7 @@ public class PutLifecycleRequestTests extends AbstractSerializingTestCase<Reques
                 ),
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(MigrateAction.NAME), MigrateAction::parse),
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse),
-                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RollupILMAction.NAME), RollupILMAction::parse)
+                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DownsampleAction.NAME), DownsampleAction::parse)
             )
         );
         return new NamedXContentRegistry(entries);

+ 11 - 10
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/RollupActionConfigTests.java → x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/DownsampleActionConfigTests.java

@@ -10,39 +10,40 @@ import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
 import org.elasticsearch.test.AbstractSerializingTestCase;
 import org.elasticsearch.xcontent.XContentParser;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
 
 import java.io.IOException;
 
 import static org.hamcrest.Matchers.equalTo;
 
-public class RollupActionConfigTests extends AbstractSerializingTestCase<RollupActionConfig> {
+public class DownsampleActionConfigTests extends AbstractSerializingTestCase<DownsampleConfig> {
 
     @Override
-    protected RollupActionConfig createTestInstance() {
+    protected DownsampleConfig createTestInstance() {
         return randomConfig();
     }
 
-    public static RollupActionConfig randomConfig() {
-        return new RollupActionConfig(ConfigTestHelpers.randomInterval());
+    public static DownsampleConfig randomConfig() {
+        return new DownsampleConfig(ConfigTestHelpers.randomInterval());
     }
 
     @Override
-    protected Writeable.Reader<RollupActionConfig> instanceReader() {
-        return RollupActionConfig::new;
+    protected Writeable.Reader<DownsampleConfig> instanceReader() {
+        return DownsampleConfig::new;
     }
 
     @Override
-    protected RollupActionConfig doParseInstance(final XContentParser parser) throws IOException {
-        return RollupActionConfig.fromXContent(parser);
+    protected DownsampleConfig doParseInstance(final XContentParser parser) throws IOException {
+        return DownsampleConfig.fromXContent(parser);
     }
 
     public void testEmptyFixedInterval() {
-        Exception e = expectThrows(IllegalArgumentException.class, () -> new RollupActionConfig((DateHistogramInterval) null));
+        Exception e = expectThrows(IllegalArgumentException.class, () -> new DownsampleConfig((DateHistogramInterval) null));
         assertThat(e.getMessage(), equalTo("Parameter [fixed_interval] is required."));
     }
 
     public void testEmptyTimezone() {
-        RollupActionConfig config = new RollupActionConfig(ConfigTestHelpers.randomInterval());
+        DownsampleConfig config = new DownsampleConfig(ConfigTestHelpers.randomInterval());
         assertEquals("UTC", config.getTimeZone());
     }
 }

+ 17 - 16
x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/RollupActionIT.java → x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java

@@ -13,7 +13,7 @@ import org.elasticsearch.client.ResponseException;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.cluster.metadata.DataStream;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
-import org.elasticsearch.cluster.metadata.IndexMetadata.RollupTaskStatus;
+import org.elasticsearch.cluster.metadata.IndexMetadata.DownsampleTaskStatus;
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.time.DateFormatter;
@@ -26,13 +26,13 @@ import org.elasticsearch.test.rest.ESRestTestCase;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentFactory;
 import org.elasticsearch.xpack.core.ilm.CheckNotDataStreamWriteIndexStep;
+import org.elasticsearch.xpack.core.ilm.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.LifecycleAction;
 import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
 import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
 import org.elasticsearch.xpack.core.ilm.Phase;
 import org.elasticsearch.xpack.core.ilm.PhaseCompleteStep;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
-import org.elasticsearch.xpack.core.ilm.RollupILMAction;
 import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
 import org.junit.Before;
 
@@ -54,7 +54,7 @@ import static org.elasticsearch.xpack.TimeSeriesRestDriver.updatePolicy;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
 
-public class RollupActionIT extends ESRestTestCase {
+public class DownsampleActionIT extends ESRestTestCase {
 
     private String index;
     private String policy;
@@ -144,7 +144,7 @@ public class RollupActionIT extends ESRestTestCase {
         index(client(), index, true, null, "@timestamp", "2020-01-01T05:10:00Z", "volume", 11.0, "metricset", randomAlphaOfLength(5));
 
         String phaseName = randomFrom("warm", "cold");
-        createNewSingletonPolicy(client(), policy, phaseName, new RollupILMAction(ConfigTestHelpers.randomInterval()));
+        createNewSingletonPolicy(client(), policy, phaseName, new DownsampleAction(ConfigTestHelpers.randomInterval()));
         updatePolicy(client(), index, policy);
         updateClusterSettings(client(), Settings.builder().put("indices.lifecycle.poll_interval", "5s").build());
 
@@ -159,8 +159,8 @@ public class RollupActionIT extends ESRestTestCase {
         );
         assertBusy(() -> {
             Map<String, Object> settings = getOnlyIndexSettings(client(), rollupIndex);
-            assertEquals(index, settings.get(IndexMetadata.INDEX_ROLLUP_SOURCE_NAME.getKey()));
-            assertEquals(RollupTaskStatus.SUCCESS.toString(), settings.get(IndexMetadata.INDEX_ROLLUP_STATUS.getKey()));
+            assertEquals(index, settings.get(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME.getKey()));
+            assertEquals(DownsampleTaskStatus.SUCCESS.toString(), settings.get(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey()));
         });
         assertBusy(
             () -> assertTrue("Alias [" + alias + "] does not point to index [" + rollupIndex + "]", aliasExists(rollupIndex, alias))
@@ -173,10 +173,11 @@ public class RollupActionIT extends ESRestTestCase {
 
         ResponseException e = expectThrows(
             ResponseException.class,
-            () -> createNewSingletonPolicy(client(), policy, "hot", new RollupILMAction(ConfigTestHelpers.randomInterval()))
+            () -> createNewSingletonPolicy(client(), policy, "hot", new DownsampleAction(ConfigTestHelpers.randomInterval()))
         );
         assertTrue(
-            e.getMessage().contains("the [rollup] action(s) may not be used in the [hot] phase without an accompanying [rollover] action")
+            e.getMessage()
+                .contains("the [downsample] action(s) may not be used in the [hot] phase without an accompanying [rollover] action")
         );
     }
 
@@ -187,8 +188,8 @@ public class RollupActionIT extends ESRestTestCase {
         Map<String, LifecycleAction> hotActions = Map.of(
             RolloverAction.NAME,
             new RolloverAction(null, null, null, 1L, null, null, null, null, null, null),
-            RollupILMAction.NAME,
-            new RollupILMAction(ConfigTestHelpers.randomInterval())
+            DownsampleAction.NAME,
+            new DownsampleAction(ConfigTestHelpers.randomInterval())
         );
         Map<String, Phase> phases = Map.of("hot", new Phase("hot", TimeValue.ZERO, hotActions));
         LifecyclePolicy lifecyclePolicy = new LifecyclePolicy(policy, phases);
@@ -237,14 +238,14 @@ public class RollupActionIT extends ESRestTestCase {
         );
         assertBusy(() -> {
             Map<String, Object> settings = getOnlyIndexSettings(client(), rollupIndex);
-            assertEquals(originalIndex, settings.get(IndexMetadata.INDEX_ROLLUP_SOURCE_NAME.getKey()));
-            assertEquals(RollupTaskStatus.SUCCESS.toString(), settings.get(IndexMetadata.INDEX_ROLLUP_STATUS.getKey()));
+            assertEquals(originalIndex, settings.get(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME.getKey()));
+            assertEquals(DownsampleTaskStatus.SUCCESS.toString(), settings.get(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey()));
         });
     }
 
     public void testTsdbDataStreams() throws Exception {
         // Create the ILM policy
-        createNewSingletonPolicy(client(), policy, "warm", new RollupILMAction(ConfigTestHelpers.randomInterval()));
+        createNewSingletonPolicy(client(), policy, "warm", new DownsampleAction(ConfigTestHelpers.randomInterval()));
 
         // Create a template
         Request createIndexTemplateRequest = new Request("POST", "/_index_template/" + dataStream);
@@ -274,8 +275,8 @@ public class RollupActionIT extends ESRestTestCase {
         assertBusy(() -> assertFalse("Source index should have been deleted", indexExists(backingIndexName)), 30, TimeUnit.SECONDS);
         assertBusy(() -> {
             Map<String, Object> settings = getOnlyIndexSettings(client(), rollupIndex);
-            assertEquals(backingIndexName, settings.get(IndexMetadata.INDEX_ROLLUP_SOURCE_NAME.getKey()));
-            assertEquals(RollupTaskStatus.SUCCESS.toString(), settings.get(IndexMetadata.INDEX_ROLLUP_STATUS.getKey()));
+            assertEquals(backingIndexName, settings.get(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME.getKey()));
+            assertEquals(DownsampleTaskStatus.SUCCESS.toString(), settings.get(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey()));
         });
     }
 
@@ -301,7 +302,7 @@ public class RollupActionIT extends ESRestTestCase {
 
     public static String getRollupIndexName(RestClient client, String originalIndexName) throws IOException {
         Response response = client.performRequest(
-            new Request("GET", "/" + RollupILMAction.ROLLUP_INDEX_PREFIX + "*-" + originalIndexName + "/?expand_wildcards=all")
+            new Request("GET", "/" + DownsampleAction.DOWNSAMPLED_INDEX_PREFIX + "*-" + originalIndexName + "/?expand_wildcards=all")
         );
         Map<String, Object> asMap = responseAsMap(response);
         if (asMap.size() == 1) {

+ 1 - 1
x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java

@@ -265,7 +265,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
         assertThat(
             exception.getMessage(),
             containsString(
-                "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, rollup]"
+                "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, downsample]"
                     + " actions which are not allowed after a managed index is mounted as a searchable snapshot"
             )
         );

+ 2 - 2
x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java

@@ -50,6 +50,7 @@ import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction;
 import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
 import org.elasticsearch.xpack.core.ilm.AllocateAction;
 import org.elasticsearch.xpack.core.ilm.DeleteAction;
+import org.elasticsearch.xpack.core.ilm.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
 import org.elasticsearch.xpack.core.ilm.FreezeAction;
 import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
@@ -59,7 +60,6 @@ import org.elasticsearch.xpack.core.ilm.LifecycleType;
 import org.elasticsearch.xpack.core.ilm.MigrateAction;
 import org.elasticsearch.xpack.core.ilm.ReadOnlyAction;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
-import org.elasticsearch.xpack.core.ilm.RollupILMAction;
 import org.elasticsearch.xpack.core.ilm.SearchableSnapshotAction;
 import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
 import org.elasticsearch.xpack.core.ilm.ShrinkAction;
@@ -337,7 +337,7 @@ public class IndexLifecycle extends Plugin implements ActionPlugin, HealthPlugin
         // TSDB Downsampling / Rollup
         if (IndexSettings.isTimeSeriesModeEnabled()) {
             entries.add(
-                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RollupILMAction.NAME), RollupILMAction::parse)
+                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DownsampleAction.NAME), DownsampleAction::parse)
             );
         }
         return List.copyOf(entries);

+ 3 - 3
x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java

@@ -22,6 +22,7 @@ import org.elasticsearch.xcontent.ParseField;
 import org.elasticsearch.xcontent.XContentParser;
 import org.elasticsearch.xpack.core.ilm.AllocateAction;
 import org.elasticsearch.xpack.core.ilm.DeleteAction;
+import org.elasticsearch.xpack.core.ilm.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
 import org.elasticsearch.xpack.core.ilm.FreezeAction;
 import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
@@ -35,7 +36,6 @@ import org.elasticsearch.xpack.core.ilm.OperationMode;
 import org.elasticsearch.xpack.core.ilm.Phase;
 import org.elasticsearch.xpack.core.ilm.ReadOnlyAction;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
-import org.elasticsearch.xpack.core.ilm.RollupILMAction;
 import org.elasticsearch.xpack.core.ilm.SearchableSnapshotAction;
 import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
 import org.elasticsearch.xpack.core.ilm.ShrinkAction;
@@ -102,7 +102,7 @@ public class IndexLifecycleMetadataTests extends SimpleDiffableSerializationTest
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, UnfollowAction.NAME, in -> UnfollowAction.INSTANCE),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, MigrateAction.NAME, MigrateAction::readFrom),
                 new NamedWriteableRegistry.Entry(LifecycleAction.class, SearchableSnapshotAction.NAME, SearchableSnapshotAction::new),
-                new NamedWriteableRegistry.Entry(LifecycleAction.class, RollupILMAction.NAME, RollupILMAction::new)
+                new NamedWriteableRegistry.Entry(LifecycleAction.class, DownsampleAction.NAME, DownsampleAction::new)
             )
         );
     }
@@ -137,7 +137,7 @@ public class IndexLifecycleMetadataTests extends SimpleDiffableSerializationTest
                     new ParseField(SearchableSnapshotAction.NAME),
                     SearchableSnapshotAction::parse
                 ),
-                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RollupILMAction.NAME), RollupILMAction::parse)
+                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DownsampleAction.NAME), DownsampleAction::parse)
             )
         );
         return new NamedXContentRegistry(entries);

+ 2 - 2
x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/ReservedLifecycleStateServiceTests.java

@@ -36,6 +36,7 @@ import org.elasticsearch.xcontent.XContentParserConfiguration;
 import org.elasticsearch.xcontent.XContentType;
 import org.elasticsearch.xpack.core.ilm.AllocateAction;
 import org.elasticsearch.xpack.core.ilm.DeleteAction;
+import org.elasticsearch.xpack.core.ilm.DownsampleAction;
 import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
 import org.elasticsearch.xpack.core.ilm.FreezeAction;
 import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
@@ -46,7 +47,6 @@ import org.elasticsearch.xpack.core.ilm.MigrateAction;
 import org.elasticsearch.xpack.core.ilm.Phase;
 import org.elasticsearch.xpack.core.ilm.ReadOnlyAction;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
-import org.elasticsearch.xpack.core.ilm.RollupILMAction;
 import org.elasticsearch.xpack.core.ilm.SearchableSnapshotAction;
 import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
 import org.elasticsearch.xpack.core.ilm.ShrinkAction;
@@ -104,7 +104,7 @@ public class ReservedLifecycleStateServiceTests extends ESTestCase {
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(SetPriorityAction.NAME), SetPriorityAction::parse),
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(MigrateAction.NAME), MigrateAction::parse),
                 new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse),
-                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RollupILMAction.NAME), RollupILMAction::parse)
+                new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DownsampleAction.NAME), DownsampleAction::parse)
             )
         );
         return new NamedXContentRegistry(entries);

+ 2 - 2
x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/aggregations/support/AggregateMetricsValuesSourceType.java

@@ -10,7 +10,7 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
 import org.elasticsearch.script.AggregationScript;
 import org.elasticsearch.search.DocValueFormat;
 import org.elasticsearch.search.aggregations.AggregationExecutionException;
-import org.elasticsearch.search.aggregations.UnsupportedAggregationOnRollupIndex;
+import org.elasticsearch.search.aggregations.UnsupportedAggregationOnDownsampledIndex;
 import org.elasticsearch.search.aggregations.support.AggregationContext;
 import org.elasticsearch.search.aggregations.support.FieldContext;
 import org.elasticsearch.search.aggregations.support.ValueType;
@@ -26,7 +26,7 @@ public enum AggregateMetricsValuesSourceType implements ValuesSourceType {
 
         @Override
         public RuntimeException getUnregisteredException(String message) {
-            return new UnsupportedAggregationOnRollupIndex(message);
+            return new UnsupportedAggregationOnDownsampledIndex(message);
         }
 
         @Override

+ 2 - 2
x-pack/plugin/rollup/qa/rest/build.gradle

@@ -17,7 +17,7 @@ dependencies {
 
 restResources {
   restApi {
-    include '_common', 'bulk', 'cluster', 'indices', 'search', 'rollup'
+    include '_common', 'bulk', 'cluster', 'indices', 'search', 'downsample'
   }
 }
 
@@ -34,5 +34,5 @@ if (BuildParams.inFipsJvm){
 }
 
 tasks.named("yamlRestTestV7CompatTransform").configure { task ->
-  task.skipTest("rollup/10_basic/Rollup index", "rollup for TSDB changed the configuration")
+  task.skipTest("rollup/10_basic/Rollup index", "Downsample for TSDB changed the configuration")
 }

+ 17 - 15
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/10_basic.yml

@@ -1,7 +1,7 @@
 setup:
   - skip:
-      version: " - 8.3.99"
-      reason: "rollup: labels support added in 8.4.0"
+      version: " - 8.4.99"
+      reason: "rollup renamed to downsample in 8.5.0"
 
   - do:
       indices.create:
@@ -89,12 +89,13 @@ setup:
 ---
 "Rollup index":
   - skip:
-      version: " - 8.2.99"
-      reason: tsdb rollups added in 8.3.0
+      version: " - 8.4.99"
+      reason: "rollup renamed to downsample in 8.5.0"
+
   - do:
-      rollup.rollup:
+      indices.downsample:
         index: test
-        rollup_index: rollup-test
+        target_index: rollup-test
         body:  >
           {
             "fixed_interval": "1h"
@@ -136,7 +137,7 @@ setup:
   - match: { rollup-test.settings.index.time_series.end_time:   2021-04-29T00:00:00Z }
   - match: { rollup-test.settings.index.time_series.start_time: 2021-04-28T00:00:00Z }
   - match: { rollup-test.settings.index.routing_path: [ "metricset", "k8s.pod.uid"] }
-  - match: { rollup-test.settings.index.rollup.source.name: test }
+  - match: { rollup-test.settings.index.downsample.source.name: test }
   - match: { rollup-test.settings.index.number_of_shards: "1" }
   - match: { rollup-test.settings.index.number_of_replicas: "0" }
 
@@ -148,13 +149,14 @@ setup:
 ---
 "Rollup non-existing index":
   - skip:
-      version: " - 8.2.99"
-      reason: tsdb rollups added in 8.3.0
+      version: " - 8.4.99"
+      reason: "rollup renamed to downsample in 8.5.0"
+
   - do:
       catch: /no such index \[non-existing-index\]/
-      rollup.rollup:
+      indices.downsample:
         index: non-existing-index
-        rollup_index: rollup-test
+        target_index: rollup-test
         body:  >
           {
             "fixed_interval": "1h"
@@ -163,8 +165,8 @@ setup:
 ---
 "Rollup to existing rollup index":
   - skip:
-      version: " - 8.2.99"
-      reason: tsdb rollups added in 8.3.0
+      version: " - 8.4.99"
+      reason: "rollup renamed to downsample in 8.5.0"
 
   - do:
       indices.create:
@@ -172,9 +174,9 @@ setup:
 
   - do:
       catch: /resource_already_exists_exception/
-      rollup.rollup:
+      indices.downsample:
         index: test
-        rollup_index: rollup-test
+        target_index: rollup-test
         body:  >
           {
             "fixed_interval": "1h"

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

@@ -1,7 +1,7 @@
 setup:
   - skip:
       version: " - 8.4.99"
-      reason: "rollup: unsupported aggregations errors added in 8.5.0"
+      reason: "downsampling: unsupported aggregations errors added in 8.5.0"
 
   - do:
       indices.create:
@@ -45,7 +45,7 @@ setup:
 "Histogram aggregation on aggregate_metric_double field":
   - skip:
       version: " - 8.4.99"
-      reason: "rollup: unsupported aggregations errors added in 8.5.0"
+      reason: "downsampling: unsupported aggregations errors added in 8.5.0"
 
   - do:
       catch: bad_request
@@ -62,15 +62,15 @@ setup:
 
   - match: { status: 400 }
   # NOTE: the type of error is part of a contract with Kibana which uses it to detect specific
-  # errors while running aggregations on rollup indices.
-  - match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index }
+  # errors while running aggregations on downsampled indices.
+  - match: { error.root_cause.0.type: unsupported_aggregation_on_downsampled_index }
   - match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [histogram]" }
 
 ---
 "Range aggregation on aggregate_metric_double field":
   - skip:
       version: " - 8.4.99"
-      reason: "rollup: unsupported aggregations errors added in 8.5.0"
+      reason: "downsample: unsupported aggregations errors added in 8.5.0"
 
   - do:
       catch: bad_request
@@ -94,15 +94,15 @@ setup:
 
   - match: { status: 400 }
   # NOTE: the type of error is part of a contract with Kibana which uses it to detect specific
-  # errors while running aggregations on rollup indices.
-  - match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index }
+  # errors while running aggregations on downsampled indices.
+  - match: { error.root_cause.0.type: unsupported_aggregation_on_downsampled_index }
   - match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [range]" }
 
 ---
 "Cardinality aggregation on aggregate_metric_double field":
   - skip:
       version: " - 8.4.99"
-      reason: "rollup: unsupported aggregations errors added in 8.5.0"
+      reason: "downsampling: unsupported aggregations errors added in 8.5.0"
 
   - do:
       catch: bad_request
@@ -117,15 +117,15 @@ setup:
 
   - match: { status: 400 }
   # NOTE: the type of error is part of a contract with Kibana which uses it to detect specific
-  # errors while running aggregations on rollup indices.
-  - match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index }
+  # errors while running aggregations on downsampled indices.
+  - match: { error.root_cause.0.type: unsupported_aggregation_on_downsampled_index }
   - match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [cardinality]" }
 
 ---
 "Percentiles aggregation on aggregate_metric_double field":
   - skip:
       version: " - 8.4.99"
-      reason: "rollup: unsupported aggregations errors added in 8.5.0"
+      reason: "downsampling: unsupported aggregations errors added in 8.5.0"
 
   - do:
       catch: bad_request
@@ -141,15 +141,15 @@ setup:
 
   - match: { status: 400 }
   # NOTE: the type of error is part of a contract with Kibana which uses it to detect specific
-  # errors while running aggregations on rollup indices.
-  - match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index }
+  # errors while running aggregations on downsampled indices.
+  - match: { error.root_cause.0.type: unsupported_aggregation_on_downsampled_index }
   - match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [percentiles]" }
 
 ---
 "Top-metrics aggregation on aggregate_metric_double field":
   - skip:
       version: " - 8.4.99"
-      reason: "rollup: unsupported aggregations errors added in 8.5.0"
+      reason: "downsampling: unsupported aggregations errors added in 8.5.0"
 
   - do:
       catch: bad_request
@@ -169,6 +169,6 @@ setup:
 
   - match: { status: 400 }
   # NOTE: the type of error is part of a contract with Kibana which uses it to detect specific
-  # errors while running aggregations on rollup indices.
-  - match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index }
+  # errors while running aggregations on downsampled indices.
+  - match: { error.root_cause.0.type: unsupported_aggregation_on_downsampled_index }
   - match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [top_metrics]" }

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

@@ -47,16 +47,16 @@ setup:
           index.blocks.write: true
 
 ---
-"Date histogram aggregation on time series index and rollup indexs":
+"Date histogram aggregation on time series index and rollup indices":
   - skip:
       version: " - 8.4.99"
       reason: "rollup: unsupported aggregations errors added in 8.5.0"
       features: close_to
 
   - do:
-      rollup.rollup:
+      indices.downsample:
         index: test
-        rollup_index: rollup-test
+        target_index: rollup-test
         body:  >
           {
             "fixed_interval": "1h"

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 /**
  * Base class for classes that read metric and label fields.

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.util.BytesRef;

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.index.query.SearchExecutionContext;
 

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.index.mapper.MappedFieldType;
 import org.elasticsearch.index.query.SearchExecutionContext;

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

@@ -5,39 +5,39 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.client.internal.node.NodeClient;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
 
 import java.io.IOException;
 import java.util.List;
 
 import static org.elasticsearch.rest.RestRequest.Method.POST;
 
-public class RestRollupAction extends BaseRestHandler {
+public class RestDownsampleAction extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(POST, "/{index}/_rollup/{rollup_index}"));
+        return List.of(new Route(POST, "/{index}/_downsample/{target_index}"));
     }
 
     @Override
     protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
         String sourceIndex = restRequest.param("index");
-        String rollupIndex = restRequest.param("rollup_index");
-        RollupActionConfig config = RollupActionConfig.fromXContent(restRequest.contentParser());
-        RollupAction.Request request = new RollupAction.Request(sourceIndex, rollupIndex, config);
-        return channel -> client.execute(RollupAction.INSTANCE, request, new RestToXContentListener<>(channel));
+        String targetIndex = restRequest.param("target_index");
+        DownsampleConfig config = DownsampleConfig.fromXContent(restRequest.contentParser());
+        DownsampleAction.Request request = new DownsampleAction.Request(sourceIndex, targetIndex, config);
+        return channel -> client.execute(DownsampleAction.INSTANCE, request, new RestToXContentListener<>(channel));
     }
 
     @Override
     public String getName() {
-        return "rollup_action";
+        return "downsample_action";
     }
 
 }

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

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -43,8 +43,8 @@ import org.elasticsearch.search.aggregations.BucketCollector;
 import org.elasticsearch.search.aggregations.LeafBucketCollector;
 import org.elasticsearch.search.aggregations.bucket.DocCountProvider;
 import org.elasticsearch.search.aggregations.timeseries.TimeSeriesIndexSearcher;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
-import org.elasticsearch.xpack.core.rollup.action.RollupIndexerAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
+import org.elasticsearch.xpack.core.downsample.RollupIndexerAction;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -76,7 +76,7 @@ class RollupShardIndexer {
 
     private final IndexShard indexShard;
     private final Client client;
-    private final RollupActionConfig config;
+    private final DownsampleConfig config;
     private final String rollupIndex;
 
     private final Engine.Searcher searcher;
@@ -100,7 +100,7 @@ class RollupShardIndexer {
         IndexService indexService,
         ShardId shardId,
         String rollupIndex,
-        RollupActionConfig config,
+        DownsampleConfig config,
         String[] dimensionFields,
         String[] metricFields,
         String[] labelFields

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.compress.CompressedXContent;

+ 27 - 23
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupAction.java → x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupAction.java

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -60,10 +60,10 @@ import org.elasticsearch.xcontent.XContentFactory;
 import org.elasticsearch.xcontent.XContentType;
 import org.elasticsearch.xpack.aggregatemetric.mapper.AggregateDoubleMetricFieldMapper;
 import org.elasticsearch.xpack.core.ClientHelper;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
+import org.elasticsearch.xpack.core.downsample.RollupIndexerAction;
 import org.elasticsearch.xpack.core.rollup.action.RollupActionRequestValidationException;
-import org.elasticsearch.xpack.core.rollup.action.RollupIndexerAction;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -78,7 +78,7 @@ import static org.elasticsearch.index.mapper.TimeSeriesParams.TIME_SERIES_METRIC
  *  -  calling {@link TransportRollupIndexerAction} to index rollup documents
  *  -  cleaning up state
  */
-public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction<RollupAction.Request> {
+public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction<DownsampleAction.Request> {
 
     private static final Logger logger = LogManager.getLogger(TransportRollupAction.class);
 
@@ -120,12 +120,12 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
         IndexScopedSettings indexScopedSettings
     ) {
         super(
-            RollupAction.NAME,
+            DownsampleAction.NAME,
             transportService,
             clusterService,
             threadPool,
             actionFilters,
-            RollupAction.Request::new,
+            DownsampleAction.Request::new,
             indexNameExpressionResolver,
             ThreadPool.Names.SAME
         );
@@ -139,7 +139,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
     @Override
     protected void masterOperation(
         Task task,
-        RollupAction.Request request,
+        DownsampleAction.Request request,
         ClusterState state,
         ActionListener<AcknowledgedResponse> listener
     ) {
@@ -177,7 +177,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
             return;
         }
 
-        final String rollupIndexName = request.getRollupIndex();
+        final String rollupIndexName = request.getTargetIndex();
         // Assert rollup index does not exist
         MetadataCreateIndexService.validateIndexName(rollupIndexName, state);
 
@@ -213,7 +213,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
                 indicesService,
                 sourceIndexMappings,
                 sourceIndexMetadata
-            ).build(request.getRollupConfig().getTimestampField());
+            ).build(request.getDownsampleConfig().getTimestampField());
             MappingVisitor.visitMapping(sourceIndexMappings, (field, mapping) -> {
                 if (helper.isTimeSeriesDimension(field, mapping)) {
                     dimensionFields.add(field);
@@ -243,7 +243,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
 
             final String mapping;
             try {
-                mapping = createRollupIndexMapping(helper, request.getRollupConfig(), mapperService, sourceIndexMappings);
+                mapping = createRollupIndexMapping(helper, request.getDownsampleConfig(), mapperService, sourceIndexMappings);
             } catch (IOException e) {
                 listener.onFailure(e);
                 return;
@@ -381,7 +381,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
     }
 
     @Override
-    protected ClusterBlockException checkBlock(RollupAction.Request request, ClusterState state) {
+    protected ClusterBlockException checkBlock(DownsampleAction.Request request, ClusterState state) {
         return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
     }
 
@@ -396,7 +396,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
      */
     public static String createRollupIndexMapping(
         final TimeseriesFieldTypeHelper helper,
-        final RollupActionConfig config,
+        final DownsampleConfig config,
         final MapperService mapperService,
         final Map<String, Object> sourceIndexMappings
     ) throws IOException {
@@ -437,7 +437,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
         });
     }
 
-    private static void addTimestampField(final RollupActionConfig config, final XContentBuilder builder) throws IOException {
+    private static void addTimestampField(final DownsampleConfig config, final XContentBuilder builder) throws IOException {
         final String timestampField = config.getTimestampField();
         final String dateIntervalType = config.getIntervalType();
         final String dateInterval = config.getInterval().toString();
@@ -447,7 +447,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
             .field("type", DateFieldMapper.CONTENT_TYPE)
             .startObject("meta")
             .field(dateIntervalType, dateInterval)
-            .field(RollupActionConfig.TIME_ZONE, timezone)
+            .field(DownsampleConfig.TIME_ZONE, timezone)
             .endObject()
             .endObject();
     }
@@ -505,11 +505,11 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
          * If the source index is a rollup index, we will add the name and UUID
          * of the first index that we initially rolled up.
          */
-        if (IndexMetadata.INDEX_ROLLUP_SOURCE_UUID.exists(sourceIndexMetadata.getSettings()) == false
-            || IndexMetadata.INDEX_ROLLUP_SOURCE_NAME.exists(sourceIndexMetadata.getSettings()) == false) {
+        if (IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID.exists(sourceIndexMetadata.getSettings()) == false
+            || IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME.exists(sourceIndexMetadata.getSettings()) == false) {
             Index sourceIndex = sourceIndexMetadata.getIndex();
-            targetSettings.put(IndexMetadata.INDEX_ROLLUP_SOURCE_NAME.getKey(), sourceIndex.getName())
-                .put(IndexMetadata.INDEX_ROLLUP_SOURCE_UUID.getKey(), sourceIndex.getUUID());
+            targetSettings.put(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME.getKey(), sourceIndex.getName())
+                .put(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID.getKey(), sourceIndex.getUUID());
         }
 
         return IndexMetadata.builder(rollupIndexMetadata).settings(targetSettings);
@@ -535,7 +535,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
         String rollupIndexName,
         IndexMetadata sourceIndexMetadata,
         String mapping,
-        RollupAction.Request request,
+        DownsampleAction.Request request,
         ActionListener<AcknowledgedResponse> listener
     ) {
         CreateIndexClusterStateUpdateRequest createIndexClusterStateUpdateRequest = new CreateIndexClusterStateUpdateRequest(
@@ -557,7 +557,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
                 .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, sourceIndexMetadata.getNumberOfShards())
                 .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
                 .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1")
-                .put(IndexMetadata.INDEX_ROLLUP_STATUS.getKey(), IndexMetadata.RollupTaskStatus.STARTED)
+                .put(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey(), IndexMetadata.DownsampleTaskStatus.STARTED)
                 .build()
         ).mappings(mapping);
         clusterService.submitStateUpdateTask("create-rollup-index [" + rollupIndexName + "]", new RollupClusterStateUpdateTask(listener) {
@@ -574,7 +574,11 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
         }, ClusterStateTaskConfig.build(Priority.URGENT, request.masterNodeTimeout()), STATE_UPDATE_TASK_EXECUTOR);
     }
 
-    private void updateRollupMetadata(String rollupIndexName, RollupAction.Request request, ActionListener<AcknowledgedResponse> listener) {
+    private void updateRollupMetadata(
+        String rollupIndexName,
+        DownsampleAction.Request request,
+        ActionListener<AcknowledgedResponse> listener
+    ) {
         // 6. Mark rollup index as "completed successfully" ("index.rollup.status": "success")
         clusterService.submitStateUpdateTask(
             "update-rollup-metadata [" + rollupIndexName + "]",
@@ -590,7 +594,7 @@ public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction
                     metadataBuilder.updateSettings(
                         Settings.builder()
                             .put(rollupIndexMetadata.getSettings())
-                            .put(IndexMetadata.INDEX_ROLLUP_STATUS.getKey(), IndexMetadata.RollupTaskStatus.SUCCESS)
+                            .put(IndexMetadata.INDEX_DOWNSAMPLE_STATUS.getKey(), IndexMetadata.DownsampleTaskStatus.SUCCESS)
                             .build(),
                         rollupIndexName
                     );

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

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ActionListener;
@@ -28,7 +28,7 @@ import org.elasticsearch.indices.IndicesService;
 import org.elasticsearch.tasks.Task;
 import org.elasticsearch.transport.TransportService;
 import org.elasticsearch.xpack.core.ClientHelper;
-import org.elasticsearch.xpack.core.rollup.action.RollupIndexerAction;
+import org.elasticsearch.xpack.core.downsample.RollupIndexerAction;
 
 import java.io.IOException;
 import java.util.Arrays;

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

@@ -39,18 +39,21 @@ import org.elasticsearch.watcher.ResourceWatcherService;
 import org.elasticsearch.xcontent.NamedXContentRegistry;
 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.RollupIndexerAction;
 import org.elasticsearch.xpack.core.rollup.RollupField;
 import org.elasticsearch.xpack.core.rollup.action.DeleteRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.GetRollupCapsAction;
 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.RollupAction;
-import org.elasticsearch.xpack.core.rollup.action.RollupIndexerAction;
 import org.elasticsearch.xpack.core.rollup.action.RollupSearchAction;
 import org.elasticsearch.xpack.core.rollup.action.StartRollupJobAction;
 import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction;
 import org.elasticsearch.xpack.core.scheduler.SchedulerEngine;
+import org.elasticsearch.xpack.downsample.RestDownsampleAction;
+import org.elasticsearch.xpack.downsample.TransportRollupAction;
+import org.elasticsearch.xpack.downsample.TransportRollupIndexerAction;
 import org.elasticsearch.xpack.rollup.action.TransportDeleteRollupJobAction;
 import org.elasticsearch.xpack.rollup.action.TransportGetRollupCapsAction;
 import org.elasticsearch.xpack.rollup.action.TransportGetRollupIndexCapsAction;
@@ -68,9 +71,6 @@ import org.elasticsearch.xpack.rollup.rest.RestPutRollupJobAction;
 import org.elasticsearch.xpack.rollup.rest.RestRollupSearchAction;
 import org.elasticsearch.xpack.rollup.rest.RestStartRollupJobAction;
 import org.elasticsearch.xpack.rollup.rest.RestStopRollupJobAction;
-import org.elasticsearch.xpack.rollup.v2.RestRollupAction;
-import org.elasticsearch.xpack.rollup.v2.TransportRollupAction;
-import org.elasticsearch.xpack.rollup.v2.TransportRollupIndexerAction;
 
 import java.time.Clock;
 import java.util.ArrayList;
@@ -146,7 +146,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
 
         // TSDB Downsampling / Rollup
         if (IndexSettings.isTimeSeriesModeEnabled()) {
-            handlers.add(new RestRollupAction());
+            handlers.add(new RestDownsampleAction());
         }
 
         return handlers;
@@ -171,7 +171,7 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin
 
         if (IndexSettings.isTimeSeriesModeEnabled()) {
             actions.add(new ActionHandler<>(RollupIndexerAction.INSTANCE, TransportRollupIndexerAction.class));
-            actions.add(new ActionHandler<>(RollupAction.INSTANCE, TransportRollupAction.class));
+            actions.add(new ActionHandler<>(DownsampleAction.INSTANCE, TransportRollupAction.class));
         }
 
         return actions;

+ 31 - 29
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java → x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java

@@ -4,7 +4,7 @@
  * 2.0; you may not use this file except in compliance with the Elastic License
  * 2.0.
  */
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.ResourceAlreadyExistsException;
@@ -70,11 +70,11 @@ import org.elasticsearch.xcontent.XContentFactory;
 import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
 import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
 import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
+import org.elasticsearch.xpack.core.downsample.DownsampleAction;
+import org.elasticsearch.xpack.core.downsample.DownsampleConfig;
 import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
 import org.elasticsearch.xpack.core.ilm.RolloverAction;
 import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers;
-import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
-import org.elasticsearch.xpack.core.rollup.action.RollupAction;
 import org.elasticsearch.xpack.core.rollup.action.RollupActionRequestValidationException;
 import org.elasticsearch.xpack.ilm.IndexLifecycle;
 import org.elasticsearch.xpack.rollup.Rollup;
@@ -102,7 +102,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
 import static org.hamcrest.Matchers.containsString;
 
-public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
+public class DownsampleActionSingleNodeTests extends ESSingleNodeTestCase {
 
     private static final DateFormatter DATE_FORMATTER = DateFormatter.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
     public static final String FIELD_TIMESTAMP = "@timestamp";
@@ -223,7 +223,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     public void testRollupIndex() throws IOException {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         SourceSupplier sourceSupplier = () -> {
             String ts = randomDateForInterval(config.getInterval());
             double labelDoubleValue = DATE_FORMATTER.parseMillis(ts);
@@ -293,7 +293,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
         var updateSettingsReq = new UpdateSettingsRequest(settings, sourceIndex);
         assertAcked(client().admin().indices().updateSettings(updateSettingsReq).actionGet());
 
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         SourceSupplier sourceSupplier = () -> {
             String ts = randomDateForInterval(config.getInterval());
             return XContentFactory.jsonBuilder()
@@ -315,7 +315,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     public void testNullSourceIndexName() {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         ActionRequestValidationException exception = expectThrows(
             ActionRequestValidationException.class,
             () -> rollup(null, rollupIndex, config)
@@ -324,12 +324,12 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     public void testNullRollupIndexName() {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         ActionRequestValidationException exception = expectThrows(
             ActionRequestValidationException.class,
             () -> rollup(sourceIndex, null, config)
         );
-        assertThat(exception.getMessage(), containsString("rollup index name is missing"));
+        assertThat(exception.getMessage(), containsString("target index name is missing"));
     }
 
     public void testNullRollupConfig() {
@@ -337,11 +337,11 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
             ActionRequestValidationException.class,
             () -> rollup(sourceIndex, rollupIndex, null)
         );
-        assertThat(exception.getMessage(), containsString("rollup configuration is missing"));
+        assertThat(exception.getMessage(), containsString("downsample configuration is missing"));
     }
 
     public void testRollupSparseMetrics() throws IOException {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         SourceSupplier sourceSupplier = () -> {
             XContentBuilder builder = XContentFactory.jsonBuilder()
                 .startObject()
@@ -362,7 +362,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     public void testCannotRollupToExistingIndex() throws Exception {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         prepareSourceIndex(sourceIndex);
 
         // Create an empty index with the same name as the rollup index
@@ -381,7 +381,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     public void testRollupEmptyIndex() throws IOException {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         // Source index has been created in the setup() method
         prepareSourceIndex(sourceIndex);
         rollup(sourceIndex, rollupIndex, config);
@@ -414,28 +414,28 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
             )
             .get();
 
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         prepareSourceIndex(sourceIndex);
         Exception exception = expectThrows(RollupActionRequestValidationException.class, () -> rollup(sourceIndex, rollupIndex, config));
         assertThat(exception.getMessage(), containsString("does not contain any metric fields"));
     }
 
     public void testCannotRollupWriteableIndex() {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         // Source index has been created in the setup() method and is empty and still writable
         Exception exception = expectThrows(ElasticsearchException.class, () -> rollup(sourceIndex, rollupIndex, config));
         assertThat(exception.getMessage(), containsString("Rollup requires setting [index.blocks.write = true] for index"));
     }
 
     public void testCannotRollupMissingIndex() {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         IndexNotFoundException exception = expectThrows(IndexNotFoundException.class, () -> rollup("missing-index", rollupIndex, config));
         assertEquals("missing-index", exception.getIndex().getName());
         assertThat(exception.getMessage(), containsString("no such index [missing-index]"));
     }
 
     public void testCannotRollupWhileOtherRollupInProgress() throws Exception {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         SourceSupplier sourceSupplier = () -> XContentFactory.jsonBuilder()
             .startObject()
             .field(FIELD_TIMESTAMP, randomDateForInterval(config.getInterval()))
@@ -461,7 +461,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
                 fail("Rollup failed: " + e.getMessage());
             }
         };
-        client().execute(RollupAction.INSTANCE, new RollupAction.Request(sourceIndex, rollupIndex, config), rollupListener);
+        client().execute(DownsampleAction.INSTANCE, new DownsampleAction.Request(sourceIndex, rollupIndex, config), rollupListener);
         ResourceAlreadyExistsException exception = expectThrows(
             ResourceAlreadyExistsException.class,
             () -> rollup(sourceIndex, rollupIndex, config)
@@ -473,7 +473,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
 
     @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/88800")
     public void testRollupDatastream() throws Exception {
-        RollupActionConfig config = new RollupActionConfig(randomInterval());
+        DownsampleConfig config = new DownsampleConfig(randomInterval());
         String dataStreamName = createDataStream();
 
         final Instant now = Instant.now();
@@ -560,8 +560,10 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
         );
     }
 
-    private void rollup(String sourceIndex, String rollupIndex, RollupActionConfig config) {
-        assertAcked(client().execute(RollupAction.INSTANCE, new RollupAction.Request(sourceIndex, rollupIndex, config)).actionGet());
+    private void rollup(String sourceIndex, String rollupIndex, DownsampleConfig config) {
+        assertAcked(
+            client().execute(DownsampleAction.INSTANCE, new DownsampleAction.Request(sourceIndex, rollupIndex, config)).actionGet()
+        );
     }
 
     private RolloverResponse rollover(String dataStreamName) throws ExecutionException, InterruptedException {
@@ -575,7 +577,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     @SuppressWarnings("unchecked")
-    private void assertRollupIndex(String sourceIndex, String rollupIndex, RollupActionConfig config) throws IOException {
+    private void assertRollupIndex(String sourceIndex, String rollupIndex, DownsampleConfig config) throws IOException {
         // Retrieve field information for the metric fields
         final GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings(sourceIndex).get();
         final Map<String, Object> sourceIndexMappings = getMappingsResponse.mappings()
@@ -640,7 +642,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     private void assertRollupIndexAggregations(
         String sourceIndex,
         String rollupIndex,
-        RollupActionConfig config,
+        DownsampleConfig config,
         Map<String, TimeSeriesParams.MetricType> metricFields,
         Map<String, String> labelFields
     ) {
@@ -739,7 +741,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
 
     @SuppressWarnings("unchecked")
     private void assertFieldMappings(
-        RollupActionConfig config,
+        DownsampleConfig config,
         Map<String, TimeSeriesParams.MetricType> metricFields,
         Map<String, Map<String, Object>> mappings
     ) {
@@ -761,16 +763,16 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
 
     private void assertRollupIndexSettings(String sourceIndex, String rollupIndex, GetIndexResponse indexSettingsResp) {
         // Assert rollup metadata are set in index settings
-        assertEquals("success", indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_ROLLUP_STATUS_KEY));
+        assertEquals("success", indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_DOWNSAMPLE_STATUS_KEY));
 
         assertNotNull(indexSettingsResp.getSetting(sourceIndex, IndexMetadata.SETTING_INDEX_UUID));
-        assertNotNull(indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_ROLLUP_SOURCE_UUID_KEY));
+        assertNotNull(indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID_KEY));
         assertEquals(
             indexSettingsResp.getSetting(sourceIndex, IndexMetadata.SETTING_INDEX_UUID),
-            indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_ROLLUP_SOURCE_UUID_KEY)
+            indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID_KEY)
         );
 
-        assertEquals(sourceIndex, indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_ROLLUP_SOURCE_NAME_KEY));
+        assertEquals(sourceIndex, indexSettingsResp.getSetting(rollupIndex, IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME_KEY));
         assertEquals(
             indexSettingsResp.getSetting(sourceIndex, IndexSettings.MODE.getKey()),
             indexSettingsResp.getSetting(rollupIndex, IndexSettings.MODE.getKey())
@@ -817,7 +819,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
     }
 
     private AggregationBuilder buildAggregations(
-        final RollupActionConfig config,
+        final DownsampleConfig config,
         final Map<String, TimeSeriesParams.MetricType> metrics,
         final Map<String, String> labels,
         final String timestampField

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.search.aggregations.AggregatorTestCase;
 

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

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.rollup.v2;
+package org.elasticsearch.xpack.downsample;
 
 import org.elasticsearch.index.IndexSettings;
 import org.elasticsearch.index.mapper.MappedFieldType;

+ 2 - 2
x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java

@@ -415,8 +415,8 @@ public class Constants {
         "indices:admin/xpack/ccr/forget_follower",
         "indices:admin/xpack/ccr/put_follow",
         "indices:admin/xpack/ccr/unfollow",
-        "indices:admin/xpack/rollup",
-        "indices:admin/xpack/rollup_indexer",
+        "indices:admin/xpack/downsample",
+        "indices:admin/xpack/downsample_indexer",
         "indices:data/read/async_search/delete",
         "indices:data/read/async_search/get",
         "indices:data/read/async_search/submit",