Class MacNodeIdentifierStrategy
- java.lang.Object
-
- com.github.f4b6a3.uuid.strategy.nodeid.MacNodeIdentifierStrategy
-
- All Implemented Interfaces:
NodeIdentifierStrategy
public class MacNodeIdentifierStrategy extends Object implements NodeIdentifierStrategy
Strategy that provides the current machine address (MAC), if available. If no MAC is found, a random node identifier is returned.
-
-
Field Summary
Fields Modifier and Type Field Description protected longnodeIdentifier
-
Constructor Summary
Constructors Constructor Description MacNodeIdentifierStrategy()Algorithm to find the hardware address: It looks for the first MAC that can be found.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longgetHardwareAddress()Returns the hardware address (MAC), if available.longgetNodeIdentifier()Get the current node identifier.
-
-
-
Constructor Detail
-
MacNodeIdentifierStrategy
public MacNodeIdentifierStrategy()
Algorithm to find the hardware address: It looks for the first MAC that can be found. First it tries to find the MAC that is associated with the host name. Otherwise, it tries to find the first MAC that is up and running. This second try may be very expensive on Windows, because it iterates over a lot of virtual network interfaces created by the operating system. ### RFC-4122 - 4.1.6. Node (1) For UUID version 1, the node field consists of an IEEE 802 MAC address, usually the host address. For systems with multiple IEEE 802 addresses, any available one can be used. The lowest addressed octet (octet number 10) contains the global/local bit and the unicast/multicast bit, and is the first octet of the address transmitted on an 802.3 LAN. (2) 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.
-
-
Method Detail
-
getNodeIdentifier
public long getNodeIdentifier()
Get the current node identifier.- Specified by:
getNodeIdentifierin interfaceNodeIdentifierStrategy- Returns:
- a node identifier
-
getHardwareAddress
protected long getHardwareAddress()
Returns the hardware address (MAC), if available.getNodeIdentifier()- Returns:
- a hardware address
-
-