public class RandomNodeIdentifierStrategy extends Object implements NodeIdentifierStrategy
| Constructor and Description |
|---|
RandomNodeIdentifierStrategy() |
RandomNodeIdentifierStrategy(Random random) |
| Modifier and Type | Method and Description |
|---|---|
long |
getNodeIdentifier()
Return a new random node identifier for every call.
|
protected long |
getRandomNodeIdentifier()
Return a random generated node identifier.
|
protected Random random
public RandomNodeIdentifierStrategy()
public RandomNodeIdentifierStrategy(Random random)
public long getNodeIdentifier()
SecureRandom by default to generate 'cryptographic
quality random number'. The first generated number is returned for all
calls.
### RFC-4122 - 4.1.6. Node
For systems with no IEEE address, a randomly or pseudo-randomly generated
value may be used; see Section 4.5. The multicast bit must be set in such
addresses, in order that they will never conflict with addresses obtained
from network cards.
### RFC-4122 - 4.5. Node IDs that Do Not Identify the Host
This section describes how to generate a version 1 UUID if an IEEE 802
address is not available, or its use is not desired.
A better solution is to obtain a 47-bit cryptographic quality random
number and use it as the low 47 bits of the node ID, with the least
significant bit of the first octet of the node ID set to one. This bit is
the unicast/multicast bit, which will never be set in IEEE 802 addresses
obtained from network cards. Hence, there can never be a conflict between
UUIDs generated by machines with and without network cards. (Recall that
the IEEE 802 spec talks about transmission order, which is the opposite
of the in-memory representation that is discussed in this document.)getNodeIdentifier in interface NodeIdentifierStrategyprotected long getRandomNodeIdentifier()
getNodeIdentifier()Copyright © 2019. All rights reserved.