Skip to content

Commit 28294e6

Browse files
authored
Replace rollup usages in downsample code. (#93697)
Replace rollup usages with downsample usages in downsample code base. Also in ilm integration code. This avoids confusion of what is what. Rollup name should only be used for rollup v1.
1 parent 7785cde commit 28294e6

24 files changed

+180
-190
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/LifecycleExecutionState.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public record LifecycleExecutionState(
3636
String snapshotName,
3737
String shrinkIndexName,
3838
String snapshotIndexName,
39-
String rollupIndexName
39+
String downsampleIndexName
4040
) {
4141

4242
public static final String ILM_CUSTOM_METADATA_KEY = "ilm";
@@ -57,7 +57,7 @@ public record LifecycleExecutionState(
5757
private static final String SNAPSHOT_REPOSITORY = "snapshot_repository";
5858
private static final String SNAPSHOT_INDEX_NAME = "snapshot_index_name";
5959
private static final String SHRINK_INDEX_NAME = "shrink_index_name";
60-
private static final String ROLLUP_INDEX_NAME = "rollup_index_name";
60+
private static final String DOWNSAMPLE_INDEX_NAME = "rollup_index_name";
6161

6262
public static final LifecycleExecutionState EMPTY_STATE = LifecycleExecutionState.builder().build();
6363

@@ -81,7 +81,7 @@ public static Builder builder(LifecycleExecutionState state) {
8181
.setSnapshotName(state.snapshotName)
8282
.setShrinkIndexName(state.shrinkIndexName)
8383
.setSnapshotIndexName(state.snapshotIndexName)
84-
.setRollupIndexName(state.rollupIndexName)
84+
.setRollupIndexName(state.downsampleIndexName)
8585
.setStepTime(state.stepTime);
8686
}
8787

@@ -187,7 +187,7 @@ public static LifecycleExecutionState fromCustomMetadata(Map<String, String> cus
187187
if (snapshotIndexName != null) {
188188
builder.setSnapshotIndexName(snapshotIndexName);
189189
}
190-
String rollupIndexName = customData.get(ROLLUP_INDEX_NAME);
190+
String rollupIndexName = customData.get(DOWNSAMPLE_INDEX_NAME);
191191
if (rollupIndexName != null) {
192192
builder.setRollupIndexName(rollupIndexName);
193193
}
@@ -250,8 +250,8 @@ public Map<String, String> asMap() {
250250
if (snapshotIndexName != null) {
251251
result.put(SNAPSHOT_INDEX_NAME, snapshotIndexName);
252252
}
253-
if (rollupIndexName != null) {
254-
result.put(ROLLUP_INDEX_NAME, rollupIndexName);
253+
if (downsampleIndexName != null) {
254+
result.put(DOWNSAMPLE_INDEX_NAME, downsampleIndexName);
255255
}
256256
return Collections.unmodifiableMap(result);
257257
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.elasticsearch.xpack.core.async.DeleteAsyncResultAction;
4040
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
4141
import org.elasticsearch.xpack.core.datastreams.DataStreamFeatureSetUsage;
42-
import org.elasticsearch.xpack.core.downsample.RollupIndexerAction;
42+
import org.elasticsearch.xpack.core.downsample.DownsampleIndexerAction;
4343
import org.elasticsearch.xpack.core.enrich.EnrichFeatureSetUsage;
4444
import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus;
4545
import org.elasticsearch.xpack.core.eql.EqlFeatureSetUsage;
@@ -410,7 +410,7 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
410410
// Terms enum API
411411
TermsEnumAction.INSTANCE,
412412
// TSDB Downsampling
413-
RollupIndexerAction.INSTANCE,
413+
DownsampleIndexerAction.INSTANCE,
414414
org.elasticsearch.xpack.core.downsample.DownsampleAction.INSTANCE
415415
);
416416
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public IndicesOptions indicesOptions() {
6767

6868
@Override
6969
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
70-
return new RollupTask(id, type, action, parentTaskId, targetIndex, downsampleConfig, headers);
70+
return new DownsampleTask(id, type, action, parentTaskId, targetIndex, downsampleConfig, headers);
7171
}
7272

7373
@Override

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupIndexerAction.java renamed to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleIndexerAction.java

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.elasticsearch.xpack.core.downsample;
88

9-
import org.elasticsearch.action.ActionRequestBuilder;
109
import org.elasticsearch.action.ActionRequestValidationException;
1110
import org.elasticsearch.action.ActionType;
1211
import org.elasticsearch.action.IndicesRequest;
@@ -15,7 +14,6 @@
1514
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
1615
import org.elasticsearch.action.support.broadcast.BroadcastShardRequest;
1716
import org.elasticsearch.action.support.broadcast.BroadcastShardResponse;
18-
import org.elasticsearch.client.internal.ElasticsearchClient;
1917
import org.elasticsearch.common.io.stream.StreamInput;
2018
import org.elasticsearch.common.io.stream.StreamOutput;
2119
import org.elasticsearch.common.io.stream.Writeable;
@@ -31,29 +29,29 @@
3129
import java.util.Map;
3230
import java.util.Objects;
3331

34-
public class RollupIndexerAction extends ActionType<RollupIndexerAction.Response> {
32+
public class DownsampleIndexerAction extends ActionType<DownsampleIndexerAction.Response> {
3533

36-
public static final RollupIndexerAction INSTANCE = new RollupIndexerAction();
34+
public static final DownsampleIndexerAction INSTANCE = new DownsampleIndexerAction();
3735
public static final String NAME = "indices:admin/xpack/downsample_indexer";
3836

39-
private RollupIndexerAction() {
40-
super(NAME, RollupIndexerAction.Response::new);
37+
private DownsampleIndexerAction() {
38+
super(NAME, DownsampleIndexerAction.Response::new);
4139
}
4240

4341
public static class Request extends BroadcastRequest<Request> implements IndicesRequest, ToXContentObject {
44-
private DownsampleAction.Request rollupRequest;
42+
private DownsampleAction.Request downsampleRequest;
4543
private String[] dimensionFields;
4644
private String[] metricFields;
4745
private String[] labelFields;
4846

4947
public Request(
50-
DownsampleAction.Request rollupRequest,
48+
DownsampleAction.Request downsampleRequest,
5149
final String[] dimensionFields,
5250
final String[] metricFields,
5351
final String[] labelFields
5452
) {
55-
super(rollupRequest.indices());
56-
this.rollupRequest = rollupRequest;
53+
super(downsampleRequest.indices());
54+
this.downsampleRequest = downsampleRequest;
5755
this.dimensionFields = dimensionFields;
5856
this.metricFields = metricFields;
5957
this.labelFields = labelFields;
@@ -63,24 +61,24 @@ public Request() {}
6361

6462
public Request(StreamInput in) throws IOException {
6563
super(in);
66-
this.rollupRequest = new DownsampleAction.Request(in);
64+
this.downsampleRequest = new DownsampleAction.Request(in);
6765
this.dimensionFields = in.readStringArray();
6866
this.metricFields = in.readStringArray();
6967
this.labelFields = in.readStringArray();
7068
}
7169

7270
@Override
7371
public String[] indices() {
74-
return rollupRequest.indices();
72+
return downsampleRequest.indices();
7573
}
7674

7775
@Override
7876
public IndicesOptions indicesOptions() {
79-
return rollupRequest.indicesOptions();
77+
return downsampleRequest.indicesOptions();
8078
}
8179

82-
public DownsampleAction.Request getRollupRequest() {
83-
return rollupRequest;
80+
public DownsampleAction.Request getDownsampleRequest() {
81+
return downsampleRequest;
8482
}
8583

8684
public String[] getDimensionFields() {
@@ -97,21 +95,21 @@ public String[] getLabelFields() {
9795

9896
@Override
9997
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
100-
return new RollupTask(
98+
return new DownsampleTask(
10199
id,
102100
type,
103101
action,
104102
parentTaskId,
105-
rollupRequest.getTargetIndex(),
106-
rollupRequest.getDownsampleConfig(),
103+
downsampleRequest.getTargetIndex(),
104+
downsampleRequest.getDownsampleConfig(),
107105
headers
108106
);
109107
}
110108

111109
@Override
112110
public void writeTo(StreamOutput out) throws IOException {
113111
super.writeTo(out);
114-
rollupRequest.writeTo(out);
112+
downsampleRequest.writeTo(out);
115113
out.writeStringArray(dimensionFields);
116114
out.writeStringArray(metricFields);
117115
out.writeStringArray(labelFields);
@@ -125,7 +123,7 @@ public ActionRequestValidationException validate() {
125123
@Override
126124
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
127125
builder.startObject();
128-
builder.field("downsample_request", rollupRequest);
126+
builder.field("downsample_request", downsampleRequest);
129127
builder.array("dimension_fields", dimensionFields);
130128
builder.array("metric_fields", metricFields);
131129
builder.array("label_fields", labelFields);
@@ -135,7 +133,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
135133

136134
@Override
137135
public int hashCode() {
138-
int result = rollupRequest.hashCode();
136+
int result = downsampleRequest.hashCode();
139137
result = 31 * result + Arrays.hashCode(dimensionFields);
140138
result = 31 * result + Arrays.hashCode(metricFields);
141139
result = 31 * result + Arrays.hashCode(labelFields);
@@ -147,20 +145,13 @@ public boolean equals(Object o) {
147145
if (this == o) return true;
148146
if (o == null || getClass() != o.getClass()) return false;
149147
Request request = (Request) o;
150-
if (rollupRequest.equals(request.rollupRequest) == false) return false;
148+
if (downsampleRequest.equals(request.downsampleRequest) == false) return false;
151149
if (Arrays.equals(dimensionFields, request.dimensionFields) == false) return false;
152150
if (Arrays.equals(labelFields, request.labelFields) == false) return false;
153151
return Arrays.equals(metricFields, request.metricFields);
154152
}
155153
}
156154

157-
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
158-
159-
protected RequestBuilder(ElasticsearchClient client, RollupIndexerAction action) {
160-
super(client, action, new Request());
161-
}
162-
}
163-
164155
public static class Response extends BroadcastResponse implements Writeable {
165156
private final boolean created;
166157

@@ -221,25 +212,25 @@ public int hashCode() {
221212
/**
222213
* Internal rollup request executed directly against a specific index shard.
223214
*/
224-
public static class ShardRollupRequest extends BroadcastShardRequest {
215+
public static class ShardDownsampleRequest extends BroadcastShardRequest {
225216
private final Request request;
226217

227-
public ShardRollupRequest(StreamInput in) throws IOException {
218+
public ShardDownsampleRequest(StreamInput in) throws IOException {
228219
super(in);
229220
this.request = new Request(in);
230221
}
231222

232-
public ShardRollupRequest(ShardId shardId, Request request) {
223+
public ShardDownsampleRequest(ShardId shardId, Request request) {
233224
super(shardId, request);
234225
this.request = request;
235226
}
236227

237228
public String getRollupIndex() {
238-
return request.getRollupRequest().getTargetIndex();
229+
return request.getDownsampleRequest().getTargetIndex();
239230
}
240231

241232
public DownsampleConfig getRollupConfig() {
242-
return request.getRollupRequest().getDownsampleConfig();
233+
return request.getDownsampleRequest().getDownsampleConfig();
243234
}
244235

245236
public String[] getDimensionFields() {
@@ -267,24 +258,24 @@ public Task createTask(long id, String type, String action, TaskId parentTaskId,
267258
type,
268259
action,
269260
parentTaskId,
270-
request.rollupRequest.getSourceIndex(),
271-
request.rollupRequest.getDownsampleConfig(),
261+
request.downsampleRequest.getSourceIndex(),
262+
request.downsampleRequest.getDownsampleConfig(),
272263
headers,
273264
shardId()
274265
);
275266
}
276267
}
277268

278-
public static class ShardRollupResponse extends BroadcastShardResponse {
269+
public static class ShardDownsampleResponse extends BroadcastShardResponse {
279270

280271
private final long numIndexed;
281272

282-
public ShardRollupResponse(ShardId shardId, long numIndexed) {
273+
public ShardDownsampleResponse(ShardId shardId, long numIndexed) {
283274
super(shardId);
284275
this.numIndexed = numIndexed;
285276
}
286277

287-
public ShardRollupResponse(StreamInput in) throws IOException {
278+
public ShardDownsampleResponse(StreamInput in) throws IOException {
288279
super(in);
289280
numIndexed = in.readLong();
290281
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/RollupTask.java renamed to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/downsample/DownsampleTask.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,37 @@
99
import org.elasticsearch.tasks.CancellableTask;
1010
import org.elasticsearch.tasks.TaskId;
1111
import org.elasticsearch.xpack.core.rollup.RollupField;
12-
import org.elasticsearch.xpack.core.rollup.job.RollupJobStatus;
1312

1413
import java.util.Map;
1514

1615
/**
1716
* This class contains the high-level logic that drives the rollup job. The allocated task contains transient state
1817
* which drives the indexing, and periodically updates it's parent PersistentTask with the indexing's current position.
1918
*/
20-
public class RollupTask extends CancellableTask {
21-
private String rollupIndex;
22-
private DownsampleConfig config;
23-
private RollupJobStatus status;
19+
public class DownsampleTask extends CancellableTask {
20+
private final String downsampleIndex;
21+
private final DownsampleConfig config;
2422

25-
RollupTask(
23+
DownsampleTask(
2624
long id,
2725
String type,
2826
String action,
2927
TaskId parentTask,
30-
String rollupIndex,
28+
String downsampleIndex,
3129
DownsampleConfig config,
3230
Map<String, String> headers
3331
) {
34-
super(id, type, action, RollupField.NAME + "_" + rollupIndex, parentTask, headers);
35-
this.rollupIndex = rollupIndex;
32+
super(id, type, action, RollupField.NAME + "_" + downsampleIndex, parentTask, headers);
33+
this.downsampleIndex = downsampleIndex;
3634
this.config = config;
3735
}
3836

39-
public String getRollupIndex() {
40-
return rollupIndex;
37+
public String getDownsampleIndex() {
38+
return downsampleIndex;
4139
}
4240

4341
public DownsampleConfig config() {
4442
return config;
4543
}
4644

47-
@Override
48-
public Status getStatus() {
49-
return status;
50-
}
51-
52-
@Override
53-
public void onCancelled() {
54-
// TODO(talevy): make things cancellable
55-
}
5645
}

0 commit comments

Comments
 (0)