Skip to content

Commit 24b852b

Browse files
authored
Clean the last traces from global retention in templates (elastic#111669)
1 parent 69f4543 commit 24b852b

11 files changed

+132
-118
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ static TransportVersion def(int id) {
190190
public static final TransportVersion ML_INFERENCE_EIS_INTEGRATION_ADDED = def(8_720_00_0);
191191
public static final TransportVersion INGEST_PIPELINE_EXCEPTION_ADDED = def(8_721_00_0);
192192
public static final TransportVersion ZDT_NANOS_SUPPORT = def(8_722_00_0);
193+
public static final TransportVersion REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES = def(8_723_00_0);
194+
193195
/*
194196
* STOP! READ THIS FIRST! No, really,
195197
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

server/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetComponentTemplateAction.java

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ public static class Response extends ActionResponse implements ToXContentObject
121121
private final Map<String, ComponentTemplate> componentTemplates;
122122
@Nullable
123123
private final RolloverConfiguration rolloverConfiguration;
124-
@Nullable
125-
private final DataStreamGlobalRetention globalRetention;
126124

127125
public Response(StreamInput in) throws IOException {
128126
super(in);
@@ -132,29 +130,39 @@ public Response(StreamInput in) throws IOException {
132130
} else {
133131
rolloverConfiguration = null;
134132
}
135-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
136-
globalRetention = in.readOptionalWriteable(DataStreamGlobalRetention::read);
137-
} else {
138-
globalRetention = null;
133+
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
134+
&& in.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
135+
in.readOptionalWriteable(DataStreamGlobalRetention::read);
139136
}
140137
}
141138

142-
public Response(Map<String, ComponentTemplate> componentTemplates, RolloverConfiguration rolloverConfiguration) {
143-
this(componentTemplates, rolloverConfiguration, null);
144-
}
145-
139+
/**
140+
* Please use {@link GetComponentTemplateAction.Response#Response(Map)}
141+
*/
142+
@Deprecated
146143
public Response(Map<String, ComponentTemplate> componentTemplates, @Nullable DataStreamGlobalRetention globalRetention) {
147-
this(componentTemplates, null, globalRetention);
144+
this(componentTemplates, (RolloverConfiguration) null);
148145
}
149146

147+
/**
148+
* Please use {@link GetComponentTemplateAction.Response#Response(Map, RolloverConfiguration)}
149+
*/
150+
@Deprecated
150151
public Response(
151152
Map<String, ComponentTemplate> componentTemplates,
152153
@Nullable RolloverConfiguration rolloverConfiguration,
153-
@Nullable DataStreamGlobalRetention globalRetention
154+
@Nullable DataStreamGlobalRetention ignored
154155
) {
156+
this(componentTemplates, rolloverConfiguration);
157+
}
158+
159+
public Response(Map<String, ComponentTemplate> componentTemplates) {
160+
this(componentTemplates, (RolloverConfiguration) null);
161+
}
162+
163+
public Response(Map<String, ComponentTemplate> componentTemplates, @Nullable RolloverConfiguration rolloverConfiguration) {
155164
this.componentTemplates = componentTemplates;
156165
this.rolloverConfiguration = rolloverConfiguration;
157-
this.globalRetention = globalRetention;
158166
}
159167

160168
public Map<String, ComponentTemplate> getComponentTemplates() {
@@ -165,8 +173,14 @@ public RolloverConfiguration getRolloverConfiguration() {
165173
return rolloverConfiguration;
166174
}
167175

176+
/**
177+
* @return null
178+
* @deprecated The global retention is not used anymore in the component template response
179+
*/
180+
@Deprecated
181+
@Nullable
168182
public DataStreamGlobalRetention getGlobalRetention() {
169-
return globalRetention;
183+
return null;
170184
}
171185

172186
@Override
@@ -175,8 +189,9 @@ public void writeTo(StreamOutput out) throws IOException {
175189
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_9_X)) {
176190
out.writeOptionalWriteable(rolloverConfiguration);
177191
}
178-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
179-
out.writeOptionalWriteable(globalRetention);
192+
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
193+
&& out.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
194+
out.writeOptionalWriteable(null);
180195
}
181196
}
182197

@@ -186,13 +201,12 @@ public boolean equals(Object o) {
186201
if (o == null || getClass() != o.getClass()) return false;
187202
Response that = (Response) o;
188203
return Objects.equals(componentTemplates, that.componentTemplates)
189-
&& Objects.equals(rolloverConfiguration, that.rolloverConfiguration)
190-
&& Objects.equals(globalRetention, that.globalRetention);
204+
&& Objects.equals(rolloverConfiguration, that.rolloverConfiguration);
191205
}
192206

