Package org.jgroups.util
Class Digest
java.lang.Object
org.jgroups.util.Digest
- All Implemented Interfaces:
Externalizable
,Serializable
,Streamable
- Direct Known Subclasses:
MutableDigest
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class keeping track of the lowest and highest sequence numbers delivered, and the highest sequence numbers received, per member. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Digest
protected static final org.apache.commons.logging.Log
protected final Map
<Address, Digest.Entry> Map<Address, Entry> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
copy()
difference
(Digest other) boolean
Returns the Entry for the given sender.Returns an unmodifiable map, so modifications will result in exceptionslong
highestDeliveredSeqnoAt
(Address sender) long
highestReceivedSeqnoAt
(Address sender) highestSequence
(Digest other) boolean
isGreaterThanOrEqual
(Digest other) Returns true if all senders of the current digest have their seqnos >= the ones from otherlong
lowSeqnoAt
(Address sender) void
void
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedboolean
sameSenders
(Digest other) Compares two digests and returns true if the senders are the same, otherwise false.long
int
size()
toString()
void
void
writeTo
(DataOutputStream out) Write the entire state of the current object (including superclasses) to outstream.
-
Field Details
-
EMPTY_DIGEST
-
senders
Map<Address, Entry> -
log
protected static final org.apache.commons.logging.Log log
-
-
Constructor Details
-
Digest
public Digest()Used for externalization -
Digest
public Digest(int size) -
Digest
Creates a new digest from an existing map by copying the keys and values from map -
Digest
-
Digest
-
Digest
-
-
Method Details
-
getSenders
Returns an unmodifiable map, so modifications will result in exceptions -
equals
-
contains
-
get
Returns the Entry for the given sender. Note that Entry is immutable -
sameSenders
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.
-
difference
-
highestSequence
-
size
public int size() -
lowSeqnoAt
-
highestDeliveredSeqnoAt
-
highestReceivedSeqnoAt
-
isGreaterThanOrEqual
Returns true if all senders of the current digest have their seqnos >= the ones from other- Parameters:
other
-- Returns:
-
copy
-
toString
-
printHighestDeliveredSeqnos
-
printHighestReceivedSeqnos
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeTo
Description copied from interface:Streamable
Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeTo
in interfaceStreamable
- Throws:
IOException
-
readFrom
public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException Description copied from interface:Streamable
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFrom
in interfaceStreamable
- Throws:
IOException
IllegalAccessException
InstantiationException
-
serializedSize
public long serializedSize()
-