Class RetentionLeases

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

public class RetentionLeases extends Object implements org.elasticsearch.common.xcontent.ToXContentFragment, Writeable
Represents a versioned collection of retention leases. We version the collection of retention leases to ensure that sync requests that arrive out of order on the replica, using the version to ensure that older sync requests are rejected.
  • 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
    Modifier and Type
    Field
    Description
    Represents an empty an un-versioned retention lease collection.

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

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    RetentionLeases(long primaryTerm, long version, Collection<RetentionLease> leases)
    Constructs a new retention lease collection with the specified version and underlying collection of retention leases.
    Constructs a new retention lease collection from a stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this retention lease collection contains a retention lease with the specified RetentionLease.id().
    boolean
     
    fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
    Parses a retention leases collection from XContent.
    get(String id)
    Returns the retention lease with the specified ID, or null if no such retention lease exists.
    int
     
    The underlying collection of retention leases
    long
    The primary term of this retention lease collection.
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    long
    The version of this retention lease collection.
    void
    Writes a retention lease collection to a stream in a manner suitable for later reconstruction via RetentionLeases(StreamInput) (StreamInput)}.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment

    isFragment
  • Field Details

    • EMPTY

      public static RetentionLeases EMPTY
      Represents an empty an un-versioned retention lease collection. This is used when no retention lease collection is found in the commit point
  • Constructor Details

    • RetentionLeases

      public RetentionLeases(long primaryTerm, long version, Collection<RetentionLease> leases)
      Constructs a new retention lease collection with the specified version and underlying collection of retention leases.
      Parameters:
      primaryTerm - the primary term under which this retention lease collection was created
      version - the version of this retention lease collection
      leases - the retention leases
    • RetentionLeases

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

    • primaryTerm

      public long primaryTerm()
      The primary term of this retention lease collection.
      Returns:
      the primary term
    • version

      public long version()
      The version of this retention lease collection. The version is managed on the primary and incremented any time that a retention lease is added, renewed, or when retention leases expire.
      Returns:
      the version of this retention lease collection
    • leases

      public Collection<RetentionLease> leases()
      The underlying collection of retention leases
      Returns:
      the retention leases
    • contains

      public boolean contains(String id)
      Checks if this retention lease collection contains a retention lease with the specified RetentionLease.id().
      Parameters:
      id - the retention lease ID
      Returns:
      true if this retention lease collection contains a retention lease with the specified ID, otherwise false
    • get

      public RetentionLease get(String id)
      Returns the retention lease with the specified ID, or null if no such retention lease exists.
      Parameters:
      id - the retention lease ID
      Returns:
      the retention lease, or null if no retention lease with the specified ID exists
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Writes a retention lease collection to a stream in a manner suitable for later reconstruction via RetentionLeases(StreamInput) (StreamInput)}.
      Specified by:
      writeTo in interface Writeable
      Parameters:
      out - the stream to write the retention lease collection 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
    • fromXContent

      public static RetentionLeases fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
      Parses a retention leases collection from XContent. This method assumes that the retention leases were converted to XContent via toXContent(XContentBuilder, Params).
      Parameters:
      parser - the parser
      Returns:
      a retention leases collection
    • 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