Skip to content

Commit 3195327

Browse files
committed
Rename downsampling to downsampling rounds
1 parent 097115d commit 3195327

File tree

16 files changed

+111
-103
lines changed

16 files changed

+111
-103
lines changed

modules/data-streams/src/test/java/org/elasticsearch/datastreams/MetadataIndexTemplateServiceTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void testLifecycleComposition() {
157157
// Defaults to true
158158
assertThat(result.enabled(), equalTo(true));
159159
assertThat(result.dataRetention(), equalTo(lifecycle.dataRetention().get()));
160-
assertThat(result.downsampling(), equalTo(lifecycle.downsampling().get()));
160+
assertThat(result.downsamplingRounds(), equalTo(lifecycle.downsamplingRounds().get()));
161161
}
162162
// If the last lifecycle is missing a property (apart from enabled) we keep the latest from the previous ones
163163
// Enabled is always true unless it's explicitly set to false
@@ -171,7 +171,7 @@ public void testLifecycleComposition() {
171171
DataStreamLifecycle result = composeDataLifecycles(lifecycles).build();
172172
assertThat(result.enabled(), equalTo(true));
173173
assertThat(result.dataRetention(), equalTo(lifecycle.dataRetention().get()));
174-
assertThat(result.downsampling(), equalTo(lifecycle.downsampling().get()));
174+
assertThat(result.downsamplingRounds(), equalTo(lifecycle.downsamplingRounds().get()));
175175
}
176176
// If both lifecycle have all properties, then the latest one overwrites all the others
177177
{
@@ -189,7 +189,7 @@ public void testLifecycleComposition() {
189189
DataStreamLifecycle result = composeDataLifecycles(lifecycles).build();
190190
assertThat(result.enabled(), equalTo(lifecycle2.enabled()));
191191
assertThat(result.dataRetention(), equalTo(lifecycle2.dataRetention().get()));
192-
assertThat(result.downsampling(), equalTo(lifecycle2.downsampling().get()));
192+
assertThat(result.downsamplingRounds(), equalTo(lifecycle2.downsamplingRounds().get()));
193193
}
194194
}
195195

modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ public void testDownsampling() throws Exception {
12281228
.put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES)
12291229
.put("index.routing_path", "@timestamp"),
12301230
DataStreamLifecycle.dataLifecycleBuilder()
1231-
.downsampling(List.of(new DownsamplingRound(TimeValue.timeValueMillis(0), new DateHistogramInterval("5m"))))
1231+
.downsamplingRounds(List.of(new DownsamplingRound(TimeValue.timeValueMillis(0), new DateHistogramInterval("5m"))))
12321232
.dataRetention(TimeValue.MAX_VALUE)
12331233
.build(),
12341234
now
@@ -1375,7 +1375,7 @@ public void testDownsamplingWhenTargetIndexNameClashYieldsException() throws Exc
13751375
.put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES)
13761376
.put("index.routing_path", "@timestamp"),
13771377
DataStreamLifecycle.dataLifecycleBuilder()
1378-
.downsampling(List.of(new DownsamplingRound(TimeValue.timeValueMillis(0), new DateHistogramInterval("5m"))))
1378+
.downsamplingRounds(List.of(new DownsamplingRound(TimeValue.timeValueMillis(0), new DateHistogramInterval("5m"))))
13791379
.dataRetention(TimeValue.MAX_VALUE)
13801380
.build(),
13811381
now
@@ -1658,7 +1658,7 @@ private ClusterState downsampleSetup(ProjectId projectId, String dataStreamName,
16581658
settings(IndexVersion.current()).put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES)
16591659
.put("index.routing_path", "@timestamp"),
16601660
DataStreamLifecycle.dataLifecycleBuilder()
1661-
.downsampling(List.of(new DownsamplingRound(TimeValue.timeValueMillis(0), new DateHistogramInterval("5m"))))
1661+
.downsamplingRounds(List.of(new DownsamplingRound(TimeValue.timeValueMillis(0), new DateHistogramInterval("5m"))))
16621662
.dataRetention(TimeValue.timeValueMillis(1))
16631663
.build(),
16641664
now

