Package org.jgroups.util
Class UUID
java.lang.Object
org.jgroups.util.UUID
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,Comparable<Address>,Address,Streamable
- Direct Known Subclasses:
AdditionalDataUUID,PayloadUUID,TopologyUUID
Logical address which is unique over space and time.
Copied from java.util.UUID, but unneeded fields from the latter have been removed. UUIDs needs to have a small memory footprint.
Copied from java.util.UUID, but unneeded fields from the latter have been removed. UUIDs needs to have a small memory footprint.
- Author:
- Bela Ban
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected static LazyRemovalCache<Address, String> Keeps track of associations between logical addresses (UUIDs) and logical namesprotected longprotected longprotected static SecureRandomThe random number generator used by this class to create random based UUIDsprotected static final LazyRemovalCache.Printable<Address, String> protected static booleanprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidclone()intCompares this UUID with the specified UUID.protected static Stringdigits(long val, int digits) Returns val represented by the specified number of hex digits.booleanCompares this object to the specified object.static Stringfinal byte[]Deprecated.Will be removed in 3.0.Returns a copy of the cache's contentslonglongReturns the most significant 64 bits of this UUID's 128 bit value.inthashCode()Returns a hash code for thisUUID.booleanChecks whether this is an address that represents multiple destinations; e.g., a class D address in the Internet.static Stringstatic UUIDStatic factory to retrieve a type 4 (pseudo randomly generated) UUID.voidvoidRead the state of the current object (including superclasses) from instream Note that the input stream must not be closedstatic voidstatic voidremoveAll(Collection<Address> mbrs) static voidretainAll(Collection<Address> logical_addrs) final voidsetAdditionalData(byte[] additional_data) Deprecated.Will be removed in 3.0.intsize()Returns serialized size of this addresstoString()Returns aStringobject representing thisUUID.voidvoidwriteTo(DataOutputStream out) Write the entire state of the current object (including superclasses) to outstream.
-
Field Details
-
mostSigBits
protected long mostSigBits -
leastSigBits
protected long leastSigBits -
additional_data
protected byte[] additional_data -
numberGenerator
The random number generator used by this class to create random based UUIDs -
cache
Keeps track of associations between logical addresses (UUIDs) and logical names -
print_uuids
protected static boolean print_uuids -
SIZE
protected static final int SIZE- See Also:
-
print_function
-
-
Constructor Details
-
UUID
public UUID() -
UUID
public UUID(long mostSigBits, long leastSigBits) -
UUID
protected UUID(byte[] data) Private constructor which uses a byte array to construct the new UUID
-
-
Method Details
-
add
-
add
-
get
-
getContents
Returns a copy of the cache's contents -
remove
-
removeAll
-
retainAll
-
printCache
-
getAdditionalData
public final byte[] getAdditionalData()Deprecated.Will be removed in 3.0. This was only added to be backwards compatible with 2.7Returns the additional_data.- Returns:
- byte[]
- Since:
- 2.8
-
setAdditionalData
public final void setAdditionalData(byte[] additional_data) Deprecated.Will be removed in 3.0. This was only added to be backwards compatible with 2.7Sets the additional_data.- Parameters:
additional_data- The additional_data to set- Since:
- 2.8
-
randomUUID
Static factory to retrieve a type 4 (pseudo randomly generated) UUID. TheUUIDis generated using a cryptographically strong pseudo random number generator.- Returns:
- A randomly generated
UUID
-
getLeastSignificantBits
public long getLeastSignificantBits() -
getMostSignificantBits
public long getMostSignificantBits()Returns the most significant 64 bits of this UUID's 128 bit value.- Returns:
- The most significant 64 bits of this UUID's 128 bit value
-
toString
-
toStringLong
Returns aStringobject representing thisUUID.The UUID string representation is as described by this BNF:
UUID = <time_low> "-" <time_mid> "-" <time_high_and_version> "-" <variant_and_sequence> "-" <node> time_low = 4*<hexOctet> time_mid = 2*<hexOctet> time_high_and_version = 2*<hexOctet> variant_and_sequence = 2*<hexOctet> node = 6*<hexOctet> hexOctet = <hexDigit><hexDigit> hexDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"- Returns:
- A string representation of this
UUID
-
digits
Returns val represented by the specified number of hex digits. -
hashCode
public int hashCode()Returns a hash code for thisUUID. -
equals
Compares this object to the specified object. The result istrueif and only if the argument is notnull, is aUUIDobject, has the same variant, and contains the same value, bit for bit, as thisUUID. -
compareTo
Compares this UUID with the specified UUID.The first of two UUIDs is greater than the second if the most significant field in which the UUIDs differ is greater for the first UUID.
- Specified by:
compareToin interfaceComparable<Address>- Parameters:
other-UUIDto which thisUUIDis to be compared- Returns:
- -1, 0 or 1 as this
UUIDis less than, equal to, or greater thanval
-
writeTo
Description copied from interface:StreamableWrite the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeToin interfaceStreamable- Throws:
IOException
-
readFrom
public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException Description copied from interface:StreamableRead the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFromin interfaceStreamable- Throws:
IOExceptionIllegalAccessExceptionInstantiationException
-
isMulticastAddress
public boolean isMulticastAddress()Description copied from interface:AddressChecks whether this is an address that represents multiple destinations; e.g., a class D address in the Internet.- Specified by:
isMulticastAddressin interfaceAddress- Returns:
- true if this is a multicast address, false if it is a unicast address
-
size
public int size()Description copied from interface:AddressReturns serialized size of this address -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-