Package org.jgroups.util
Class Digest
- java.lang.Object
-
- org.jgroups.util.Digest
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,Streamable
- Direct Known Subclasses:
MutableDigest
public class Digest extends java.lang.Object implements java.io.Externalizable, Streamable
A message digest, which is used by the PBCAST layer for gossiping (also used by NAKACK for keeping track of current seqnos for all members). It contains pairs of senders and a range of seqnos (low and high), where each sender is associated with its highest and lowest seqnos seen so far. That is, the lowest seqno which was not yet garbage-collected and the highest that was seen so far and is deliverable (or was already delivered) to the application. A range of [0 - 0] means no messages have been received yet.April 3 2001 (bela): Added high_seqnos_seen member. It is used to disseminate information about the last (highest) message M received from a sender P. Since we might be using a negative acknowledgment message numbering scheme, we would never know if the last message was lost. Therefore we periodically gossip and include the last message seqno. Members who haven't seen it (e.g. because msg was dropped) will request a retransmission. See DESIGN for details.
- Version:
- $Id: Digest.java,v 1.8.2.1 2008/01/22 10:01:17 belaban Exp $
- Author:
- Bela Ban
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDigest.EntryClass keeping track of the lowest and highest sequence numbers delivered, and the highest sequence numbers received, per member.
-
Field Summary
Fields Modifier and Type Field Description static DigestEMPTY_DIGESTprotected static org.apache.commons.logging.Loglogprotected java.util.Map<Address,Digest.Entry>sendersMap<Address, Entry>
-
Constructor Summary
Constructors Constructor Description Digest()Used for externalizationDigest(int size)Digest(java.util.Map<Address,Digest.Entry> map)Creates a new digest from an existing map by copying the keys and values from mapDigest(Address sender, long low, long highest_delivered)Digest(Address sender, long low, long highest_delivered, long highest_received)Digest(Digest d)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Address sender)Digestcopy()Digestdifference(Digest other)booleanequals(java.lang.Object obj)Digest.Entryget(Address sender)Returns the Entry for the given sender.java.util.Map<Address,Digest.Entry>getSenders()Returns an unmodifiable map, so modifications will result in exceptionslonghighestDeliveredSeqnoAt(Address sender)longhighestReceivedSeqnoAt(Address sender)DigesthighestSequence(Digest other)booleanisGreaterThanOrEqual(Digest other)Returns true if all senders of the current digest have their seqnos >= the ones from otherlonglowSeqnoAt(Address sender)java.lang.StringprintHighestDeliveredSeqnos()java.lang.StringprintHighestReceivedSeqnos()voidreadExternal(java.io.ObjectInput in)voidreadFrom(java.io.DataInputStream in)Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedbooleansameSenders(Digest other)Compares two digests and returns true if the senders are the same, otherwise false.longserializedSize()intsize()java.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)voidwriteTo(java.io.DataOutputStream out)Write the entire state of the current object (including superclasses) to outstream.
-
-
-
Field Detail
-
EMPTY_DIGEST
public static final Digest EMPTY_DIGEST
-
senders
protected final java.util.Map<Address,Digest.Entry> senders
Map<Address, Entry>
-
log
protected static final org.apache.commons.logging.Log log
-
-
Constructor Detail
-
Digest
public Digest()
Used for externalization
-
Digest
public Digest(int size)
-
Digest
public Digest(java.util.Map<Address,Digest.Entry> map)
Creates a new digest from an existing map by copying the keys and values from map
-
Digest
public Digest(Digest d)
-
Digest
public Digest(Address sender, long low, long highest_delivered, long highest_received)
-
Digest
public Digest(Address sender, long low, long highest_delivered)
-
-
Method Detail
-
getSenders
public java.util.Map<Address,Digest.Entry> getSenders()
Returns an unmodifiable map, so modifications will result in exceptions
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
contains
public boolean contains(Address sender)
-
get
public Digest.Entry get(Address sender)
Returns the Entry for the given sender. Note that Entry is immutable
-
sameSenders
public boolean sameSenders(Digest other)
Compares two digests and returns true if the senders are the same, otherwise false.- Parameters:
other-- Returns:
- True if senders are the same, otherwise false.
-
size
public int size()
-
lowSeqnoAt
public long lowSeqnoAt(Address sender)
-
highestDeliveredSeqnoAt
public long highestDeliveredSeqnoAt(Address sender)
-
highestReceivedSeqnoAt
public long highestReceivedSeqnoAt(Address sender)
-
isGreaterThanOrEqual
public boolean isGreaterThanOrEqual(Digest other)
Returns true if all senders of the current digest have their seqnos >= the ones from other- Parameters:
other-- Returns:
-
copy
public Digest copy()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
printHighestDeliveredSeqnos
public java.lang.String printHighestDeliveredSeqnos()
-
printHighestReceivedSeqnos
public java.lang.String printHighestReceivedSeqnos()
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeTo
public void writeTo(java.io.DataOutputStream 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- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInputStream in) throws java.io.IOException, java.lang.IllegalAccessException, java.lang.InstantiationExceptionDescription 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:
java.io.IOExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationException
-
serializedSize
public long serializedSize()
-
-