server/src/main/java/org/elasticsearch/action/datastreams/lifecycle/PutDataStreamLifecycleAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ public Request(
145145
String[] names,
146146
@Nullable TimeValue dataRetention,
147147
@Nullable Boolean enabled,
148-
@Nullable List<DataStreamLifecycle.DownsamplingRound> downsampling
148+
@Nullable List<DataStreamLifecycle.DownsamplingRound> downsamplingRounds
149149
) {
150150
super(masterNodeTimeout, ackTimeout);
151151
this.names = names;
152152
this.lifecycle = DataStreamLifecycle.dataLifecycleBuilder()
153153
.dataRetention(dataRetention)
154154
.enabled(enabled == null || enabled)
155-
.downsampling(downsampling)
155+
.downsamplingRounds(downsamplingRounds)
156156
.build();
157157
}
158158

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ public List<DownsamplingRound> getDownsamplingRoundsFor(
12471247
LongSupplier nowSupplier
12481248
) {
12491249
assert backingIndices.indices.contains(index) : "the provided index must be a backing index for this datastream";
1250-
if (lifecycle == null || lifecycle.downsampling() == null) {
1250+
if (lifecycle == null || lifecycle.downsamplingRounds() == null) {
12511251
return List.of();
12521252
}
12531253

@@ -1260,8 +1260,8 @@ public List<DownsamplingRound> getDownsamplingRoundsFor(
12601260
if (indexGenerationTime != null) {
12611261
long nowMillis = nowSupplier.getAsLong();
12621262
long indexGenerationTimeMillis = indexGenerationTime.millis();
1263-
List<DownsamplingRound> orderedRoundsForIndex = new ArrayList<>(lifecycle.downsampling().size());
1264-
for (DownsamplingRound round : lifecycle.downsampling()) {
1263+
List<DownsamplingRound> orderedRoundsForIndex = new ArrayList<>(lifecycle.downsamplingRounds().size());
1264+
for (DownsamplingRound round : lifecycle.downsamplingRounds()) {
12651265
if (nowMillis >= indexGenerationTimeMillis + round.after().getMillis()) {
12661266
orderedRoundsForIndex.add(round);
12671267
}

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

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static boolean isDataStreamsLifecycleOnlyMode(final Settings settings) {
143143
@Nullable
144144
private final TimeValue dataRetention;
145145
@Nullable
146-
private final List<DownsamplingRound> downsampling;
146+
private final List<DownsamplingRound> downsamplingRounds;
147147

148148
/**
149149
* This constructor is visible for testing, please use {@link DataStreamLifecycle#createDataLifecycle(Boolean, TimeValue, List)} or
@@ -153,16 +153,16 @@ public static boolean isDataStreamsLifecycleOnlyMode(final Settings settings) {
153153
LifecycleType lifecycleType,
154154
@Nullable Boolean enabled,
155155
@Nullable TimeValue dataRetention,
156-
@Nullable List<DownsamplingRound> downsampling
156+
@Nullable List<DownsamplingRound> downsamplingRounds
157157
) {
158158
this.lifecycleType = lifecycleType;
159159
this.enabled = enabled == null || enabled;
160160
this.dataRetention = dataRetention;
161-
if (lifecycleType == LifecycleType.FAILURES && downsampling != null) {
161+
if (lifecycleType == LifecycleType.FAILURES && downsamplingRounds != null) {
162162
throw new IllegalArgumentException(DOWNSAMPLING_NOT_SUPPORTED_ERROR_MESSAGE);
163163
}
164-
DownsamplingRound.validateRounds(downsampling);
165-
this.downsampling = downsampling;
164+
DownsamplingRound.validateRounds(downsamplingRounds);
165+
this.downsamplingRounds = downsamplingRounds;
166166
}
167167

168168
/**
@@ -308,8 +308,8 @@ public void addWarningHeaderIfDataRetentionNotEffective(
308308
* not configured then it returns null.
309309
*/
310310
@Nullable
311-
public List<DownsamplingRound> downsampling() {
312-
return downsampling;
311+
public List<DownsamplingRound> downsamplingRounds() {
312+
return downsamplingRounds;
313313
}
314314

315315
@Override
@@ -320,13 +320,13 @@ public boolean equals(Object o) {
320320
final DataStreamLifecycle that = (DataStreamLifecycle) o;
321321
return lifecycleType == that.lifecycleType
322322
&& Objects.equals(dataRetention, that.dataRetention)
323-
&& Objects.equals(downsampling, that.downsampling)
323+
&& Objects.equals(downsamplingRounds, that.downsamplingRounds)
324324
&& enabled == that.enabled;
325325
}
326326

327327
@Override
328328
public int hashCode() {
329-
return Objects.hash(lifecycleType, enabled, dataRetention, downsampling);
329+
return Objects.hash(lifecycleType, enabled, dataRetention, downsamplingRounds);
330330
}
331331

332332
@Override
@@ -341,9 +341,9 @@ public void writeTo(StreamOutput out) throws IOException {
341341
}
342342
if (out.getTransportVersion().onOrAfter(ADDED_ENABLED_FLAG_VERSION)) {
343343
if (out.getTransportVersion().supports(INTRODUCE_LIFECYCLE_TEMPLATE)) {
344-
out.writeOptionalCollection(downsampling);
344+
out.writeOptionalCollection(downsamplingRounds);
345345
} else {
346-
writeLegacyOptionalValue(downsampling, out, StreamOutput::writeCollection);
346+
writeLegacyOptionalValue(downsamplingRounds, out, StreamOutput::writeCollection);
347347
}
348348
out.writeBoolean(enabled());
349349
}
@@ -364,13 +364,13 @@ public DataStreamLifecycle(StreamInput in) throws IOException {
364364
}
365365
if (in.getTransportVersion().onOrAfter(ADDED_ENABLED_FLAG_VERSION)) {
366366
if (in.getTransportVersion().supports(INTRODUCE_LIFECYCLE_TEMPLATE)) {
367-
downsampling = in.readOptionalCollectionAsList(DownsamplingRound::read);
367+
downsamplingRounds = in.readOptionalCollectionAsList(DownsamplingRound::read);
368368
} else {
369-
downsampling = readLegacyOptionalValue(in, is -> is.readCollectionAsList(DownsamplingRound::read));
369+
downsamplingRounds = readLegacyOptionalValue(in, is -> is.readCollectionAsList(DownsamplingRound::read));
370370
}
371371
enabled = in.readBoolean();
372372
} else {
373-
downsampling = null;
373+
downsamplingRounds = null;
374374
enabled = true;
375375
}
376376
lifecycleType = in.getTransportVersion().supports(INTRODUCE_FAILURES_LIFECYCLE) ? LifecycleType.read(in) : LifecycleType.DATA;
@@ -426,8 +426,8 @@ public String toString() {
426426
+ enabled
427427
+ ", dataRetention="
428428
+ dataRetention
429-
+ ", downsampling="
430-
+ downsampling
429+
+ ", downsamplingRounds="
430+
+ downsamplingRounds
431431
+ '}';
432432
}
433433

@@ -466,8 +466,8 @@ public XContentBuilder toXContent(
466466
}
467467
}
468468

469-
if (downsampling != null) {
470-
builder.field(DOWNSAMPLING_FIELD.getPreferredName(), downsampling);
469+
if (downsamplingRounds != null) {
470+
builder.field(DOWNSAMPLING_FIELD.getPreferredName(), downsamplingRounds);
471471
}
472472
if (rolloverConfiguration != null) {
473473
builder.field(ROLLOVER_FIELD.getPreferredName());
@@ -667,7 +667,7 @@ public record Template(
667667
LifecycleType lifecycleType,
668668
boolean enabled,
669669
ResettableValue<TimeValue> dataRetention,
670-
ResettableValue<List<DataStreamLifecycle.DownsamplingRound>> downsampling
670+
ResettableValue<List<DataStreamLifecycle.DownsamplingRound>> downsamplingRounds
671671
) implements ToXContentObject, Writeable {
672672

673673
Template(
@@ -680,11 +680,11 @@ public record Template(
680680
}
681681

682682
public Template {
683-
if (lifecycleType == LifecycleType.FAILURES && downsampling.get() != null) {
683+
if (lifecycleType == LifecycleType.FAILURES && downsamplingRounds.get() != null) {
684684
throw new IllegalArgumentException(DOWNSAMPLING_NOT_SUPPORTED_ERROR_MESSAGE);
685685
}
686-
if (downsampling.isDefined() && downsampling.get() != null) {
687-
DownsamplingRound.validateRounds(downsampling.get());
686+
if (downsamplingRounds.isDefined() && downsamplingRounds.get() != null) {
687+
DownsamplingRound.validateRounds(downsamplingRounds.get());
688688
}
689689
}
690690

@@ -736,9 +736,9 @@ public void writeTo(StreamOutput out) throws IOException {
736736
}
737737
if (out.getTransportVersion().onOrAfter(ADDED_ENABLED_FLAG_VERSION)) {
738738
if (out.getTransportVersion().supports(INTRODUCE_LIFECYCLE_TEMPLATE)) {
739-
ResettableValue.write(out, downsampling, StreamOutput::writeCollection);
739+
ResettableValue.write(out, downsamplingRounds, StreamOutput::writeCollection);
740740
} else {
741-
writeLegacyValue(out, downsampling, StreamOutput::writeCollection);
741+
writeLegacyValue(out, downsamplingRounds, StreamOutput::writeCollection);
742742
}
743743
out.writeBoolean(enabled);
744744
}
@@ -839,7 +839,7 @@ public XContentBuilder toXContent(
839839
builder.startObject();
840840
builder.field(ENABLED_FIELD.getPreferredName(), enabled);
841841
dataRetention.toXContent(builder, params, DATA_RETENTION_FIELD.getPreferredName(), TimeValue::getStringRep);
842-
downsampling.toXContent(builder, params, DOWNSAMPLING_FIELD.getPreferredName());
842+
downsamplingRounds.toXContent(builder, params, DOWNSAMPLING_FIELD.getPreferredName());
843843
if (rolloverConfiguration != null) {
844844
builder.field(ROLLOVER_FIELD.getPreferredName());
845845
rolloverConfiguration.evaluateAndConvertToXContent(
@@ -853,7 +853,7 @@ public XContentBuilder toXContent(
853853
}
854854

855855
public DataStreamLifecycle toDataStreamLifecycle() {
856-
return new DataStreamLifecycle(lifecycleType, enabled, dataRetention.get(), downsampling.get());
856+
return new DataStreamLifecycle(lifecycleType, enabled, dataRetention.get(), downsamplingRounds.get());
857857
}
858858
}
859859

@@ -890,7 +890,7 @@ public static class Builder {
890890
@Nullable
891891
private TimeValue dataRetention = null;
892892
@Nullable
893-
private List<DownsamplingRound> downsampling = null;
893+
private List<DownsamplingRound> downsamplingRounds = null;
894894

895895
private Builder(LifecycleType lifecycleType) {
896896
this.lifecycleType = lifecycleType;
@@ -900,21 +900,21 @@ private Builder(DataStreamLifecycle.Template template) {
900900
lifecycleType = template.lifecycleType();
901901
enabled = template.enabled();
902902
dataRetention = template.dataRetention().get();
903-
downsampling = template.downsampling().get();
903+
downsamplingRounds = template.downsamplingRounds().get();
904904
}
905905

906906
private Builder(DataStreamLifecycle lifecycle) {
907907
lifecycleType = lifecycle.lifecycleType;
908908
enabled = lifecycle.enabled();
909909
dataRetention = lifecycle.dataRetention();
910-
downsampling = lifecycle.downsampling();
910+
downsamplingRounds = lifecycle.downsamplingRounds();
911911
}
912912

913913
public Builder composeTemplate(DataStreamLifecycle.Template template) {
914914
assert lifecycleType == template.lifecycleType() : "Trying to compose templates with different lifecycle types";
915915
enabled(template.enabled());
916916
dataRetention(template.dataRetention());
917-
downsampling(template.downsampling());
917+
downsamplingRounds(template.downsamplingRounds());
918918
return this;
919919
}
920920

@@ -935,24 +935,24 @@ public Builder dataRetention(@Nullable TimeValue dataRetention) {
935935
return this;
936936
}
937937

938-
public Builder downsampling(ResettableValue<List<DownsamplingRound>> downsampling) {
938+
public Builder downsamplingRounds(ResettableValue<List<DownsamplingRound>> downsampling) {
939939
if (downsampling.isDefined()) {
940-
this.downsampling = downsampling.get();
940+
this.downsamplingRounds = downsampling.get();
941941
}
942942
return this;
943943
}
944944

945-
public Builder downsampling(@Nullable List<DownsamplingRound> downsampling) {
946-
this.downsampling = downsampling;
945+
public Builder downsamplingRounds(@Nullable List<DownsamplingRound> downsampling) {
946+
this.downsamplingRounds = downsampling;
947947
return this;
948948
}
949949

950950
public DataStreamLifecycle build() {
951-
return new DataStreamLifecycle(lifecycleType, enabled, dataRetention, downsampling);
951+
return new DataStreamLifecycle(lifecycleType, enabled, dataRetention, downsamplingRounds);
952952
}
953953

954954
public Template buildTemplate() {
955-
return new Template(lifecycleType, enabled, dataRetention, downsampling);
955+
return new Template(lifecycleType, enabled, dataRetention, downsamplingRounds);
956956
}
957957
}
958958

server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamFailureStoreTemplateTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private static DataStreamFailureStore.Template normalise(DataStreamFailureStore.
146146
template.lifecycleType(),
147147
template.enabled(),
148148
template.dataRetention().get(),
149-
template.downsampling().get()
149+
template.downsamplingRounds().get()
150150
)
151151
)
152152
);

0 commit comments

Comments
 (0)