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

Clean the last traces from global retention in templates #111669

Merged
2 changes: 2 additions & 0 deletions server/src/main/java/org/elasticsearch/TransportVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ static TransportVersion def(int id) {
public static final TransportVersion ML_INFERENCE_EIS_INTEGRATION_ADDED = def(8_720_00_0);
public static final TransportVersion INGEST_PIPELINE_EXCEPTION_ADDED = def(8_721_00_0);
public static final TransportVersion ZDT_NANOS_SUPPORT = def(8_722_00_0);
public static final TransportVersion REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES = def(8_723_00_0);

/*
* STOP! READ THIS FIRST! No, really,
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public static class Response extends ActionResponse implements ToXContentObject
private final Map<String, ComponentTemplate> componentTemplates;
@Nullable
private final RolloverConfiguration rolloverConfiguration;
@Nullable
private final DataStreamGlobalRetention globalRetention;

public Response(StreamInput in) throws IOException {
super(in);
Expand All @@ -132,29 +130,39 @@ public Response(StreamInput in) throws IOException {
} else {
rolloverConfiguration = null;
}
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
globalRetention = in.readOptionalWriteable(DataStreamGlobalRetention::read);
} else {
globalRetention = null;
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
&& in.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
in.readOptionalWriteable(DataStreamGlobalRetention::read);
}
}

public Response(Map<String, ComponentTemplate> componentTemplates, RolloverConfiguration rolloverConfiguration) {
this(componentTemplates, rolloverConfiguration, null);
}

/**
* Please use {@link GetComponentTemplateAction.Response#Response(Map)}
*/
@Deprecated
public Response(Map<String, ComponentTemplate> componentTemplates, @Nullable DataStreamGlobalRetention globalRetention) {
this(componentTemplates, null, globalRetention);
this(componentTemplates, (RolloverConfiguration) null);
}

/**
* Please use {@link GetComponentTemplateAction.Response#Response(Map, RolloverConfiguration)}
*/
@Deprecated
public Response(
Map<String, ComponentTemplate> componentTemplates,
@Nullable RolloverConfiguration rolloverConfiguration,
@Nullable DataStreamGlobalRetention globalRetention
@Nullable DataStreamGlobalRetention ignored
) {
this(componentTemplates, rolloverConfiguration);
}

public Response(Map<String, ComponentTemplate> componentTemplates) {
this(componentTemplates, (RolloverConfiguration) null);
}

public Response(Map<String, ComponentTemplate> componentTemplates, @Nullable RolloverConfiguration rolloverConfiguration) {
this.componentTemplates = componentTemplates;
this.rolloverConfiguration = rolloverConfiguration;
this.globalRetention = globalRetention;
}

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

/**
* @return null
* @deprecated The global retention is not used anymore in the component template response
*/
@Deprecated
@Nullable
public DataStreamGlobalRetention getGlobalRetention() {
return globalRetention;
return null;
}

@Override
Expand All @@ -175,8 +189,9 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_9_X)) {
out.writeOptionalWriteable(rolloverConfiguration);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
out.writeOptionalWriteable(globalRetention);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
&& out.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
out.writeOptionalWriteable(null);
}
}

Expand All @@ -186,13 +201,12 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
Response that = (Response) o;
return Objects.equals(componentTemplates, that.componentTemplates)
&& Objects.equals(rolloverConfiguration, that.rolloverConfiguration)
&& Objects.equals(globalRetention, that.globalRetention);
&& Objects.equals(rolloverConfiguration, that.rolloverConfiguration);
}

@Override
public int hashCode() {
return Objects.hash(componentTemplates, rolloverConfiguration, globalRetention);
return Objects.hash(componentTemplates, rolloverConfiguration);
}

@Override
Expand All @@ -212,5 +226,4 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public static class Response extends ActionResponse implements ToXContentObject
private final Map<String, ComposableIndexTemplate> indexTemplates;
@Nullable
private final RolloverConfiguration rolloverConfiguration;
@Nullable
private final DataStreamGlobalRetention globalRetention;

public Response(StreamInput in) throws IOException {
super(in);
Expand All @@ -133,37 +131,57 @@ public Response(StreamInput in) throws IOException {
} else {
rolloverConfiguration = null;
}
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
globalRetention = in.readOptionalWriteable(DataStreamGlobalRetention::read);
} else {
globalRetention = null;
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
&& in.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
in.readOptionalWriteable(DataStreamGlobalRetention::read);
}
}

/**
* Please use {@link GetComposableIndexTemplateAction.Response#Response(Map)}
*/
public Response(Map<String, ComposableIndexTemplate> indexTemplates, @Nullable DataStreamGlobalRetention globalRetention) {
this(indexTemplates, null, globalRetention);
}

public Response(Map<String, ComposableIndexTemplate> indexTemplates) {
this(indexTemplates, null, null);
this(indexTemplates, (RolloverConfiguration) null);
}

