Class DataStream

java.lang.Object
org.elasticsearch.cluster.metadata.DataStream
All Implemented Interfaces:
Diffable<DataStream>, SimpleDiffable<DataStream>, Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public final class DataStream extends Object implements SimpleDiffable<DataStream>, org.elasticsearch.xcontent.ToXContentObject
  • Field Details

    • BACKING_INDEX_PREFIX

      public static final String BACKING_INDEX_PREFIX
      See Also:
    • DATE_FORMATTER

      public static final DateFormatter DATE_FORMATTER
    • TIMESERIES_LEAF_READERS_SORTER

      public static Comparator<org.apache.lucene.index.LeafReader> TIMESERIES_LEAF_READERS_SORTER
    • NAME_FIELD

      public static final org.elasticsearch.xcontent.ParseField NAME_FIELD
    • TIMESTAMP_FIELD_FIELD

      public static final org.elasticsearch.xcontent.ParseField TIMESTAMP_FIELD_FIELD
    • INDICES_FIELD

      public static final org.elasticsearch.xcontent.ParseField INDICES_FIELD
    • GENERATION_FIELD

      public static final org.elasticsearch.xcontent.ParseField GENERATION_FIELD
    • METADATA_FIELD

      public static final org.elasticsearch.xcontent.ParseField METADATA_FIELD
    • HIDDEN_FIELD

      public static final org.elasticsearch.xcontent.ParseField HIDDEN_FIELD
    • REPLICATED_FIELD

      public static final org.elasticsearch.xcontent.ParseField REPLICATED_FIELD
    • SYSTEM_FIELD

      public static final org.elasticsearch.xcontent.ParseField SYSTEM_FIELD
    • ALLOW_CUSTOM_ROUTING

      public static final org.elasticsearch.xcontent.ParseField ALLOW_CUSTOM_ROUTING
    • INDEX_MODE

      public static final org.elasticsearch.xcontent.ParseField INDEX_MODE
  • Constructor Details

  • Method Details

    • getName

      public String getName()
    • getTimeStampField

      public DataStream.TimestampField getTimeStampField()
    • getIndices

      public List<Index> getIndices()
    • getGeneration

      public long getGeneration()
    • getWriteIndex

      public Index getWriteIndex()
    • selectTimeSeriesWriteIndex

      public Index selectTimeSeriesWriteIndex(Instant timestamp, Metadata metadata)
      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

      public void validate(Function<String,IndexMetadata> imSupplier)
      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 supplies IndexMetadata instances based on the provided index name
    • getMetadata

      @Nullable public Map<String,Object> 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

      @Nullable public IndexMode getIndexMode()
    • rollover

      public DataStream rollover(Index writeIndex, long generation)
      Performs a rollover on a DataStream instance and returns a new instance containing the updated list of backing indices and incremented generation.
      Parameters:
      writeIndex - new write index
      generation - new generation
      Returns:
      new DataStream instance with the rollover operation applied
    • unsafeRollover

      public DataStream unsafeRollover(Index writeIndex, long generation)
      Like rollover(Index, long), but does no validation, use with care only.
    • nextWriteIndexAndGeneration

      public org.elasticsearch.core.Tuple<String,Long> nextWriteIndexAndGeneration(Metadata clusterMetadata)
      Performs a dummy rollover on a DataStream instance and returns the tuple of the next write index name and next generation that this DataStream should roll over to using rollover(Index, long).
      Parameters:
      clusterMetadata - Cluster metadata
      Returns:
      new DataStream instance with the dummy rollover operation applied
    • unsafeNextWriteIndexAndGeneration

      public org.elasticsearch.core.Tuple<String,Long> unsafeNextWriteIndexAndGeneration(Metadata clusterMetadata)
      Like nextWriteIndexAndGeneration(Metadata), but does no validation, use with care only.
    • removeBackingIndex

      public DataStream removeBackingIndex(Index index)
      Removes the specified backing index and returns a new DataStream instance with the remaining backing indices.
      Parameters:
      index - the backing index to remove
      Returns:
      new DataStream instance with the remaining backing indices
      Throws:
      IllegalArgumentException - if index is not a backing index or is the current write index of the data stream
    • replaceBackingIndex

      public DataStream replaceBackingIndex(Index existingBackingIndex, Index newBackingIndex)
      Replaces the specified backing index with a new index and returns a new DataStream instance with the modified backing indices. An IllegalArgumentException is thrown if the index to be replaced is not a backing index for this data stream or if it is the DataStream's write index.
      Parameters:
      existingBackingIndex - the backing index to be replaced
      newBackingIndex - the new index that will be part of the DataStream
      Returns:
      new DataStream instance with backing indices that contain replacement index instead of the specified existing index.
    • addBackingIndex

      public DataStream addBackingIndex(Metadata clusterMetadata, Index index)
      Adds the specified index as a backing index and returns a new DataStream 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 - if index is ineligible to be a backing index for the data stream
    • promoteDataStream

      public DataStream promoteDataStream()
    • snapshot

      @Nullable public DataStream snapshot(Collection<String> indicesInSnapshot)
      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 or null if no reconciled version of this data stream could be built from the given indices
    • getDefaultBackingIndexName

      public 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.
      Parameters:
      dataStreamName - name of the data stream
      generation - 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 stream
      generation - generation of the data stream
      epochMillis - creation time for the backing index
      Returns:
      backing index name
    • readDiffFrom

      public static Diff<DataStream> readDiffFrom(StreamInput in) throws IOException
      Throws:
      IOException
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • fromXContent

      public static DataStream fromXContent(org.elasticsearch.xcontent.XContentParser parser) throws IOException
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object