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 java.lang.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
    static RetentionLeases EMPTY
    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, java.util.Collection<RetentionLease> leases)
    Constructs a new retention lease collection with the specified version and underlying collection of retention leases.
    RetentionLeases​(StreamInput in)
    Constructs a new retention lease collection from a stream.
  • Method Summary

    Modifier and Type Method Description
    boolean contains​(java.lang.String id)
    Checks if this retention lease collection contains a retention lease with the specified RetentionLease.id().
    boolean equals​(java.lang.Object o)  
    static RetentionLeases fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)
    Parses a retention leases collection from XContent.
    RetentionLease get​(java.lang.String id)
    Returns the retention lease with the specified ID, or null if no such retention lease exists.
    int hashCode()  
    java.util.Collection<RetentionLease> leases()
    The underlying collection of retention leases
    long primaryTerm()
    The primary term of this retention lease collection.
    java.lang.String toString()  
    org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)  
    long version()
    The version of this retention lease collection.
    void writeTo​(StreamOutput out)
    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, java.util.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 java.io.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:
      java.io.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 java.util.Collection<RetentionLease> leases()
      The underlying collection of retention leases
      Returns:
      the retention leases
    • contains

      public boolean contains​(java.lang.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​(java.lang.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 java.io.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:
      java.io.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 java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.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​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object