org.jgroups.util
Class Digest

java.lang.Object
  extended by org.jgroups.util.Digest
All Implemented Interfaces:
java.lang.Iterable<Digest.DigestEntry>, Streamable
Direct Known Subclasses:
MutableDigest

public class Digest
extends java.lang.Object
implements Streamable, java.lang.Iterable<Digest.DigestEntry>

A message digest, containing senders and ranges of seqnos, where each sender is associated with its highest delivered and received seqno seen so far.

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

Nested Class Summary
static class Digest.DigestEntry
          Keeps track of one members plus its highest delivered and received seqnos
protected  class Digest.MyIterator
           
 
Field Summary
protected  Address[] members
           
protected  long[] seqnos
           
 
Constructor Summary
  Digest()
          Used for serialization
protected Digest(Address[] members, long[] seqnos)
           
  Digest(Address sender, long highest_delivered)
           
  Digest(Address sender, long highest_delivered, long highest_received)
           
  Digest(Digest digest)
           
  Digest(java.util.Map<Address,long[]> map)
          Creates a new digest from an existing map by copying the keys and values from map
 
Method Summary
 boolean contains(Address member)
           
 boolean containsAll(Digest other)
          Returns true if our 'members' array contains all of the elements in other.members
 Digest copy()
           
protected  void createArrays(int size)
           
protected  void createArrays(java.util.Map<Address,long[]> map)
           
 Digest difference(Digest other)
           
 boolean equals(java.lang.Object obj)
          Not really used, other than in unit tests and by FLUSH (reconciliation phase), so it doesn't need to be super efficient
protected  int find(Address member)
           
 long[] get(Address member)
          Returns the highest delivered and received seqnos associated with a member.
 java.util.Set<Address> getMembers()
           
 long highestDeliveredSeqnoAt(Address sender)
           
 long highestReceivedSeqnoAt(Address sender)
           
 Digest highestSequence(Digest other)
           
 boolean isGreaterThanOrEqual(Digest other)
          Returns true if all senders of the current digest have their seqnos >= the ones from other
 java.util.Iterator<Digest.DigestEntry> iterator()
           
 java.lang.String printHighestDeliveredSeqnos()
           
 void readFrom(java.io.DataInput in)
          Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
 boolean sameSenders(Digest other)
          Compares two digests and returns true if the senders are the same, otherwise false.
 long serializedSize()
           
 int size()
           
 java.lang.String toString()
           
 java.lang.String toStringSorted()
           
 java.lang.String toStringSorted(boolean print_highest_received)
           
 void writeTo(java.io.DataOutput 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

members

protected Address[] members

seqnos

protected long[] seqnos
Constructor Detail

Digest

protected Digest(Address[] members,
                 long[] seqnos)

Digest

public Digest()
Used for serialization


Digest

public Digest(java.util.Map<Address,long[]> map)
Creates a new digest from an existing map by copying the keys and values from map


Digest

public Digest(Digest digest)

Digest

public Digest(Address sender,
              long highest_delivered,
              long highest_received)

Digest

public Digest(Address sender,
              long highest_delivered)
Method Detail

contains

public boolean contains(Address member)

containsAll

public boolean containsAll(Digest other)
Returns true if our 'members' array contains all of the elements in other.members

Parameters:
other -
Returns:

equals

public boolean equals(java.lang.Object obj)
Not really used, other than in unit tests and by FLUSH (reconciliation phase), so it doesn't need to be super efficient

Overrides:
equals in class java.lang.Object

get

public long[] get(Address member)
Returns the highest delivered and received seqnos associated with a member. This searches the members array sequentially, so use sparingly

Parameters:
member -
Returns:
An array of 2 elements: highest_delivered and highest_received seqnos

getMembers

public java.util.Set<Address> getMembers()

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.

difference

public Digest difference(Digest other)

highestSequence

public Digest highestSequence(Digest other)

size

public int size()

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:
toString in class java.lang.Object

toStringSorted

public java.lang.String toStringSorted()

toStringSorted

public java.lang.String toStringSorted(boolean print_highest_received)

printHighestDeliveredSeqnos

public java.lang.String printHighestDeliveredSeqnos()

writeTo

public void writeTo(java.io.DataOutput out)
             throws java.lang.Exception
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 interface Streamable
Throws:
java.lang.Exception

readFrom

public void readFrom(java.io.DataInput in)
              throws java.lang.Exception
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 interface Streamable
Throws:
java.lang.Exception

serializedSize

public long serializedSize()

find

protected int find(Address member)

createArrays

protected void createArrays(int size)

createArrays

protected void createArrays(java.util.Map<Address,long[]> map)

iterator

public java.util.Iterator<Digest.DigestEntry> iterator()
Specified by:
iterator in interface java.lang.Iterable<Digest.DigestEntry>


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.