public record SeqNoPrimaryTerm(long sequenceNumber, long primaryTerm)
extends Record
A container for seq_no and primary_term values. When an entity class contains a field of this type, it will be
automatically filled with SeqNoPrimaryTerm instance on read operations (like get or search), and also, when the
SeqNoPrimaryTerm is not null and filled with seq_no and primary_term, they will be sent to Elasticsearch
when indexing such an entity.
This allows to implement optimistic locking pattern for full-update scenario, when an entity is first read from
Elasticsearch and then gets reindexed with new _content. Index operations will throw an
OptimisticLockingFailureException if the seq_no + primary_term pair already has
different values for the given document. See Elasticsearch documentation for more information:
https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html
A property of this type is implicitly @Transient and never gets included
into a mapping at Elasticsearch side.
A SeqNoPrimaryTerm instance cannot contain an invalid or unassigned seq_no or primary_term.
publicSeqNoPrimaryTerm(long sequenceNumber,
long primaryTerm)
Creates an instance of SeqNoPrimaryTerm with the given seq_no and primary_term. The passed values are validated:
sequenceNumber must be non-negative, primaryTerm must be positive. If validation fails, an IllegalArgumentException
is thrown.
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.