org.jgroups.protocols.pbcast

Class Digest

Implemented Interfaces:
Externalizable

public class Digest
extends java.lang.Object
implements Externalizable

A message digest, which is used e.g. 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.

Author:
Bela Ban

Field Summary

protected static Log
log

Constructor Summary

Digest()
Digest(int size)

Method Summary

void
add(Address sender, long low_seqno, long high_seqno)
void
add(Address sender, long low_seqno, long high_seqno, long high_seqno_seen)
void
add(Digest d)
boolean
contains(Address sender)
Digest
copy()
int
getIndex(Address sender)
long
highSeqnoAt(int index)
long
highSeqnoAt(Address sender)
long
highSeqnoSeenAt(int index)
long
highSeqnoSeenAt(Address sender)
void
incrementHighSeqno(Address sender)
Increment the sender's high_seqno by 1
long
lowSeqnoAt(int index)
void
merge(Address sender, long low_seqno, long high_seqno, long high_seqno_seen)
Similar to add(), but if the sender already exists, its seqnos will be modified (no new entry) as follows:
  1. this.low_seqno=min(this.low_seqno, low_seqno)
  2. this.high_seqno=max(this.high_seqno, high_seqno)
  3. this.high_seqno_seen=max(this.high_seqno_seen, high_seqno_seen)
If the sender doesn not exist, a new entry will be added (provided there is enough space)
void
merge(Digest d)
Adds a digest to this digest.
String
printHighSeqnos()
String
printHighSeqnosSeen()
void
readExternal(ObjectInput in)
void
reset(int size)
void
resetAt(int index)
Resets the seqnos for the sender at 'index' to 0.
boolean
sameSenders(Digest other)
Compares two digests and returns true if the senders are the same, otherwise false
Address
senderAt(int index)
void
setHighSeqnoAt(int index, long high_seqno)
void
setHighSeqnoAt(Address sender, long high_seqno)
void
setHighSeqnoSeenAt(int index, long high_seqno_seen)
void
setHighSeqnoSeenAt(Address sender, long high_seqno_seen)
void
setLowSeqnoAt(int index, long low_seqno)
int
size()
String
toString()
void
writeExternal(ObjectOutput out)

Field Details

log

protected static Log log

Constructor Details

Digest

public Digest()

Digest

public Digest(int size)

Method Details

add

public void add(Address sender,
                long low_seqno,
                long high_seqno)

add

public void add(Address sender,
                long low_seqno,
                long high_seqno,
                long high_seqno_seen)

add

public void add(Digest d)

contains

public boolean contains(Address sender)

copy

public Digest copy()

getIndex

public int getIndex(Address sender)

highSeqnoAt

public long highSeqnoAt(int index)

highSeqnoAt

public long highSeqnoAt(Address sender)

highSeqnoSeenAt

public long highSeqnoSeenAt(int index)

highSeqnoSeenAt

public long highSeqnoSeenAt(Address sender)

incrementHighSeqno

public void incrementHighSeqno(Address sender)
Increment the sender's high_seqno by 1

lowSeqnoAt

public long lowSeqnoAt(int index)

merge

public void merge(Address sender,
                  long low_seqno,
                  long high_seqno,
                  long high_seqno_seen)
Similar to add(), but if the sender already exists, its seqnos will be modified (no new entry) as follows:
  1. this.low_seqno=min(this.low_seqno, low_seqno)
  2. this.high_seqno=max(this.high_seqno, high_seqno)
  3. this.high_seqno_seen=max(this.high_seqno_seen, high_seqno_seen)
If the sender doesn not exist, a new entry will be added (provided there is enough space)

merge

public void merge(Digest d)
Adds a digest to this digest. This digest must have enough space to add the other digest; otherwise an error message will be written. For each sender in the other digest, the merge() method will be called.

printHighSeqnos

public String printHighSeqnos()

printHighSeqnosSeen

public String printHighSeqnosSeen()

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException

reset

public void reset(int size)

resetAt

public void resetAt(int index)
Resets the seqnos for the sender at 'index' to 0. This happens when a member has left the group, but it is still in the digest. Resetting its seqnos ensures that no-one will request a message retransmission from the dead member.

sameSenders

public boolean sameSenders(Digest other)
Compares two digests and returns true if the senders are the same, otherwise false
Parameters:
other -
Returns:

senderAt

public Address senderAt(int index)

setHighSeqnoAt

public void setHighSeqnoAt(int index,
                           long high_seqno)

setHighSeqnoAt

public void setHighSeqnoAt(Address sender,
                           long high_seqno)

setHighSeqnoSeenAt

public void setHighSeqnoSeenAt(int index,
                               long high_seqno_seen)

setHighSeqnoSeenAt

public void setHighSeqnoSeenAt(Address sender,
                               long high_seqno_seen)

setLowSeqnoAt

public void setLowSeqnoAt(int index,
                          long low_seqno)

size

public int size()

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException

Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.