Package org.elasticsearch.index.seqno
Class RetentionLeases
- java.lang.Object
-
- org.elasticsearch.index.seqno.RetentionLeases
-
- All Implemented Interfaces:
Writeable
,ToXContent
public class RetentionLeases extends java.lang.Object implements ToXContent, 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
ToXContent.DelegatingMapParams, ToXContent.MapParams, 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 specifiedRetentionLease.id()
.boolean
equals(java.lang.Object o)
static RetentionLeases
fromXContent(XContentParser parser)
Parses a retention leases collection fromXContent
.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 leaseslong
primaryTerm()
The primary term of this retention lease collection.java.lang.String
toString()
XContentBuilder
toXContent(XContentBuilder builder, 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 viaRetentionLeases(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.ToXContent
isFragment
-
-
-
-
Field Detail
-
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 Detail
-
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 createdversion
- the version of this retention lease collectionleases
- 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 viawriteTo(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 Detail
-
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 specifiedRetentionLease.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 viaRetentionLeases(StreamInput)
(StreamInput)}.
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
fromXContent
public static RetentionLeases fromXContent(XContentParser parser)
Parses a retention leases collection fromXContent
. This method assumes that the retention leases were converted toXContent
viatoXContent(XContentBuilder, Params)
.- Parameters:
parser
- the parser- Returns:
- a retention leases collection
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-