Class RetentionLease

java.lang.Object
org.elasticsearch.index.seqno.RetentionLease
All Implemented Interfaces:
Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject

public final class RetentionLease extends Object implements org.elasticsearch.common.xcontent.ToXContentObject, Writeable
A "shard history retention lease" (or "retention lease" for short) is conceptually a marker containing a retaining sequence number such that all operations with sequence number at least that retaining sequence number will be retained during merge operations (which could otherwise merge away operations that have been soft deleted). Each retention lease contains a unique identifier, the retaining sequence number, the timestamp of when the lease was created or renewed, and the source of the retention lease (e.g., "ccr").
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable

    Writeable.Reader<V>, Writeable.Writer<V>
  • Field Summary

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    RetentionLease​(String id, long retainingSequenceNumber, long timestamp, String source)
    Constructs a new retention lease.
    Constructs a new retention lease from a stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals​(Object o)
     
    fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)
    Parses a retention lease from XContent.
    int
     
    id()
    The identifier for this retention lease.
    boolean
     
    long
    The retaining sequence number of this retention lease.
    The source of this retention lease.
    long
    The timestamp of when this retention lease was created or renewed.
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    void
    Writes a retention lease to a stream in a manner suitable for later reconstruction via RetentionLease(StreamInput).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RetentionLease

      public RetentionLease(String id, long retainingSequenceNumber, long timestamp, String source)
      Constructs a new retention lease.
      Parameters:
      id - the identifier of the retention lease
      retainingSequenceNumber - the retaining sequence number
      timestamp - the timestamp of when the retention lease was created or renewed
      source - the source of the retention lease
    • RetentionLease

      public RetentionLease(StreamInput in) throws IOException
      Constructs a new retention lease from a stream. The retention lease should have been written via writeTo(StreamOutput).
      Parameters:
      in - the stream to construct the retention lease from
      Throws:
      IOException - if an I/O exception occurs reading from the stream
  • Method Details

    • id

      public String id()
      The identifier for this retention lease. This identifier should be unique per lease and is set during construction by the caller.
      Returns:
      the identifier
    • retainingSequenceNumber

      public long retainingSequenceNumber()
      The retaining sequence number of this retention lease. The retaining sequence number is the minimum sequence number that this retention lease wants to retain during merge operations. The retaining sequence number is set during construction by the caller.
      Returns:
      the retaining sequence number
    • timestamp

      public long timestamp()
      The timestamp of when this retention lease was created or renewed.
      Returns:
      the timestamp used as a basis for determining lease expiration
    • source

      public String source()
      The source of this retention lease. The source is set during construction by the caller.
      Returns:
      the source
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Writes a retention lease to a stream in a manner suitable for later reconstruction via RetentionLease(StreamInput).
      Specified by:
      writeTo in interface Writeable
      Parameters:
      out - the stream to write the retention lease to
      Throws:
      IOException - if an I/O exception occurs writing to the stream
    • toXContent

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

      public boolean isFragment()
      Specified by:
      isFragment in interface org.elasticsearch.common.xcontent.ToXContent
      Specified by:
      isFragment in interface org.elasticsearch.common.xcontent.ToXContentObject
    • fromXContent

      public static RetentionLease fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
      Parses a retention lease from XContent. This method assumes that the retention lease was converted to XContent via toXContent(XContentBuilder, Params).
      Parameters:
      parser - the parser
      Returns:
      a retention lease
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object