diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/rollup.rollup.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.downsample.json similarity index 66% rename from rest-api-spec/src/main/resources/rest-api-spec/api/rollup.rollup.json rename to rest-api-spec/src/main/resources/rest-api-spec/api/indices.downsample.json index 3869bf8ac9600..c67d566790ea6 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/rollup.rollup.json +++ b/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 } } diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchException.java b/server/src/main/java/org/elasticsearch/ElasticsearchException.java index 0c4a70cb4327f..51718a226173d 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/server/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -23,7 +23,7 @@ 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 @@ private enum ElasticsearchExceptionHandle { 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 ); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index 2d0975faec9b3..92e4c8b49ce20 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -128,14 +128,14 @@ public class IndexMetadata implements Diffable, 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 Index getResizeSourceIndex() { : 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 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 INDEX_DOWNSAMPLE_SOURCE_UUID = Setting.simpleString( + INDEX_DOWNSAMPLE_SOURCE_UUID_KEY, Property.IndexScope, Property.PrivateIndex ); - public static final Setting INDEX_ROLLUP_SOURCE_NAME = Setting.simpleString( - INDEX_ROLLUP_SOURCE_NAME_KEY, + public static final Setting 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 String toString() { } } - public static final Setting INDEX_ROLLUP_STATUS = Setting.enumSetting( - RollupTaskStatus.class, - INDEX_ROLLUP_STATUS_KEY, - RollupTaskStatus.UNKNOWN, + public static final Setting INDEX_DOWNSAMPLE_STATUS = Setting.enumSetting( + DownsampleTaskStatus.class, + INDEX_DOWNSAMPLE_STATUS_KEY, + DownsampleTaskStatus.UNKNOWN, Property.IndexScope, Property.InternalIndex ); diff --git a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java index 70f3110d5cf8e..60f3b53ee3175 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java +++ b/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, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnRollupIndex.java b/server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnDownsampledIndex.java similarity index 80% rename from server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnRollupIndex.java rename to server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnDownsampledIndex.java index 574cd64448483..183acbf6f6208 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnRollupIndex.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnDownsampledIndex.java @@ -20,13 +20,13 @@ * 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); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java index c83f6a0fb4007..bd1dca9f5e89a 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java @@ -419,7 +419,7 @@ protected ValuesSourceAggregatorFactory innerBuild( ) 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 @@ protected ValuesSourceAggregatorFactory innerBuild( } 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 + "]" ); diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 1cfa86e446002..c1de22a53978e 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -73,7 +73,7 @@ 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 void testIds() { 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, Integer> reverse = new HashMap<>(); for (Map.Entry> entry : ids.entrySet()) { diff --git a/x-pack/plugin/core/src/main/java/module-info.java b/x-pack/plugin/core/src/main/java/module-info.java index b1c8da82a080a..3c76b3e1d009f 100644 --- a/x-pack/plugin/core/src/main/java/module-info.java +++ b/x-pack/plugin/core/src/main/java/module-info.java @@ -53,6 +53,7 @@ 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; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java index 2ea7bf2fdfafc..e6fbe03f09695 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java @@ -40,6 +40,7 @@ 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.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.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.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 List> getClientActions() { // 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 List getNamedWriteables() { // 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; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleAction.java similarity index 68% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleAction.java index 453493c8665d3..b2bc1d197b2ee 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupAction.java +++ b/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.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 static org.elasticsearch.action.ValidateActions.addValidationError; -public class RollupAction extends ActionType { - public static final RollupAction INSTANCE = new RollupAction(); - public static final String NAME = "indices:admin/xpack/rollup"; +public class DownsampleAction extends ActionType { + 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 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 Request() {} 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 IndicesOptions indicesOptions() { @Override public Task createTask(long id, String type, String action, TaskId parentTaskId, Map 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 ActionRequestValidationException validate() { 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 ActionRequestValidationException validate() { 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 boolean equals(Object obj) { } 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 { - protected RequestBuilder(ElasticsearchClient client, RollupAction action) { + protected RequestBuilder(ElasticsearchClient client, DownsampleAction action) { super(client, action, new Request()); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupActionConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleConfig.java similarity index 84% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupActionConfig.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleConfig.java index 7a394d04bdb75..049f6c5436187 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupActionConfig.java +++ b/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.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 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 @@ * 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 PARSER; + private static final ConstructingObjectParser 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 RollupActionConfig(final DateHistogramInterval fixedInterval) { 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 XContentBuilder toXContent(final XContentBuilder builder, final Params pa 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 boolean equals(final Object other) { 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()); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupIndexerAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupIndexerAction.java similarity index 90% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupIndexerAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupIndexerAction.java index b0601ba9a66f2..50c0144732385 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupIndexerAction.java +++ b/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.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 @@ public class RollupIndexerAction extends ActionType { 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 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 Request() {} 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 IndicesOptions indicesOptions() { return rollupRequest.indicesOptions(); } - public RollupAction.Request getRollupRequest() { + public DownsampleAction.Request getRollupRequest() { return rollupRequest; } @@ -97,7 +96,15 @@ public String[] getLabelFields() { @Override public Task createTask(long id, String type, String action, TaskId parentTaskId, Map 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 ActionRequestValidationException validate() { @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 ShardRollupRequest(ShardId shardId, Request request) { } 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() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupTask.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupTask.java similarity index 86% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupTask.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupTask.java index d4f3b43852831..7e05f21244ee3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupTask.java +++ b/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 @@ */ 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 headers ) { super(id, type, action, RollupField.NAME + "_" + rollupIndex, parentTask, headers); @@ -41,7 +40,7 @@ public String getRollupIndex() { return rollupIndex; } - public RollupActionConfig config() { + public DownsampleConfig config() { return config; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupILMAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java similarity index 83% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupILMAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java index 7440dc1118210..0e139160189d9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupILMAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java @@ -19,8 +19,8 @@ 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 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 PARSER = new ConstructingObjectParser<>( + private static final ConstructingObjectParser 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 List toSteps(Client client, String phase, StepKey nextStepKey) { 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 List toSteps(Client client, String phase, StepKey nextStepKey) { 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 List toSteps(Client client, String phase, StepKey nextStepKey) { 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 List toSteps(Client client, String phase, StepKey nextStepKey) { 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 boolean equals(Object o) { 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); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupStep.java index 200ab54292a84..3938b8da90579 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RollupStep.java @@ -18,8 +18,8 @@ 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 void performAction( 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 void performAction( } private void performRollupIndex(String indexName, String rollupIndexName, ActionListener 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) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java index 006fcde7a131f..7bdebb0ea44ca 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java +++ b/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 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() {} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupILMActionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DownsampleActionTests.java similarity index 80% rename from x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupILMActionTests.java rename to x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DownsampleActionTests.java index c82ef50c9be71..52ee1ef5983c4 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupILMActionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DownsampleActionTests.java @@ -15,29 +15,29 @@ 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 { +public class DownsampleActionTests extends AbstractActionTestCase { - 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 instanceReader() { - return RollupILMAction::new; + protected Reader instanceReader() { + return DownsampleAction::new; } @Override @@ -47,7 +47,7 @@ public boolean isSafeAction() { @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 void testToSteps() { 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 void testEqualsAndHashCode() { 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); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyMetadataTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyMetadataTests.java index e5fffcf67fab5..c99aab9e04688 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyMetadataTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyMetadataTests.java @@ -56,7 +56,7 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() { 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 @@ protected NamedXContentRegistry xContentRegistry() { 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); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyTests.java index a5bf70ff61dd0..7a713e180f7b7 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyTests.java @@ -66,7 +66,7 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() { 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 @@ protected NamedXContentRegistry xContentRegistry() { 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 @@ private static Function getNameToActionFunction() { 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 + "]"); }; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupStepTests.java index 264c3e7e3966c..03cfe2a94fbc5 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/RollupStepTests.java @@ -17,9 +17,9 @@ 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 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 @@ private IndexMetadata getIndexMetadata(String index, String lifecycleName, Rollu .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 void testPerformActionCompletedRollupIndexExists() { 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 void testPerformActionCompletedRollupIndexExists() { // 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 void testPerformActionRollupInProgressIndexExists() { 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 void testPerformActionRollupInProgressIndexExists() { // 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 void onFailure(Exception e) { 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 listener = (ActionListener) invocation.getArguments()[2]; assertRollupActionRequest(request, sourceIndex); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleTypeTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleTypeTests.java index aab5ae554a9f4..4a025171da1c0 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleTypeTests.java +++ b/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 void testActionsThatCannotFollowSearchableSnapshot() { 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 void testValidateActionsFollowingSearchableSnapshot() { 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 void testValidateActionsFollowingSearchableSnapshot() { 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 void testValidateActionsFollowingSearchableSnapshot() { 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 void testValidateActionsFollowingSearchableSnapshot() { 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 @@ private ConcurrentMap convertActionNamesToActions(Strin 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 @@ private LifecycleAction getTestAction(String actionName) { 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 + "]"); }; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/action/PutLifecycleRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/action/PutLifecycleRequestTests.java index 8ebdcff579931..810db441e93aa 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/action/PutLifecycleRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/action/PutLifecycleRequestTests.java @@ -15,6 +15,7 @@ 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.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 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() { 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 @@ protected NamedXContentRegistry xContentRegistry() { ), 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); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/RollupActionConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/DownsampleActionConfigTests.java similarity index 57% rename from x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/RollupActionConfigTests.java rename to x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/DownsampleActionConfigTests.java index 4018cd25802da..1e4a5df4147a9 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/RollupActionConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/rollup/DownsampleActionConfigTests.java @@ -10,39 +10,40 @@ 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 { +public class DownsampleActionConfigTests extends AbstractSerializingTestCase { @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 instanceReader() { - return RollupActionConfig::new; + protected Writeable.Reader 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()); } } diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/RollupActionIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java similarity index 90% rename from x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/RollupActionIT.java rename to x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java index d329e713a3b0e..ff607f9e6b29d 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/RollupActionIT.java +++ b/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.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.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.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 void testRollupIndex() throws Exception { 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 void testRollupIndex() throws Exception { ); assertBusy(() -> { Map 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 void testRollupIndexInTheHotPhase() throws Exception { 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 void testRollupIndexInTheHotPhaseAfterRollover() throws Exception { Map 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 phases = Map.of("hot", new Phase("hot", TimeValue.ZERO, hotActions)); LifecyclePolicy lifecyclePolicy = new LifecyclePolicy(policy, phases); @@ -237,14 +238,14 @@ public void testRollupIndexInTheHotPhaseAfterRollover() throws Exception { ); assertBusy(() -> { Map 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 void testTsdbDataStreams() throws Exception { assertBusy(() -> assertFalse("Source index should have been deleted", indexExists(backingIndexName)), 30, TimeUnit.SECONDS); assertBusy(() -> { Map 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 String waitAndGetRollupIndexName(RestClient client, String originalIndexN 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 asMap = responseAsMap(response); if (asMap.size() == 1) { diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java index 849b00464f0fb..627c36627947f 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java @@ -265,7 +265,7 @@ public void testCreateInvalidPolicy() { 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" ) ); diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java index 7b340986251c3..f91d7c5784156 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java @@ -49,6 +49,7 @@ 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; @@ -58,7 +59,6 @@ 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; @@ -335,7 +335,7 @@ private static List xContentEntries() { // 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); diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java index 3a10119c0eb70..9c4c0ec2c8609 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java @@ -22,6 +22,7 @@ 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.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 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() { 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 @@ protected NamedXContentRegistry xContentRegistry() { 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); diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/ReservedLifecycleStateServiceTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/ReservedLifecycleStateServiceTests.java index 40303c87890e6..3ad311497ee11 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/ReservedLifecycleStateServiceTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/ReservedLifecycleStateServiceTests.java @@ -36,6 +36,7 @@ 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.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 @@ protected NamedXContentRegistry xContentRegistry() { 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); diff --git a/x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/aggregations/support/AggregateMetricsValuesSourceType.java b/x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/aggregations/support/AggregateMetricsValuesSourceType.java index daf8990c5fb8f..48b70a3741c09 100644 --- a/x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/aggregations/support/AggregateMetricsValuesSourceType.java +++ b/x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/aggregations/support/AggregateMetricsValuesSourceType.java @@ -10,7 +10,7 @@ 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 diff --git a/x-pack/plugin/rollup/qa/rest/build.gradle b/x-pack/plugin/rollup/qa/rest/build.gradle index 59d9d9e4c3033..95438bc08f1eb 100644 --- a/x-pack/plugin/rollup/qa/rest/build.gradle +++ b/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") } diff --git a/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/10_basic.yml b/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/10_basic.yml index 6c062ce4f4507..73a5eff613d3a 100644 --- a/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/10_basic.yml +++ b/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" diff --git a/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/20_unsupported_aggs.yml b/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/20_unsupported_aggs.yml index 4db6f6a925712..f58985189b9e0 100644 --- a/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/20_unsupported_aggs.yml +++ b/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]" } diff --git a/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/30_date_histogram.yml b/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/30_date_histogram.yml index 87b882db3d020..910d14accc8f5 100644 --- a/x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/30_date_histogram.yml +++ b/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" diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/AbstractRollupFieldProducer.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AbstractRollupFieldProducer.java similarity index 96% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/AbstractRollupFieldProducer.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AbstractRollupFieldProducer.java index 1b1ff0189bdc8..21afa1859a190 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/AbstractRollupFieldProducer.java +++ b/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. diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/FieldValueFetcher.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java similarity index 99% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/FieldValueFetcher.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java index 9911eae3b5491..8bf75cdf873ae 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/FieldValueFetcher.java +++ b/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; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/LabelFieldProducer.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/LabelFieldProducer.java similarity index 98% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/LabelFieldProducer.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/LabelFieldProducer.java index 798cc785a0f19..c10eeaec5dc91 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/LabelFieldProducer.java +++ b/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; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/MetricFieldProducer.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/MetricFieldProducer.java similarity index 99% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/MetricFieldProducer.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/MetricFieldProducer.java index 8fec3c7ab6e4c..5164e6d8518df 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/MetricFieldProducer.java +++ b/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; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RestRollupAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RestDownsampleAction.java similarity index 54% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RestRollupAction.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RestDownsampleAction.java index 4182a06fa3299..e48411a40089c 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RestRollupAction.java +++ b/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 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"; } } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RollupShardIndexer.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java similarity index 98% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RollupShardIndexer.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java index 7f55d37f128e6..b71bc6fc9ceed 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RollupShardIndexer.java +++ b/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.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 diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TimeseriesFieldTypeHelper.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TimeseriesFieldTypeHelper.java similarity index 98% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TimeseriesFieldTypeHelper.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TimeseriesFieldTypeHelper.java index 0bb73a5c5e290..21cd5a27aa2b7 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TimeseriesFieldTypeHelper.java +++ b/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; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupAction.java similarity index 94% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupAction.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupAction.java index 80c8f84b63823..90847c913a5f4 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupAction.java +++ b/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.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 @@ * - calling {@link TransportRollupIndexerAction} to index rollup documents * - cleaning up state */ -public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction { +public class TransportRollupAction extends AcknowledgedTransportMasterNodeAction { private static final Logger logger = LogManager.getLogger(TransportRollupAction.class); @@ -120,12 +120,12 @@ public TransportRollupAction( 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 TransportRollupAction( @Override protected void masterOperation( Task task, - RollupAction.Request request, + DownsampleAction.Request request, ClusterState state, ActionListener listener ) { @@ -177,7 +177,7 @@ protected void masterOperation( 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 @@ protected void masterOperation( 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 @@ protected void masterOperation( 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 @@ protected void masterOperation( } @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 @@ protected ClusterBlockException checkBlock(RollupAction.Request request, Cluster */ public static String createRollupIndexMapping( final TimeseriesFieldTypeHelper helper, - final RollupActionConfig config, + final DownsampleConfig config, final MapperService mapperService, final Map sourceIndexMappings ) throws IOException { @@ -437,7 +437,7 @@ private static void addMetricFields( }); } - 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 @@ private static void addTimestampField(final RollupActionConfig config, final XCo .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 @@ private IndexMetadata.Builder copyIndexMetadata(IndexMetadata sourceIndexMetadat * 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 @@ private void createRollupIndex( String rollupIndexName, IndexMetadata sourceIndexMetadata, String mapping, - RollupAction.Request request, + DownsampleAction.Request request, ActionListener listener ) { CreateIndexClusterStateUpdateRequest createIndexClusterStateUpdateRequest = new CreateIndexClusterStateUpdateRequest( @@ -557,7 +557,7 @@ private void createRollupIndex( .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 ClusterState execute(ClusterState currentState) throws Exception { }, ClusterStateTaskConfig.build(Priority.URGENT, request.masterNodeTimeout()), STATE_UPDATE_TASK_EXECUTOR); } - private void updateRollupMetadata(String rollupIndexName, RollupAction.Request request, ActionListener listener) { + private void updateRollupMetadata( + String rollupIndexName, + DownsampleAction.Request request, + ActionListener listener + ) { // 6. Mark rollup index as "completed successfully" ("index.rollup.status": "success") clusterService.submitStateUpdateTask( "update-rollup-metadata [" + rollupIndexName + "]", @@ -590,7 +594,7 @@ public ClusterState execute(ClusterState currentState) { 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 ); diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupIndexerAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupIndexerAction.java similarity index 98% rename from x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupIndexerAction.java rename to x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupIndexerAction.java index 76d07e827a8a4..e7ccf37edde29 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/TransportRollupIndexerAction.java +++ b/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.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; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java index 79890f6ece1f6..8c7c6708e06cc 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java @@ -38,18 +38,21 @@ 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; @@ -67,9 +70,6 @@ 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; @@ -144,7 +144,7 @@ public List getRestHandlers( // TSDB Downsampling / Rollup if (IndexSettings.isTimeSeriesModeEnabled()) { - handlers.add(new RestRollupAction()); + handlers.add(new RestDownsampleAction()); } return handlers; @@ -169,7 +169,7 @@ public List getRestHandlers( 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; diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java similarity index 95% rename from x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java rename to x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java index 55e21d1c4c282..74da67f74a607 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java +++ b/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.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.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 void setup() { } 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 void testCopyIndexSettings() throws IOException { 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 void testCopyIndexSettings() throws IOException { } 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 void testNullSourceIndexName() { } 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 void testNullRollupConfig() { 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 void testRollupSparseMetrics() throws IOException { } 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 void testCannotRollupToExistingIndex() throws Exception { } 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 void testCannotRollupIndexWithNoMetrics() { ) .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 void onFailure(Exception e) { 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 void onFailure(Exception e) { @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 @@ private void prepareSourceIndex(String sourceIndex) { ); } - 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 @@ private Aggregations aggregate(final String index, AggregationBuilder aggregatio } @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 sourceIndexMappings = getMappingsResponse.mappings() @@ -640,7 +642,7 @@ private void assertRollupIndex(String sourceIndex, String rollupIndex, RollupAct private void assertRollupIndexAggregations( String sourceIndex, String rollupIndex, - RollupActionConfig config, + DownsampleConfig config, Map metricFields, Map labelFields ) { @@ -739,7 +741,7 @@ private void assertRollupIndexAggregations( @SuppressWarnings("unchecked") private void assertFieldMappings( - RollupActionConfig config, + DownsampleConfig config, Map metricFields, Map> mappings ) { @@ -761,16 +763,16 @@ private void assertFieldMappings( 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 @@ private void assertRollupIndexSettings(String sourceIndex, String rollupIndex, G } private AggregationBuilder buildAggregations( - final RollupActionConfig config, + final DownsampleConfig config, final Map metrics, final Map labels, final String timestampField diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/LabelFieldProducerTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/LabelFieldProducerTests.java similarity index 98% rename from x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/LabelFieldProducerTests.java rename to x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/LabelFieldProducerTests.java index 8ac6df94131bf..ee88dc83bbb18 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/LabelFieldProducerTests.java +++ b/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; diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/MetricFieldProducerTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/MetricFieldProducerTests.java similarity index 99% rename from x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/MetricFieldProducerTests.java rename to x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/MetricFieldProducerTests.java index 670858486f3b0..d27008729ae2c 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/MetricFieldProducerTests.java +++ b/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; diff --git a/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java b/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java index 14d81525a55a8..ccc56e8ffc986 100644 --- a/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java +++ b/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",