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 configuration that defines how the data stream indices of a data stream are managed. The lifecycle also
has a type that determines the type of index component it can manage. Currently, we support data and failures.
Lifecycle supports the following configurations:
- enabled, applicable to data and failures
- data retention, applicable to data and failures
- downsampling, applicable only to data
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds and composes the data stream lifecycle or the respective template.static final recordA round represents the configuration for when and how elasticsearch will downsample a backing index.static enumThis enum represents all configuration sources that can influence the retention of a data stream.static final recordRepresents the template configuration of a lifecycle.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.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TransportVersionstatic final Setting<RolloverConfiguration> static final ParseFieldstatic final Stringstatic final Stringstatic final DataStreamLifecyclestatic final DataStreamLifecyclestatic final ParseFieldstatic final ParseFieldstatic final Stringstatic final ParseFieldstatic final Stringstatic final Tuple<TimeValue, DataStreamLifecycle.RetentionSource> static final ConstructingObjectParser<DataStreamLifecycle, org.elasticsearch.cluster.metadata.DataStreamLifecycle.LifecycleType> static final ParseFieldFields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTYFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ToXContent.ParamsAdds a retention param to signal that this serialisation should include the effective retention metadata.voidaddWarningHeaderIfDataRetentionNotEffective(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.static DataStreamLifecycle.Builderbuilder(DataStreamLifecycle lifecycle) static DataStreamLifecycle.Builderbuilder(DataStreamLifecycle.Template template) static DataStreamLifecyclecreateDataLifecycle(Boolean enabled, TimeValue dataRetention, List<DataStreamLifecycle.DownsamplingRound> downsampling) This factory method creates a lifecycle applicable for the data index component of a data stream.static DataStreamLifecycle.TemplatecreateDataLifecycleTemplate(boolean enabled, ResettableValue<TimeValue> dataRetention, ResettableValue<List<DataStreamLifecycle.DownsamplingRound>> downsampling) This factory method creates a lifecycle template applicable for the data index component of a data stream.static DataStreamLifecycle.TemplatecreateDataLifecycleTemplate(boolean enabled, TimeValue dataRetention, List<DataStreamLifecycle.DownsamplingRound> downsampling) This factory method creates a lifecycle template applicable for the data index component of a data stream.static DataStreamLifecyclecreateFailuresLifecycle(Boolean enabled, TimeValue dataRetention) This factory method creates a lifecycle applicable for the failures index component of a data stream.static DataStreamLifecycle.TemplatecreateFailuresLifecycleTemplate(boolean enabled, TimeValue dataRetention) This factory method creates a lifecycle template applicable for the failures index component of a data stream.static DataStreamLifecycle.BuilderThis builder factory initialises a builder of a data lifecycle, meaning when it builds we will either get a data lifecycle or a data lifecycle template.static DataStreamLifecycleThis method de-serialises a data lifecycle 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.booleanenabled()Returns true, if this data stream lifecycle configuration is enabled, false otherwisebooleanstatic DataStreamLifecycleThis method de-serialises a failures lifecycle as it was generated ONLY bytoXContent(XContentBuilder, Params).static DataStreamLifecycle.BuilderThis builder factory initialises a builder of a failures lifecycle, meaning when it builds we will either get a failures lifecycle or a failures lifecycle template, if downsampling is not null the final "building" will throw an exception.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..inthashCode()static booleanisDataStreamsLifecycleOnlyMode(Settings settings) Check ifDATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAMEis present and set totrue, indicating that we're running in a cluster configuration that is only expecting to use data streams lifecycles.static Diff<DataStreamLifecycle> booleantoString()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.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diffMethods 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_LIFECYCLE
-
DEFAULT_FAILURE_LIFECYCLE
-
DATA_STREAM_LIFECYCLE_ORIGIN
- See Also:
-
ENABLED_FIELD
-
DATA_RETENTION_FIELD
-
EFFECTIVE_RETENTION_FIELD
-
RETENTION_SOURCE_FIELD
-
DOWNSAMPLING_FIELD
-
PARSER
public static final ConstructingObjectParser<DataStreamLifecycle,org.elasticsearch.cluster.metadata.DataStreamLifecycle.LifecycleType> PARSER
-
-
Constructor Details
-
DataStreamLifecycle
- Throws:
IOException
-
-
Method Details
-
isDataStreamsLifecycleOnlyMode
Check ifDATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAMEis 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_NAMEis present and set
-
createDataLifecycle
public static DataStreamLifecycle createDataLifecycle(@Nullable Boolean enabled, @Nullable TimeValue dataRetention, @Nullable List<DataStreamLifecycle.DownsamplingRound> downsampling) This factory method creates a lifecycle applicable for the data index component of a data stream. This means it supports all configuration applicable for backing indices. -
createFailuresLifecycle
public static DataStreamLifecycle createFailuresLifecycle(@Nullable Boolean enabled, @Nullable TimeValue dataRetention) This factory method creates a lifecycle applicable for the failures index component of a data stream. This means it supports only enabling and retention. -
enabled
public boolean enabled()Returns true, if this data stream lifecycle configuration is enabled, false otherwise -
targetsFailureStore
public boolean targetsFailureStore()- Returns:
- true if the lifecycle manages the failure store, false otherwise
-
getLifecycleType
-
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.
-
dataRetention
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. -
downsampling
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:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
readDiffFrom
- Throws:
IOException
-
toString
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin 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_NAMEto true in the XContent params. NOTE: this is used for serialising user output and the result is never deserialised in elasticsearch.- Throws:
IOException
-
dataLifecycleFromXContent
public static DataStreamLifecycle dataLifecycleFromXContent(XContentParser parser) throws IOException This method de-serialises a data lifecycle 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 de-serialisation.- Throws:
IOException
-
failureLifecycleFromXContent
public static DataStreamLifecycle failureLifecycleFromXContent(XContentParser parser) throws IOException This method de-serialises a failures lifecycle 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 de-serialisation.- 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.
-
createDataLifecycleTemplate
public static DataStreamLifecycle.Template createDataLifecycleTemplate(boolean enabled, TimeValue dataRetention, List<DataStreamLifecycle.DownsamplingRound> downsampling) This factory method creates a lifecycle template applicable for the data index component of a data stream. This means it supports all configuration applicable for backing indices. -
createDataLifecycleTemplate
public static DataStreamLifecycle.Template createDataLifecycleTemplate(boolean enabled, ResettableValue<TimeValue> dataRetention, ResettableValue<List<DataStreamLifecycle.DownsamplingRound>> downsampling) This factory method creates a lifecycle template applicable for the data index component of a data stream. This means it supports all configuration applicable for backing indices. -
createFailuresLifecycleTemplate
public static DataStreamLifecycle.Template createFailuresLifecycleTemplate(boolean enabled, TimeValue dataRetention) This factory method creates a lifecycle template applicable for the failures index component of a data stream. This means it supports only setting the enabled and the retention. -
builder
-
builder
-
dataLifecycleBuilder
This builder factory initialises a builder of a data lifecycle, meaning when it builds we will either get a data lifecycle or a data lifecycle template. -
failuresLifecycleBuilder
This builder factory initialises a builder of a failures lifecycle, meaning when it builds we will either get a failures lifecycle or a failures lifecycle template, if downsampling is not null the final "building" will throw an exception.
-