java.lang.Object
org.elasticsearch.cluster.metadata.DataStream
- All Implemented Interfaces:
Diffable<DataStream>
,SimpleDiffable<DataStream>
,Writeable
,ToXContent
,ToXContentObject
public final class DataStream
extends Object
implements SimpleDiffable<DataStream>, ToXContentObject
-
Nested Class Summary
Nested ClassesNested 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 ParseField
static final String
static final DateFormatter
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static Comparator<org.apache.lucene.index.LeafReader>
static final DataStream.TimestampField
static final ParseField
Fields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTY
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBackingIndex
(Metadata clusterMetadata, Index index) Adds the specified index as a backing index and returns a newDataStream
instance with the new combination of backing indices.boolean
static DataStream
fromXContent
(XContentParser parser) static String
getDefaultBackingIndexName
(String dataStreamName, long generation) Generates the name of the index that conforms to the default naming convention for backing indices on data streams given the specified data stream name and generation and the current system time.static String
getDefaultBackingIndexName
(String dataStreamName, long generation, long epochMillis) Generates the name of the index that conforms to the default naming convention for backing indices on data streams given the specified data stream name, generation, and time.long
getName()
int
hashCode()
boolean
boolean
isHidden()
boolean
Determines whether this data stream is replicated from elsewhere, for example a remote cluster.boolean
isSystem()
nextWriteIndexAndGeneration
(Metadata clusterMetadata) Performs a dummy rollover on aDataStream
instance and returns the tuple of the next write index name and next generation that thisDataStream
should roll over to usingrollover(Index, long, boolean)
.static Diff<DataStream>
removeBackingIndex
(Index index) Removes the specified backing index and returns a newDataStream
instance with the remaining backing indices.replaceBackingIndex
(Index existingBackingIndex, Index newBackingIndex) Replaces the specified backing index with a new index and returns a newDataStream
instance with the modified backing indices.Performs a rollover on aDataStream
instance and returns a new instance containing the updated list of backing indices and incremented generation.selectTimeSeriesWriteIndex
(Instant timestamp, Metadata metadata) snapshot
(Collection<String> indicesInSnapshot) Reconciles this data stream with a list of indices available in a snapshot.toXContent
(XContentBuilder builder, ToXContent.Params params) unsafeNextWriteIndexAndGeneration
(Metadata clusterMetadata) LikenextWriteIndexAndGeneration(Metadata)
, but does no validation, use with care only.unsafeRollover
(Index writeIndex, long generation, boolean timeSeries) Likerollover(Index, long, boolean)
, but does no validation, use with care only.void
validate
(Function<String, IndexMetadata> imSupplier) Validates this data stream.void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diff
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
BACKING_INDEX_PREFIX
- See Also:
-
DATE_FORMATTER
-
TIMESTAMP_FIELD
-
TIMESERIES_LEAF_READERS_SORTER
-
NAME_FIELD
-
TIMESTAMP_FIELD_FIELD
-
INDICES_FIELD
-
GENERATION_FIELD
-
METADATA_FIELD
-
HIDDEN_FIELD
-
REPLICATED_FIELD
-
SYSTEM_FIELD
-
ALLOW_CUSTOM_ROUTING
-
INDEX_MODE
-
-
Constructor Details
-
DataStream
-
DataStream
- Throws:
IOException
-
-
Method Details
-
getName
-
getTimeStampField
-
getIndices
-
getGeneration
public long getGeneration() -
getWriteIndex
-
selectTimeSeriesWriteIndex
- Parameters:
timestamp
- The timestamp used to select a backing index based on its start and end time.metadata
- The metadata that is used to fetch the start and end times for backing indices of this data stream.- Returns:
- a backing index with a start time that is greater or equal to the provided timestamp and
an end time that is less than the provided timestamp. Otherwise
null
is returned.
-
validate
Validates this data stream. If this is a time series data stream then this method validates that temporal range of backing indices (defined by index.time_series.start_time and index.time_series.end_time) do not overlap with each other.- Parameters:
imSupplier
- Function that suppliesIndexMetadata
instances based on the provided index name
-
getMetadata
-
isHidden
public boolean isHidden() -
isReplicated
public boolean isReplicated()Determines whether this data stream is replicated from elsewhere, for example a remote cluster.- Returns:
- Whether this data stream is replicated.
-
isSystem
public boolean isSystem() -
isAllowCustomRouting
public boolean isAllowCustomRouting() -
getIndexMode
-
rollover
Performs a rollover on aDataStream
instance and returns a new instance containing the updated list of backing indices and incremented generation.- Parameters:
writeIndex
- new write indexgeneration
- new generationtimeSeries
- whether the template that created this data stream is in time series mode- Returns:
- new
DataStream
instance with the rollover operation applied
-
unsafeRollover
Likerollover(Index, long, boolean)
, but does no validation, use with care only. -
nextWriteIndexAndGeneration
Performs a dummy rollover on aDataStream
instance and returns the tuple of the next write index name and next generation that thisDataStream
should roll over to usingrollover(Index, long, boolean)
.- Parameters:
clusterMetadata
- Cluster metadata- Returns:
- new
DataStream
instance with the dummy rollover operation applied
-
unsafeNextWriteIndexAndGeneration
LikenextWriteIndexAndGeneration(Metadata)
, but does no validation, use with care only. -
removeBackingIndex
Removes the specified backing index and returns a newDataStream
instance with the remaining backing indices.- Parameters:
index
- the backing index to remove- Returns:
- new
DataStream
instance with the remaining backing indices - Throws:
IllegalArgumentException
- ifindex
is not a backing index or is the current write index of the data stream
-
replaceBackingIndex
Replaces the specified backing index with a new index and returns a newDataStream
instance with the modified backing indices. AnIllegalArgumentException
is thrown if the index to be replaced is not a backing index for this data stream or if it is theDataStream
's write index.- Parameters:
existingBackingIndex
- the backing index to be replacednewBackingIndex
- the new index that will be part of theDataStream
- Returns:
- new
DataStream
instance with backing indices that contain replacement index instead of the specified existing index.
-
addBackingIndex
Adds the specified index as a backing index and returns a newDataStream
instance with the new combination of backing indices.- Parameters:
index
- index to add to the data stream- Returns:
- new
DataStream
instance with the added backing index - Throws:
IllegalArgumentException
- ifindex
is ineligible to be a backing index for the data stream
-
promoteDataStream
-
snapshot
Reconciles this data stream with a list of indices available in a snapshot. Allows snapshots to store accurate data stream definitions that do not reference backing indices not contained in the snapshot.- Parameters:
indicesInSnapshot
- List of indices in the snapshot- Returns:
- Reconciled
DataStream
instance ornull
if no reconciled version of this data stream could be built from the given indices
-
getDefaultBackingIndexName
Generates the name of the index that conforms to the default naming convention for backing indices on data streams given the specified data stream name and generation and the current system time.- Parameters:
dataStreamName
- name of the data streamgeneration
- generation of the data stream- Returns:
- backing index name
-
getDefaultBackingIndexName
public static String getDefaultBackingIndexName(String dataStreamName, long generation, long epochMillis) Generates the name of the index that conforms to the default naming convention for backing indices on data streams given the specified data stream name, generation, and time.- Parameters:
dataStreamName
- name of the data streamgeneration
- generation of the data streamepochMillis
- creation time for the backing index- Returns:
- backing index name
-
readDiffFrom
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
fromXContent
- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode()
-