193207
@Override
194208
public int hashCode() {
195-
return Objects.hash(componentTemplates, rolloverConfiguration, globalRetention);
209+
return Objects.hash(componentTemplates, rolloverConfiguration);
196210
}
197211

198212
@Override
@@ -212,5 +226,4 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
212226
}
213227

214228
}
215-
216229
}

server/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetComposableIndexTemplateAction.java

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public static class Response extends ActionResponse implements ToXContentObject
122122
private final Map<String, ComposableIndexTemplate> indexTemplates;
123123
@Nullable
124124
private final RolloverConfiguration rolloverConfiguration;
125-
@Nullable
126-
private final DataStreamGlobalRetention globalRetention;
127125

128126
public Response(StreamInput in) throws IOException {
129127
super(in);
@@ -133,37 +131,57 @@ public Response(StreamInput in) throws IOException {
133131
} else {
134132
rolloverConfiguration = null;
135133
}
136-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
137-
globalRetention = in.readOptionalWriteable(DataStreamGlobalRetention::read);
138-
} else {
139-
globalRetention = null;
134+
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
135+
&& in.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
136+
in.readOptionalWriteable(DataStreamGlobalRetention::read);
140137
}
141138
}
142139

140+
/**
141+
* Please use {@link GetComposableIndexTemplateAction.Response#Response(Map)}
142+
*/
143143
public Response(Map<String, ComposableIndexTemplate> indexTemplates, @Nullable DataStreamGlobalRetention globalRetention) {
144-
this(indexTemplates, null, globalRetention);
145-
}
146-
147-
public Response(Map<String, ComposableIndexTemplate> indexTemplates) {
148-
this(indexTemplates, null, null);
144+
this(indexTemplates, (RolloverConfiguration) null);
149145
}
150146

147+
/**
148+
* Please use {@link GetComposableIndexTemplateAction.Response#Response(Map, RolloverConfiguration)}
149+
*/
150+
@Deprecated
151151
public Response(
152152
Map<String, ComposableIndexTemplate> indexTemplates,
153153
@Nullable RolloverConfiguration rolloverConfiguration,
154154
@Nullable DataStreamGlobalRetention globalRetention
155155
) {
156+
this(indexTemplates, rolloverConfiguration);
157+
}
158+
159+
public Response(Map<String, ComposableIndexTemplate> indexTemplates) {
160+
this(indexTemplates, (RolloverConfiguration) null);
161+
}
162+
163+
public Response(Map<String, ComposableIndexTemplate> indexTemplates, @Nullable RolloverConfiguration rolloverConfiguration) {
156164
this.indexTemplates = indexTemplates;
157165
this.rolloverConfiguration = rolloverConfiguration;
158-
this.globalRetention = globalRetention;
159166
}
160167

161168
public Map<String, ComposableIndexTemplate> indexTemplates() {
162169
return indexTemplates;
163170
}
164171

172+
/**
173+
* @return null
174+
* @deprecated global retention is not used in composable templates anymore
175+
*/
176+
@Deprecated
177+
@Nullable
165178
public DataStreamGlobalRetention getGlobalRetention() {
166-
return globalRetention;
179+
return null;
180+
}
181+
182+
@Nullable
183+
public RolloverConfiguration getRolloverConfiguration() {
184+
return rolloverConfiguration;
167185
}
168186

169187
@Override
@@ -172,8 +190,9 @@ public void writeTo(StreamOutput out) throws IOException {
172190
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_9_X)) {
173191
out.writeOptionalWriteable(rolloverConfiguration);
174192
}
175-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
176-
out.writeOptionalWriteable(globalRetention);
193+
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
194+
&& out.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
195+
out.writeOptionalWriteable(null);
177196
}
178197
}
179198

@@ -182,14 +201,12 @@ public boolean equals(Object o) {
182201
if (this == o) return true;
183202
if (o == null || getClass() != o.getClass()) return false;
184203
GetComposableIndexTemplateAction.Response that = (GetComposableIndexTemplateAction.Response) o;
185-
return Objects.equals(indexTemplates, that.indexTemplates)
186-
&& Objects.equals(rolloverConfiguration, that.rolloverConfiguration)
187-
&& Objects.equals(globalRetention, that.globalRetention);
204+
return Objects.equals(indexTemplates, that.indexTemplates) && Objects.equals(rolloverConfiguration, that.rolloverConfiguration);
188205
}
189206

