Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSDB] Rename rollup public API to downsample #89809

Merged
merged 11 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
}
}
Expand All @@ -34,7 +34,7 @@
},
"params":{},
"body":{
"description":"The rollup configuration",
"description":"The downsampling configuration",
"required":true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
EnumSet.of(ClusterBlockLevel.WRITE)
);

// TODO: refactor this method after adding more rollup metadata
public boolean isRollupIndex() {
final String sourceIndex = settings.get(IndexMetadata.INDEX_ROLLUP_SOURCE_NAME_KEY);
final String indexRollupStatus = settings.get(IndexMetadata.INDEX_ROLLUP_STATUS_KEY);
final boolean rollupSuccess = IndexMetadata.RollupTaskStatus.SUCCESS.name()
// TODO: refactor this method after adding more downsampling metadata
public boolean isDownsampledIndex() {
final String sourceIndex = settings.get(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_NAME_KEY);
final String indexDownsamplingStatus = settings.get(IndexMetadata.INDEX_DOWNSAMPLE_STATUS_KEY);
final boolean downsamplingSuccess = DownsampleTaskStatus.SUCCESS.name()
.toLowerCase(Locale.ROOT)
.equals(indexRollupStatus != null ? indexRollupStatus.toLowerCase(Locale.ROOT) : IndexMetadata.RollupTaskStatus.UNKNOWN);
return Strings.isNullOrEmpty(sourceIndex) == false && rollupSuccess;
.equals(indexDownsamplingStatus != null ? indexDownsamplingStatus.toLowerCase(Locale.ROOT) : DownsampleTaskStatus.UNKNOWN);
return Strings.isNullOrEmpty(sourceIndex) == false && downsamplingSuccess;
}

public enum State implements Writeable {
Expand Down Expand Up @@ -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<String> INDEX_ROLLUP_SOURCE_UUID = Setting.simpleString(
INDEX_ROLLUP_SOURCE_UUID_KEY,
public static final String INDEX_DOWNSAMPLE_STATUS_KEY = "index.downsample.status";
public static final Setting<String> INDEX_DOWNSAMPLE_SOURCE_UUID = Setting.simpleString(
INDEX_DOWNSAMPLE_SOURCE_UUID_KEY,
Property.IndexScope,
Property.PrivateIndex
);
public static final Setting<String> INDEX_ROLLUP_SOURCE_NAME = Setting.simpleString(
INDEX_ROLLUP_SOURCE_NAME_KEY,
public static final Setting<String> INDEX_DOWNSAMPLE_SOURCE_NAME = Setting.simpleString(
INDEX_DOWNSAMPLE_SOURCE_NAME_KEY,
Property.IndexScope,
Property.PrivateIndex
);

public enum RollupTaskStatus {
public enum DownsampleTaskStatus {
UNKNOWN,
STARTED,
SUCCESS;
Expand All @@ -1158,10 +1158,10 @@ public String toString() {
}
}

public static final Setting<RollupTaskStatus> INDEX_ROLLUP_STATUS = Setting.enumSetting(
RollupTaskStatus.class,
INDEX_ROLLUP_STATUS_KEY,
RollupTaskStatus.UNKNOWN,
public static final Setting<DownsampleTaskStatus> INDEX_DOWNSAMPLE_STATUS = Setting.enumSetting(
DownsampleTaskStatus.class,
INDEX_DOWNSAMPLE_STATUS_KEY,
DownsampleTaskStatus.UNKNOWN,
Property.IndexScope,
Property.InternalIndex
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 + "]"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Class<? extends ElasticsearchException>, Integer> reverse = new HashMap<>();
for (Map.Entry<Integer, Class<? extends ElasticsearchException>> entry : ids.entrySet()) {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -416,7 +415,7 @@ public List<ActionType<? extends ActionResponse>> 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;
Expand Down Expand Up @@ -574,7 +573,7 @@ public List<NamedWriteableRegistry.Entry> 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;
Expand Down
Loading