@ThreadSafe public final class SnowcastSequenceUtils extends Object
SnowcastTimestampComparator
would have to.Modifier and Type | Method and Description |
---|---|
static int |
compareSequence(long sequenceId1,
long sequenceId2)
This helper method provides a comparison implementation to order or compare two distinct
sequence ids by their internal timestamp and counter value.
|
static int |
compareSequence(long sequenceId1,
long sequenceId2,
int maxLogicalNodeCount)
This helper method provides a comparison implementation to order or compare two distinct
sequence ids by their internal timestamp and counter value.
|
static int |
compareTimestamp(long sequenceId1,
long sequenceId2)
This helper method provides a comparison implementation to order or compare two distinct
sequence ids by their internal timestamp value.
|
static int |
counterValue(long sequenceId)
This helper method extracts the counter value from a given sequence id.
|
static int |
counterValue(long sequenceId,
int maxLogicalNodeCount)
This helper method extracts the counter value from a given sequence id.
|
static int |
logicalNodeId(long sequenceId)
This helper method extracts the logicalNodeId from a given sequence id.
|
static int |
logicalNodeId(long sequenceId,
int maxLogicalNodeCount)
This helper method extracts the logicalNodeId from a given sequence id.
|
static Comparator<Long> |
snowcastSequenceComparator(SnowcastSequencer sequencer)
Creates a new
SnowcastSequenceComparator instance based on the
given SnowcastSequencer 's internal configuration. |
static long |
timestampValue(long sequenceId)
This helper method extracts the timestamp value from a given sequence id.
|
@Nonnull public static Comparator<Long> snowcastSequenceComparator(@Nonnull SnowcastSequencer sequencer)
SnowcastSequenceComparator
instance based on the
given SnowcastSequencer
's internal configuration. This is a
convenience method over customly creating the comparator instance.sequencer
- the SnowcastSequencer to retrieve the maximum logical node count value from@Nonnegative public static long timestampValue(long sequenceId)
compareTimestamp(long, long)
as
well as SnowcastTimestampComparator
.sequenceId
- the sequence id to extract the timestamp value from@Nonnegative public static int logicalNodeId(long sequenceId)
This helper method extracts the logicalNodeId from a given sequence id. This logicalNodeId identifies the logical node at generation time. Since assignment is automatic and there is no guarantee that a node has always the same logicalNodeId users are not expected to make assumptions based on this id!.
This overload always assumes a maximal node count of 8192 nodes. For a divergent number of maximum
nodes at generation time of the sequenceId please use logicalNodeId(long, int)
and specify the
maximum node count.
sequenceId
- the sequence id to extract the logicalNodeId value from@Nonnegative public static int logicalNodeId(long sequenceId, @Min(value=128L) @Max(value=8192L) int maxLogicalNodeCount)
This helper method extracts the logicalNodeId from a given sequence id. This logicalNodeId identifies the logical node at generation time. Since assignment is automatic and there is no guarantee that a node has always the same logicalNodeId users are not expected to make assumptions based on this id!.
sequenceId
- the sequence id to extract the logicalNodeId value frommaxLogicalNodeCount
- the maximum node count that was specified at generation timeSnowcastMaxLogicalNodeIdOutOfBoundsException
- when maxLogicalNodeCount is outside of the legal range@Nonnegative public static int counterValue(long sequenceId)
This helper method extracts the counter value from a given sequence id. This counter value identifies the order and count of generated sequence ids on a node in this ids timestamp value.
This overload always assumes a maximal node count of 8192 nodes. For a divergent number of maximum
nodes at generation time of the sequenceId please use counterValue(long, int)
and specify the
maximum node count.
sequenceId
- the sequence id to extract the counter value from@Nonnegative public static int counterValue(long sequenceId, @Min(value=128L) @Max(value=8192L) int maxLogicalNodeCount)
This helper method extracts the counter value from a given sequence id. This counter value identifies the order and count of generated sequence ids on a node in this ids timestamp value.
sequenceId
- the sequence id to extract the logicalNodeId value frommaxLogicalNodeCount
- the maximum node count that was specified at generation timeSnowcastMaxLogicalNodeIdOutOfBoundsException
- when maxLogicalNodeCount is outside of the legal rangepublic static int compareTimestamp(long sequenceId1, long sequenceId2)
sequenceId1
- the first sequence id to be comparedsequenceId2
- the second sequence if to be comparedpublic static int compareSequence(long sequenceId1, long sequenceId2)
This helper method provides a comparison implementation to order or compare two distinct sequence ids by their internal timestamp and counter value.
This overload always assumes a maximal node count of 8192 nodes. For a divergent number of maximum
nodes at generation time of the sequenceId please use compareSequence(long, long, int)
and
specify the maximum node count.
sequenceId1
- the first sequence id to be comparedsequenceId2
- the second sequence if to be comparedpublic static int compareSequence(long sequenceId1, long sequenceId2, @Min(value=128L) @Max(value=8192L) int maxLogicalNodeCount)
sequenceId1
- the first sequence id to be comparedsequenceId2
- the second sequence if to be comparedmaxLogicalNodeCount
- the maximum node count that was specified at generation timeSnowcastMaxLogicalNodeIdOutOfBoundsException
- when maxLogicalNodeCount is outside of the legal rangeCopyright © 2014-2017. All Rights Reserved.