Package org.jgroups.util
Class ExtendedUUID
- java.lang.Object
-
- org.jgroups.util.UUID
-
- org.jgroups.util.FlagsUUID
-
- org.jgroups.util.ExtendedUUID
-
- All Implemented Interfaces:
java.lang.Comparable<Address>,Address,Constructable<UUID>,SizeStreamable,Streamable
- Direct Known Subclasses:
SiteUUID
public class ExtendedUUID extends FlagsUUID
Subclass ofUUIDaccommodating additional data such as a flag and a small hashmap. There may be many instances in memory, and as they are serialized a lot and sent across the wire, I tried to make this as compact as possible. As a consequence, the hashmap can have a max size of 255 and a value can have a max length of 255 bytes.- Since:
- 3.5
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[][]keysprotected static java.util.function.Function<ExtendedUUID,java.lang.String>print_functionprotected byte[][]values-
Fields inherited from class org.jgroups.util.UUID
leastSigBits, mostSigBits, SIZE
-
Fields inherited from interface org.jgroups.Address
IP_ADDR, IP_ADDR_UUID, NULL, SITE_MASTER, SITE_UUID, UUID_ADDR
-
-
Constructor Summary
Constructors Modifier Constructor Description ExtendedUUID()protectedExtendedUUID(byte[] data)ExtendedUUID(long mostSigBits, long leastSigBits)ExtendedUUID(T o)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FlagsUUID>
TaddContents(T o)java.util.function.Supplier<? extends UUID>create()Creates an instance of the class implementing this interfacebyte[]get(byte[] key)byte[]get(java.lang.String key)booleankeyExists(byte[] key)booleankeyExists(java.lang.String key)intlength()The number of non-null keysjava.lang.Stringprint()ExtendedUUIDput(byte[] key, byte[] val)protected ExtendedUUIDput(int start_index, byte[] key, byte[] val)ExtendedUUIDput(java.lang.String key, byte[] val)static ExtendedUUIDrandomUUID()static ExtendedUUIDrandomUUID(java.lang.String name)protected voidread(java.io.DataInput in)voidreadFrom(java.io.DataInput in)Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedbyte[]remove(byte[] key)byte[]remove(java.lang.String key)protected voidresize(int new_length)intserializedSize()The number of bytes required to serialize this instancestatic voidsetPrintFunction(java.util.function.Function<ExtendedUUID,java.lang.String> f)protected intsizeofHashMap()java.lang.StringtoString()protected voidwrite(java.io.DataOutput out)voidwriteTo(java.io.DataOutput out)Write the entire state of the current object (including superclasses) to outstream.-
Methods inherited from class org.jgroups.util.UUID
compareTo, copy, digits, equals, fromString, generateRandomBytes, getLeastSignificantBits, getMostSignificantBits, hashCode, toStringLong
-
-
-
-
Field Detail
-
keys
protected byte[][] keys
-
values
protected byte[][] values
-
print_function
protected static java.util.function.Function<ExtendedUUID,java.lang.String> print_function
-
-
Method Detail
-
create
public java.util.function.Supplier<? extends UUID> create()
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<UUID>- Overrides:
createin classFlagsUUID
-
setPrintFunction
public static void setPrintFunction(java.util.function.Function<ExtendedUUID,java.lang.String> f)
-
randomUUID
public static ExtendedUUID randomUUID()
-
randomUUID
public static ExtendedUUID randomUUID(java.lang.String name)
-
get
public byte[] get(byte[] key)
-
get
public byte[] get(java.lang.String key)
-
put
public ExtendedUUID put(byte[] key, byte[] val)
-
put
protected ExtendedUUID put(int start_index, byte[] key, byte[] val)
-
put
public ExtendedUUID put(java.lang.String key, byte[] val)
-
remove
public byte[] remove(byte[] key)
-
remove
public byte[] remove(java.lang.String key)
-
keyExists
public boolean keyExists(byte[] key)
-
keyExists
public boolean keyExists(java.lang.String key)
-
addContents
public <T extends FlagsUUID> T addContents(T o)
- Overrides:
addContentsin classFlagsUUID
-
writeTo
public void writeTo(java.io.DataOutput out) throws java.io.IOExceptionDescription 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- Overrides:
writeToin classFlagsUUID- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInput in) throws java.io.IOExceptionDescription 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- Overrides:
readFromin classFlagsUUID- Throws:
java.io.IOException
-
serializedSize
public int serializedSize()
The number of bytes required to serialize this instance- Specified by:
serializedSizein interfaceSizeStreamable- Overrides:
serializedSizein classFlagsUUID
-
length
public int length()
The number of non-null keys
-
print
public java.lang.String print()
-
write
protected void write(java.io.DataOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
read
protected void read(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
sizeofHashMap
protected int sizeofHashMap()
-
resize
protected void resize(int new_length)
-
-