|
Sea 0.2.1 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gov.lbl.dsd.sea.nio.util.SequenceNumberGenerator
Utility to create long sequence numbers in a thread safe manner; useful for packet or event tagging or session/message IDs.
Sequence numbers start from a fixed seed or random seed, and then are incremented
on each invocation of nextSequenceNumber
. Random seeds can be
obtained from an insecure (but fast) source, or from a secure (but slow)
source.
Method Summary | |
static SequenceNumberGenerator |
createWithFixedSeed(long seqNum)
Creates and returns an instance with the given fixed seed |
static SequenceNumberGenerator |
createWithRandomSeed(boolean secure)
Creates and returns an instance with a secure or insecure random seed |
static int |
hashCode(long seqNum)
Returns a hashcode fo the given sequence number |
long |
nextSequenceNumber()
Increments the sequence number and returns the incremented value |
String |
toString()
Returns a string representation of the receiver |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public static SequenceNumberGenerator createWithFixedSeed(long seqNum)
seqNum
- the fixed seedpublic static SequenceNumberGenerator createWithRandomSeed(boolean secure)
secure
- shall it be secure or not?public long nextSequenceNumber()
public String toString()
public static int hashCode(long seqNum)
seqNum
- the sequence number
|
Sea 0.2.1 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |