Class Digest
java.lang.Object
org.jgroups.util.Digest
- All Implemented Interfaces:
Iterable<Digest.Entry>, Constructable<Digest>, SizeStreamable, Streamable
- Direct Known Subclasses:
MutableDigest
public class Digest
extends Object
implements SizeStreamable, Iterable<Digest.Entry>, Constructable<Digest>
A message digest containing - for each member - the highest seqno delivered (hd) and the highest seqno received (hr).
The seqnos are stored according to the order of the members in the associated membership, ie. seqnos[0] is the hd for
member members[0], seqnos[1] is the hr for the same member, seqnos[2] is the hd for members[1] and so on.
Field 'members' may refer to the View.members, e.g. in a JoinRsp where we ship a view and a digest referring to the view's membership. This is done to conserve memory.
This class is immutable except for 2 cases:
- The contents are read when unmarshalling (readFrom())
- The membership is set with members(). This must only be done directly after unmarshalling
- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordKeeps track of one members plus its highest delivered and received seqnosprotected class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDigest()Used for serializationCreates a new digest from an existing map by copying the keys and values from mapOnly used internally, don't use !Only used for testing -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()protected voidbooleanbooleancontainsAll(Address... members) copy()create()Creates an instance of the class implementing this interfaceprotected voidcreateArrays(Map<Address, long[]> map) boolean2 digests are equal if their memberships match and all highest-delivered and highest-received seqnos matchprotected intlong[]Returns the highest delivered and received seqnos associated with a member.Address[]Don't use, this method is reserved for Bela ! :-)iterator()voidRead the state of the current object (including superclasses) from instream Note that the input stream must not be closedvoidintReturns the size (in bytes) of the marshalled objectintserializedSize(boolean with_members) toString()voidwriteTo(DataOutput out) Write the entire state of the current object (including superclasses) to outstream.voidwriteTo(DataOutput out, boolean write_addrs) Methods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
members
-
seqnos
protected long[] seqnos
-
-
Constructor Details
-
Digest
public Digest()Used for serialization -
Digest
-
Digest
Only used internally, don't use ! -
Digest
Only used for testing -
Digest
-
Digest
-
-
Method Details
-
create
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<Digest>- Returns:
- Supplier
-
getMembersRaw
Don't use, this method is reserved for Bela ! :-) -
capacity
public int capacity() -
contains
-
containsAll
-
equals
-
get
Returns the highest delivered and received seqnos associated with a member.- Returns:
- An array of 2 elements: highest_delivered and highest_received seqnos
-
iterator
- Specified by:
iteratorin interfaceIterable<Digest.Entry>
-
copy
-
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
-
writeTo
- Throws:
IOException
-
readFrom
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:
IOExceptionClassNotFoundException
-
readFrom
- Throws:
IOExceptionClassNotFoundException
-
serializedSize
public int serializedSize()Description copied from interface:SizeStreamableReturns the size (in bytes) of the marshalled object- Specified by:
serializedSizein interfaceSizeStreamable
-
serializedSize
public int serializedSize(boolean with_members) -
toString
-
toString
-
toString
-
find
-
createArrays
-
checkPostcondition
protected void checkPostcondition()
-