Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jgroups.protocols.pbcast
Class Digest  view Digest download Digest.java

java.lang.Object
  extended byorg.jgroups.protocols.pbcast.Digest
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, org.jgroups.util.Streamable

public class Digest
extends java.lang.Object
implements java.io.Externalizable, org.jgroups.util.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.


Nested Class Summary
static class Digest.Entry
          Class keeping track of the lowest and highest sequence numbers delivered, and the highest sequence numbers received, per member
 
Field Summary
protected static org.apache.commons.logging.Log log
           
(package private)  java.util.Map senders
          Map
(package private) static boolean warn
           
 
Constructor Summary
Digest()
           
Digest(int size)
           
 
Method Summary
private  void add(org.jgroups.Address sender, Digest.Entry entry)
           
 void add(org.jgroups.Address sender, long low_seqno, long high_seqno)
           
 void add(org.jgroups.Address sender, long low_seqno, long high_seqno, long high_seqno_seen)
           
 void add(Digest d)
           
 void clear()
           
 boolean contains(org.jgroups.Address sender)
           
 Digest copy()
           
private  java.util.Map createSenders(int size)
           
 boolean equals(java.lang.Object obj)
          Determine whether this Object is semantically equal to another Object.
 Digest.Entry get(org.jgroups.Address sender)
           
 long highSeqnoAt(org.jgroups.Address sender)
           
 long highSeqnoSeenAt(org.jgroups.Address sender)
           
 void incrementHighSeqno(org.jgroups.Address sender)
          Increments the sender's high_seqno by 1.
 long lowSeqnoAt(org.jgroups.Address sender)
           
 void merge(org.jgroups.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: this.low_seqno=min(this.low_seqno, low_seqno) this.high_seqno=max(this.high_seqno, high_seqno) 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.
 java.lang.String printHighSeqnos()
           
 java.lang.String printHighSeqnosSeen()
           
 void readExternal(java.io.ObjectInput in)
          This method restores an object's state by reading in the instance data for the object from the passed in stream.
 void readFrom(java.io.DataInputStream in)
          Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
 void replace(Digest d)
           
 void resetAt(org.jgroups.Address sender)
          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.
 long serializedSize()
           
 boolean set(org.jgroups.Address sender, long low_seqno, long high_seqno, long high_seqno_seen)
           
 void setHighestDeliveredAndSeenSeqnos(org.jgroups.Address sender, long high_seqno, long high_seqno_seen)
           
 void setHighSeqnoAt(org.jgroups.Address sender, long high_seqno)
           
 void setHighSeqnoSeenAt(org.jgroups.Address sender, long high_seqno_seen)
           
 int size()
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void writeExternal(java.io.ObjectOutput out)
          This method is responsible for writing the instance data of an object to the passed in stream.
 void writeTo(java.io.DataOutputStream out)
          Write the entire state of the current object (including superclasses) to outstream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

senders

java.util.Map senders
Map


log

protected static final org.apache.commons.logging.Log log

warn

static final boolean warn
Constructor Detail

Digest

public Digest()

Digest

public Digest(int size)
Method Detail

equals

public boolean equals(java.lang.Object obj)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.


add

public void add(org.jgroups.Address sender,
                long low_seqno,
                long high_seqno)

add

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

add

private void add(org.jgroups.Address sender,
                 Digest.Entry entry)

add

public void add(Digest d)

replace

public void replace(Digest d)

get

public Digest.Entry get(org.jgroups.Address sender)

set

public boolean set(org.jgroups.Address sender,
                   long low_seqno,
                   long high_seqno,
                   long high_seqno_seen)

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.


merge

public void merge(org.jgroups.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)


contains

public boolean contains(org.jgroups.Address sender)

sameSenders

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


incrementHighSeqno

public void incrementHighSeqno(org.jgroups.Address sender)
Increments the sender's high_seqno by 1.


size

public int size()

resetAt

public void resetAt(org.jgroups.Address sender)
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.


clear

public void clear()

lowSeqnoAt

public long lowSeqnoAt(org.jgroups.Address sender)

highSeqnoAt

public long highSeqnoAt(org.jgroups.Address sender)

highSeqnoSeenAt

public long highSeqnoSeenAt(org.jgroups.Address sender)

setHighSeqnoAt

public void setHighSeqnoAt(org.jgroups.Address sender,
                           long high_seqno)

setHighSeqnoSeenAt

public void setHighSeqnoSeenAt(org.jgroups.Address sender,
                               long high_seqno_seen)

setHighestDeliveredAndSeenSeqnos

public void setHighestDeliveredAndSeenSeqnos(org.jgroups.Address sender,
                                             long high_seqno,
                                             long high_seqno_seen)

copy

public Digest copy()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


printHighSeqnos

public java.lang.String printHighSeqnos()

printHighSeqnosSeen

public java.lang.String printHighSeqnosSeen()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Description copied from interface: java.io.Externalizable
This method is responsible for writing the instance data of an object to the passed in stream. Note that this stream is not a subclass of OutputStream, but rather is a class that implements the ObjectOutput interface. That interface provides a number of methods for writing Java data values to a stream.

Not that the implementation of this method must be coordinated with the implementation of readExternal.

Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Description copied from interface: java.io.Externalizable
This method restores an object's state by reading in the instance data for the object from the passed in stream. Note that this stream is not a subclass of InputStream, but rather is a class that implements the ObjectInput interface. That interface provides a mechanism for reading in Java data types from a stream.

Note that this method must be compatible with writeExternal. It must read back the exact same types that were written by that method in the exact order they were written.

If this method needs to read back an object instance, then the class for that object must be found and loaded. If that operation fails, then this method throws a ClassNotFoundException

Specified by:
readExternal in interface java.io.Externalizable

writeTo

public void writeTo(java.io.DataOutputStream out)
             throws java.io.IOException
Description copied from interface: org.jgroups.util.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 interface org.jgroups.util.Streamable

readFrom

public void readFrom(java.io.DataInputStream in)
              throws java.io.IOException,
                     java.lang.IllegalAccessException,
                     java.lang.InstantiationException
Description copied from interface: org.jgroups.util.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 interface org.jgroups.util.Streamable

serializedSize

public long serializedSize()

createSenders

private java.util.Map createSenders(int size)