Class RetentionLeases

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

public class RetentionLeases
extends java.lang.Object
implements 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.
  • 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 XContentBuilder toXContent​(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      java.io.IOException
    • fromXContent

      public static RetentionLeases fromXContent​(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