190207
@Override
191208
public int hashCode() {
192-
return Objects.hash(indexTemplates, rolloverConfiguration, globalRetention);
209+
return Objects.hash(indexTemplates, rolloverConfiguration);
193210
}
194211

195212
@Override
@@ -207,7 +224,5 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
207224
builder.endObject();
208225
return builder;
209226
}
210-
211227
}
212-
213228
}

server/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.elasticsearch.cluster.block.ClusterBlockException;
1717
import org.elasticsearch.cluster.block.ClusterBlockLevel;
1818
import org.elasticsearch.cluster.metadata.ComponentTemplate;
19-
import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionProvider;
2019
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
2120
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2221
import org.elasticsearch.cluster.service.ClusterService;
@@ -36,16 +35,14 @@ public class TransportGetComponentTemplateAction extends TransportMasterNodeRead
3635
GetComponentTemplateAction.Response> {
3736

3837
private final ClusterSettings clusterSettings;
39-
private final DataStreamGlobalRetentionProvider globalRetentionResolver;
4038

4139
@Inject
4240
public TransportGetComponentTemplateAction(
4341
TransportService transportService,
4442
ClusterService clusterService,
4543
ThreadPool threadPool,
4644
ActionFilters actionFilters,
47-
IndexNameExpressionResolver indexNameExpressionResolver,
48-
DataStreamGlobalRetentionProvider globalRetentionResolver
45+
IndexNameExpressionResolver indexNameExpressionResolver
4946
) {
5047
super(
5148
GetComponentTemplateAction.NAME,
@@ -59,7 +56,6 @@ public TransportGetComponentTemplateAction(
5956
EsExecutors.DIRECT_EXECUTOR_SERVICE
6057
);
6158
clusterSettings = clusterService.getClusterSettings();
62-
this.globalRetentionResolver = globalRetentionResolver;
6359
}
6460

6561
@Override
@@ -100,12 +96,11 @@ protected void masterOperation(
10096
listener.onResponse(
10197
new GetComponentTemplateAction.Response(
10298
results,
103-
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING),
104-
globalRetentionResolver.provide()
99+
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING)
105100
)
106101
);
107102
} else {
108-
listener.onResponse(new GetComponentTemplateAction.Response(results, globalRetentionResolver.provide()));
103+
listener.onResponse(new GetComponentTemplateAction.Response(results));
109104
}
110105
}
111106
}

server/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.elasticsearch.cluster.block.ClusterBlockException;
1717
import org.elasticsearch.cluster.block.ClusterBlockLevel;
1818
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
19-
import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionProvider;
2019
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
2120
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2221
import org.elasticsearch.cluster.service.ClusterService;
@@ -36,16 +35,14 @@ public class TransportGetComposableIndexTemplateAction extends TransportMasterNo
3635
GetComposableIndexTemplateAction.Response> {
3736

3837
private final ClusterSettings clusterSettings;
39-
private final DataStreamGlobalRetentionProvider globalRetentionResolver;
4038

4139
@Inject
4240
public TransportGetComposableIndexTemplateAction(
4341
TransportService transportService,
4442
ClusterService clusterService,
4543
ThreadPool threadPool,
4644
ActionFilters actionFilters,
47-
IndexNameExpressionResolver indexNameExpressionResolver,
48-
DataStreamGlobalRetentionProvider globalRetentionResolver
45+
IndexNameExpressionResolver indexNameExpressionResolver
4946
) {
5047
super(
5148
GetComposableIndexTemplateAction.NAME,
@@ -59,7 +56,6 @@ public TransportGetComposableIndexTemplateAction(
5956
EsExecutors.DIRECT_EXECUTOR_SERVICE
6057
);
6158
clusterSettings = clusterService.getClusterSettings();
62-
this.globalRetentionResolver = globalRetentionResolver;
6359
}
6460

6561
@Override
@@ -98,12 +94,11 @@ protected void masterOperation(
9894
listener.onResponse(
9995
new GetComposableIndexTemplateAction.Response(
10096
results,
101-
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING),
102-
globalRetentionResolver.provide()
97+
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING)
10398
)
10499
);
105100
} else {
106-
listener.onResponse(new GetComposableIndexTemplateAction.Response(results, globalRetentionResolver.provide()));
101+
listener.onResponse(new GetComposableIndexTemplateAction.Response(results));
107102
}
108103
}
109104
}

0 commit comments

Comments
 (0)