/**
* Please use {@link GetComposableIndexTemplateAction.Response#Response(Map, RolloverConfiguration)}
*/
@Deprecated
public Response(
Map<String, ComposableIndexTemplate> indexTemplates,
@Nullable RolloverConfiguration rolloverConfiguration,
@Nullable DataStreamGlobalRetention globalRetention
) {
this(indexTemplates, rolloverConfiguration);
}

public Response(Map<String, ComposableIndexTemplate> indexTemplates) {
this(indexTemplates, (RolloverConfiguration) null);
}

public Response(Map<String, ComposableIndexTemplate> indexTemplates, @Nullable RolloverConfiguration rolloverConfiguration) {
this.indexTemplates = indexTemplates;
this.rolloverConfiguration = rolloverConfiguration;
this.globalRetention = globalRetention;
}

public Map<String, ComposableIndexTemplate> indexTemplates() {
return indexTemplates;
}

/**
* @return null
* @deprecated global retention is not used in composable templates anymore
*/
@Deprecated
@Nullable
public DataStreamGlobalRetention getGlobalRetention() {
return globalRetention;
return null;
}

@Nullable
public RolloverConfiguration getRolloverConfiguration() {
return rolloverConfiguration;
}

@Override
Expand All @@ -172,8 +190,9 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_9_X)) {
out.writeOptionalWriteable(rolloverConfiguration);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
out.writeOptionalWriteable(globalRetention);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)
&& out.getTransportVersion().before(TransportVersions.REMOVE_GLOBAL_RETENTION_FROM_TEMPLATES)) {
out.writeOptionalWriteable(null);
}
}

Expand All @@ -182,14 +201,12 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GetComposableIndexTemplateAction.Response that = (GetComposableIndexTemplateAction.Response) o;
return Objects.equals(indexTemplates, that.indexTemplates)
&& Objects.equals(rolloverConfiguration, that.rolloverConfiguration)
&& Objects.equals(globalRetention, that.globalRetention);
return Objects.equals(indexTemplates, that.indexTemplates) && Objects.equals(rolloverConfiguration, that.rolloverConfiguration);
}

@Override
public int hashCode() {
return Objects.hash(indexTemplates, rolloverConfiguration, globalRetention);
return Objects.hash(indexTemplates, rolloverConfiguration);
}

@Override
Expand All @@ -207,7 +224,5 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.endObject();
return builder;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.ComponentTemplate;
import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionProvider;
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
Expand All @@ -36,16 +35,14 @@ public class TransportGetComponentTemplateAction extends TransportMasterNodeRead
GetComponentTemplateAction.Response> {

private final ClusterSettings clusterSettings;
private final DataStreamGlobalRetentionProvider globalRetentionResolver;

@Inject
public TransportGetComponentTemplateAction(
TransportService transportService,
ClusterService clusterService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
DataStreamGlobalRetentionProvider globalRetentionResolver
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(
GetComponentTemplateAction.NAME,
Expand All @@ -59,7 +56,6 @@ public TransportGetComponentTemplateAction(
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
clusterSettings = clusterService.getClusterSettings();
this.globalRetentionResolver = globalRetentionResolver;
}

@Override
Expand Down Expand Up @@ -100,12 +96,11 @@ protected void masterOperation(
listener.onResponse(
new GetComponentTemplateAction.Response(
results,
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING),
globalRetentionResolver.provide()
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING)
)
);
} else {
listener.onResponse(new GetComponentTemplateAction.Response(results, globalRetentionResolver.provide()));
listener.onResponse(new GetComponentTemplateAction.Response(results));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionProvider;
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
Expand All @@ -36,16 +35,14 @@ public class TransportGetComposableIndexTemplateAction extends TransportMasterNo
GetComposableIndexTemplateAction.Response> {

private final ClusterSettings clusterSettings;
private final DataStreamGlobalRetentionProvider globalRetentionResolver;

@Inject
public TransportGetComposableIndexTemplateAction(
TransportService transportService,
ClusterService clusterService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
DataStreamGlobalRetentionProvider globalRetentionResolver
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(
GetComposableIndexTemplateAction.NAME,
Expand All @@ -59,7 +56,6 @@ public TransportGetComposableIndexTemplateAction(
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
clusterSettings = clusterService.getClusterSettings();
this.globalRetentionResolver = globalRetentionResolver;
}

@Override
Expand Down Expand Up @@ -98,12 +94,11 @@ protected void masterOperation(
listener.onResponse(
new GetComposableIndexTemplateAction.Response(
results,
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING),
globalRetentionResolver.provide()
clusterSettings.get(DataStreamLifecycle.CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING)
)
);
} else {
listener.onResponse(new GetComposableIndexTemplateAction.Response(results, globalRetentionResolver.provide()));
listener.onResponse(new GetComposableIndexTemplateAction.Response(results));
}
}
}
Loading