public class DefaultNodeIdentifierStrategy extends Object implements NodeIdentifierStrategy
| Modifier and Type | Field and Description |
|---|---|
protected long |
nodeIdentifier |
protected Random |
random |
| Constructor and Description |
|---|
DefaultNodeIdentifierStrategy() |
| Modifier and Type | Method and Description |
|---|---|
long |
getNodeIdentifier()
Return a random node identifier.
|
protected long |
getRandomMulticastNodeIdentifier()
Return a random generated node identifier.
|
protected long nodeIdentifier
protected Random random
public long getNodeIdentifier()
SecureRandom to generate 'cryptographic quality random
number'. The first generated number is returned for all calls.
### RFC-4122 - 4.1.6. Node
(2a) 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
(1b) This section describes how to generate a version 1 UUID if an IEEE
802 address is not available, or its use is not desired.
(2b) One approach is to contact the IEEE and get a separate block of
addresses. At the time of writing, the application could be found at
http://standards.ieee.org/regauth/oui/pilot-ind.html, and the cost was
US$550.
(3b) 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 getRandomMulticastNodeIdentifier()
getNodeIdentifier()Copyright © 2019. All rights reserved.