Module org.elasticsearch.server
Class DataStreamLifecycle
java.lang.Object
org.elasticsearch.cluster.metadata.DataStreamLifecycle
- All Implemented Interfaces:
Diffable<DataStreamLifecycle>
,SimpleDiffable<DataStreamLifecycle>
,Writeable
,ToXContent
,ToXContentObject
public class DataStreamLifecycle
extends Object
implements SimpleDiffable<DataStreamLifecycle>, ToXContentObject
Holds the data stream lifecycle metadata that are configuring how a data stream is managed. Currently, it supports the following
configurations:
- enabled
- data retention
- downsampling
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This builder helps during the composition of the data stream lifecycle templates.static final record
Downsampling holds the configuration about when should elasticsearch downsample a backing index.static final record
Retention is the least amount of time that the data will be kept by elasticsearch.static enum
This enum represents all configuration sources that can influence the retention of a data stream.Nested classes/interfaces inherited from interface org.elasticsearch.cluster.SimpleDiffable
SimpleDiffable.CompleteDiff<T extends Diffable<T>>
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TransportVersion
static final Setting
<RolloverConfiguration> static final ParseField
static final String
static final String
static final DataStreamLifecycle
static final ParseField
static final ParseField
static final String
static final ParseField
static final String
static final Tuple
<TimeValue, DataStreamLifecycle.RetentionSource> static final ConstructingObjectParser
<DataStreamLifecycle, Void> static final ParseField
Fields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTY
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionDataStreamLifecycle
(DataStreamLifecycle.Retention dataRetention, DataStreamLifecycle.Downsampling downsampling, Boolean enabled) -
Method Summary
Modifier and TypeMethodDescriptionstatic ToXContent.Params
Adds a retention param to signal that this serialisation should include the effective retention metadata.void
addWarningHeaderIfDataRetentionNotEffective
(DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) This method checks if the effective retention is matching what the user has configured; if the effective retention does not match then it adds a warning informing the user about the effective retention and the source.boolean
static DataStreamLifecycle
fromXContent
(XContentParser parser) This method deserialises XContent format as it was generated ONLY bytoXContent(XContentBuilder, Params)
.The least amount of time data the data stream is requesting es to keep the data.The configured downsampling rounds with the `after` and the `fixed_interval` per round.getEffectiveDataRetention
(DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) The least amount of time data should be kept by elasticsearch.getEffectiveDataRetentionWithSource
(DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) The least amount of time data should be kept by elasticsearch..int
hashCode()
static boolean
isDataStreamsLifecycleOnlyMode
(Settings settings) Check ifDATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME
is present and set totrue
, indicating that we're running in a cluster configuration that is only expecting to use data streams lifecycles.boolean
Returns true, if this data stream lifecycle configuration is enabled and false otherwisestatic DataStreamLifecycle.Builder
static DataStreamLifecycle.Builder
newBuilder
(DataStreamLifecycle lifecycle) static Diff
<DataStreamLifecycle> toString()
toXContent
(XContentBuilder builder, ToXContent.Params params) toXContent
(XContentBuilder builder, ToXContent.Params params, RolloverConfiguration rolloverConfiguration, DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) Converts the data stream lifecycle to XContent, enriches it with effective retention information when requested and injects the RolloverConditions if they exist.void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diff
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
ADDED_ENABLED_FLAG_VERSION
-
EFFECTIVE_RETENTION_REST_API_CAPABILITY
- See Also:
-
DATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME
- See Also:
-
INCLUDE_EFFECTIVE_RETENTION_PARAM_NAME
- See Also:
-
INCLUDE_EFFECTIVE_RETENTION_PARAMS
-
INFINITE_RETENTION
-
CLUSTER_LIFECYCLE_DEFAULT_ROLLOVER_SETTING
-
DEFAULT
-
DATA_STREAM_LIFECYCLE_ORIGIN
- See Also:
-
ENABLED_FIELD
-
DATA_RETENTION_FIELD
-
EFFECTIVE_RETENTION_FIELD
-
RETENTION_SOURCE_FIELD
-
DOWNSAMPLING_FIELD
-
PARSER
-
-
Constructor Details
-
DataStreamLifecycle
public DataStreamLifecycle() -
DataStreamLifecycle
public DataStreamLifecycle(@Nullable DataStreamLifecycle.Retention dataRetention, @Nullable DataStreamLifecycle.Downsampling downsampling, @Nullable Boolean enabled) -
DataStreamLifecycle
- Throws:
IOException
-
-
Method Details
-
isDataStreamsLifecycleOnlyMode
Check ifDATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME
is present and set totrue
, indicating that we're running in a cluster configuration that is only expecting to use data streams lifecycles.- Parameters:
settings
- the node settings- Returns:
- true if
DATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME
is present and set
-
isEnabled
public boolean isEnabled()Returns true, if this data stream lifecycle configuration is enabled and false otherwise -
getEffectiveDataRetention
@Nullable public TimeValue getEffectiveDataRetention(@Nullable DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) The least amount of time data should be kept by elasticsearch. The effective retention is a function with three parameters, thedataRetention
, the global retention and whether this lifecycle is associated with an internal data stream.- Parameters:
globalRetention
- The global retention, or null if global retention does not exist.isInternalDataStream
- A flag denoting if this lifecycle is associated with an internal data stream or not- Returns:
- the time period or null, null represents that data should never be deleted.
-
getEffectiveDataRetentionWithSource
public Tuple<TimeValue,DataStreamLifecycle.RetentionSource> getEffectiveDataRetentionWithSource(@Nullable DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) The least amount of time data should be kept by elasticsearch.. The effective retention is a function with three parameters, thedataRetention
, the global retention and whether this lifecycle is associated with an internal data stream.- Parameters:
globalRetention
- The global retention, or null if global retention does not exist.isInternalDataStream
- A flag denoting if this lifecycle is associated with an internal data stream or not- Returns:
- A tuple containing the time period or null as v1 (where null represents that data should never be deleted), and the non-null retention source as v2.
-
getDataStreamRetention
The least amount of time data the data stream is requesting es to keep the data. NOTE: this can be overridden by thegetEffectiveDataRetention(DataStreamGlobalRetention,boolean)
.- Returns:
- the time period or null, null represents that data should never be deleted.
-
addWarningHeaderIfDataRetentionNotEffective
public void addWarningHeaderIfDataRetentionNotEffective(@Nullable DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) This method checks if the effective retention is matching what the user has configured; if the effective retention does not match then it adds a warning informing the user about the effective retention and the source. -
getDownsamplingRounds
The configured downsampling rounds with the `after` and the `fixed_interval` per round. If downsampling is not configured then it returns null. -
equals
-
hashCode
public int hashCode() -
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
readDiffFrom
- Throws:
IOException
-
toString
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params, @Nullable RolloverConfiguration rolloverConfiguration, @Nullable DataStreamGlobalRetention globalRetention, boolean isInternalDataStream) throws IOException Converts the data stream lifecycle to XContent, enriches it with effective retention information when requested and injects the RolloverConditions if they exist. In order to request the effective retention you need to setINCLUDE_EFFECTIVE_RETENTION_PARAM_NAME
to true in the XContent params. NOTE: this is used for serialising user output and the result is never deserialised in elasticsearch.- Throws:
IOException
-
fromXContent
This method deserialises XContent format as it was generated ONLY bytoXContent(XContentBuilder, Params)
. It does not support the output oftoXContent(XContentBuilder, Params, RolloverConfiguration, DataStreamGlobalRetention, boolean)
because this output is enriched with derived fields we do not handle in this deserialisation.- Throws:
IOException
-
addEffectiveRetentionParams
Adds a retention param to signal that this serialisation should include the effective retention metadata.- Parameters:
params
- the XContent params to be extended with the new flag- Returns:
- XContent params with `include_effective_retention` set to true. If the flag exists it will override it.
-
newBuilder
-
newBuilder
-