Package org.elasticsearch.index.seqno
Class SequenceNumbers
- java.lang.Object
-
- org.elasticsearch.index.seqno.SequenceNumbers
-
public class SequenceNumbers extends java.lang.Object
A utility class for handling sequence numbers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SequenceNumbers.CommitInfo
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LOCAL_CHECKPOINT_KEY
static java.lang.String
MAX_SEQ_NO
static long
NO_OPS_PERFORMED
Represents no operations have been performed on the shard.static long
PRE_60_NODE_CHECKPOINT
Represents a checkpoint coming from a pre-6.0 nodestatic long
UNASSIGNED_PRIMARY_TERM
Represents an unassigned primary term (e.g., when a primary shard was not yet allocated)static long
UNASSIGNED_SEQ_NO
Represents an unassigned sequence number (e.g., can be used on primary operations before they are executed).
-
Constructor Summary
Constructors Constructor Description SequenceNumbers()
-
Method Summary
Modifier and Type Method Description static SequenceNumbers.CommitInfo
loadSeqNoInfoFromLuceneCommit(java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> commitData)
Reads the sequence number stats from the commit data (maximum sequence number and local checkpoint).static long
max(long maxSeqNo, long seqNo)
Compute the maximum of the given current maximum sequence number and the specified sequence number, accounting for the fact that the current maximum sequence number could beNO_OPS_PERFORMED
orUNASSIGNED_SEQ_NO
.static long
min(long minSeqNo, long seqNo)
Compute the minimum of the given current minimum sequence number and the specified sequence number, accounting for the fact that the current minimum sequence number could beNO_OPS_PERFORMED
orUNASSIGNED_SEQ_NO
.
-
-
-
Field Detail
-
LOCAL_CHECKPOINT_KEY
public static final java.lang.String LOCAL_CHECKPOINT_KEY
- See Also:
- Constant Field Values
-
MAX_SEQ_NO
public static final java.lang.String MAX_SEQ_NO
- See Also:
- Constant Field Values
-
PRE_60_NODE_CHECKPOINT
public static final long PRE_60_NODE_CHECKPOINT
Represents a checkpoint coming from a pre-6.0 node- See Also:
- Constant Field Values
-
UNASSIGNED_SEQ_NO
public static final long UNASSIGNED_SEQ_NO
Represents an unassigned sequence number (e.g., can be used on primary operations before they are executed).- See Also:
- Constant Field Values
-
NO_OPS_PERFORMED
public static final long NO_OPS_PERFORMED
Represents no operations have been performed on the shard. Initial value of a sequence number.- See Also:
- Constant Field Values
-
UNASSIGNED_PRIMARY_TERM
public static final long UNASSIGNED_PRIMARY_TERM
Represents an unassigned primary term (e.g., when a primary shard was not yet allocated)- See Also:
- Constant Field Values
-
-
Method Detail
-
loadSeqNoInfoFromLuceneCommit
public static SequenceNumbers.CommitInfo loadSeqNoInfoFromLuceneCommit(java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> commitData)
Reads the sequence number stats from the commit data (maximum sequence number and local checkpoint).- Parameters:
commitData
- the commit data- Returns:
- the sequence number stats
-
min
public static long min(long minSeqNo, long seqNo)
Compute the minimum of the given current minimum sequence number and the specified sequence number, accounting for the fact that the current minimum sequence number could beNO_OPS_PERFORMED
orUNASSIGNED_SEQ_NO
. When the current minimum sequence number is notNO_OPS_PERFORMED
norUNASSIGNED_SEQ_NO
, the specified sequence number must not beUNASSIGNED_SEQ_NO
.- Parameters:
minSeqNo
- the current minimum sequence numberseqNo
- the specified sequence number- Returns:
- the new minimum sequence number
-
max
public static long max(long maxSeqNo, long seqNo)
Compute the maximum of the given current maximum sequence number and the specified sequence number, accounting for the fact that the current maximum sequence number could beNO_OPS_PERFORMED
orUNASSIGNED_SEQ_NO
. When the current maximum sequence number is notNO_OPS_PERFORMED
norUNASSIGNED_SEQ_NO
, the specified sequence number must not beUNASSIGNED_SEQ_NO
.- Parameters:
maxSeqNo
- the current maximum sequence numberseqNo
- the specified sequence number- Returns:
- the new maximum sequence number
-
-