public class DefaultNodeIdentifierStrategy extends Object implements NodeIdentifierStrategy
| Modifier and Type | Field and Description |
|---|---|
protected long |
nodeIdentifier |
| Constructor and Description |
|---|
DefaultNodeIdentifierStrategy()
This constructor works in two steps:
1.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getNodeIdentifier()
Return a random node identifier.
|
protected static long |
getRandomNodeIdentifier()
Return a random generated node identifier.
|
public DefaultNodeIdentifierStrategy()
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 static long getRandomNodeIdentifier()
RandomNodeIdentifierStrategy.getNodeIdentifier()Copyright © 2020. All rights reserved.