|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.feide.moria.store.RandomId
public final class RandomId
Returns an id that is random and unique across a cluster of JVMs. Each JVM
needs to be configured with a unique node id, identifying each node. This is
done by setting the system property no.feide.moria.store.nodeid
.
The value must be a ascii string of 3 character length. The returned id is an
encoded String (pseudo Base64, see method documentation for details)
constructed from the node id, the current time and a random string. This
should guarantee unique ids across the cluster and node restarts.
Field Summary | |
---|---|
private static byte[] |
CHAR_64
The characters used in our version of base64. |
private static int |
NO_OF_RANDOM_BITS
The number of random bits to get from the PRNG. |
private static java.security.SecureRandom |
random
The random generator. |
Constructor Summary | |
---|---|
private |
RandomId()
Default private constructor. |
Method Summary | |
---|---|
(package private) static byte[] |
longToByteArray(long in)
Takes a long value (64 bit) and returns it as an eight element byte array. |
static java.lang.String |
newId(java.lang.String nodeId)
Generate a new random id. |
(package private) static byte[] |
nodeIdToByteArray(java.lang.String nodeId)
|
(package private) static java.lang.String |
pseudoBase64Encode(byte[] bytes)
Takes a byte array and returns a string encoded with a slightly modified version of Base64. |
(package private) static byte[] |
unsignedShortToByteArray(int in)
Takes an unsigned short value (16 bit, as an 32 bit int value) and returns it as an two element byte array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.security.SecureRandom random
private static final byte[] CHAR_64
private static final int NO_OF_RANDOM_BITS
Constructor Detail |
---|
private RandomId()
Method Detail |
---|
public static java.lang.String newId(java.lang.String nodeId)
static java.lang.String pseudoBase64Encode(byte[] bytes)
bytes
- The data to convert.
static byte[] longToByteArray(long in)
in
- The long value to be converted.
static byte[] unsignedShortToByteArray(int in)
in
- the unsigned short value to be converted.
static byte[] nodeIdToByteArray(java.lang.String nodeId)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |