Package org.jgroups.stack
Class AckMcastSenderWindow
- java.lang.Object
-
- org.jgroups.stack.AckMcastSenderWindow
-
public class AckMcastSenderWindow extends java.lang.ObjectKeeps track of ACKs from receivers for each message. When a new message is sent, it is tagged with a sequence number and the receiver set (set of members to which the message is sent) and added to a hashtable (key = sequence number, val = message + receiver set). Each incoming ACK is noted and when all ACKs for a specific sequence number haven been received, the corresponding entry is removed from the hashtable. A retransmission thread periodically re-sends the message point-to-point to all receivers from which no ACKs have been received yet. A view change or suspect message causes the corresponding non-existing receivers to be removed from the hashtable. This class may need flow control in order to avoid needless retransmissions because of timeouts.- Version:
- $Id: AckMcastSenderWindow.java,v 1.14.2.1 2008/01/22 10:01:01 belaban Exp $
- Author:
- Bela Ban June 9 1999, 2007, John Georgiadis May 8 2001
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAckMcastSenderWindow.RetransmitCommandCalled by retransmitter thread whenever a message needs to be re-sent to a destination.
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.commons.logging.LoglogDefault retransmit thread suspend timeout (ms)
-
Constructor Summary
Constructors Constructor Description AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd)Create and start the retransmitterAckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd, Interval retransmit_intervals)Create and start the retransmitterAckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd, Interval retransmit_intervals, TimeScheduler sched)Create and start the retransmitterAckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd, TimeScheduler sched)Create and start the retransmitter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidack(long seqno, Address sender)An ACK has been received fromsender.voidadd(long seqno, Message msg, java.util.Vector receivers)Adds a new message to the hash table.voidclearStableMessages()longgetNumberOfResponsesExpected(long seqno)Returns the number of members for a given entry for which acks have to be receivedlonggetNumberOfResponsesReceived(long seqno)Returns the number of members for a given entry for which acks have been receivedjava.util.ListgetStableMessages()java.lang.StringprintDetails(long seqno)Prints all members plus whether an ack has been received from those members for a given seqnovoidremove(Address obj)Removeobjfrom all receiver sets and wake up retransmission thread.voidreset()Remove all pending msgs from the hashtable.longsize()voidstop()Stop the rentransmition and clear all pending msgs.voidsuspect(Address suspected)Process with addresssuspectedis suspected: remove it from all receiver sets.java.lang.StringtoString()voidwaitUntilAllAcksReceived(long timeout)Waits until all outstanding messages have been ACKed by all receivers.
-
-
-
Constructor Detail
-
AckMcastSenderWindow
public AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd, Interval retransmit_intervals, TimeScheduler sched)
Create and start the retransmitter- Parameters:
cmd- the callback object for retranmissionsretransmit_intervals- the interval between two consecutive retransmission attemptssched- the external scheduler to use to schedule retransmissions- Throws:
java.lang.IllegalArgumentException- ifcmdis null
-
AckMcastSenderWindow
public AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd, TimeScheduler sched)
Create and start the retransmitter- Parameters:
cmd- the callback object for retranmissionssched- the external scheduler to use to schedule retransmissions- Throws:
java.lang.IllegalArgumentException- ifcmdis null
-
AckMcastSenderWindow
public AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd, Interval retransmit_intervals)
Create and start the retransmitter- Parameters:
cmd- the callback object for retranmissionsretransmit_intervals- the interval between two consecutive retransmission attempts- Throws:
java.lang.IllegalArgumentException- ifcmdis null
-
AckMcastSenderWindow
public AckMcastSenderWindow(AckMcastSenderWindow.RetransmitCommand cmd)
Create and start the retransmitter- Parameters:
cmd- the callback object for retranmissions- Throws:
java.lang.IllegalArgumentException- ifcmdis null
-
-
Method Detail
-
add
public void add(long seqno, Message msg, java.util.Vector receivers)Adds a new message to the hash table.- Parameters:
seqno- The sequence number associated with the messagemsg- The message (should be a copy!)receivers- The set of addresses to which the message was sent and from which consequently an ACK is expected
-
ack
public void ack(long seqno, Address sender)An ACK has been received fromsender. Tag the sender in the hash table as 'received'. If all ACKs have been received, remove the entry all together.- Parameters:
seqno- The sequence number of the message for which an ACK has been received.sender- The sender which sent the ACK
-
remove
public void remove(Address obj)
Removeobjfrom all receiver sets and wake up retransmission thread.- Parameters:
obj- the sender to remove
-
suspect
public void suspect(Address suspected)
Process with addresssuspectedis suspected: remove it from all receiver sets. This means that no ACKs are expected from this process anymore.- Parameters:
suspected- The suspected process
-
getStableMessages
public java.util.List getStableMessages()
- Returns:
- a copy of stable messages, or null (if non available). Removes all stable messages afterwards
-
clearStableMessages
public void clearStableMessages()
-
size
public long size()
- Returns:
- the number of currently pending msgs
-
getNumberOfResponsesExpected
public long getNumberOfResponsesExpected(long seqno)
Returns the number of members for a given entry for which acks have to be received
-
getNumberOfResponsesReceived
public long getNumberOfResponsesReceived(long seqno)
Returns the number of members for a given entry for which acks have been received
-
printDetails
public java.lang.String printDetails(long seqno)
Prints all members plus whether an ack has been received from those members for a given seqno
-
waitUntilAllAcksReceived
public void waitUntilAllAcksReceived(long timeout)
Waits until all outstanding messages have been ACKed by all receivers. Takes into account suspicions and view changes. Returns when there are no entries left in the hashtable. While waiting, no entries can be added to the hashtable (they will be discarded).- Parameters:
timeout- Miliseconds to wait. 0 means wait indefinitely.
-
stop
public void stop()
Stop the rentransmition and clear all pending msgs. If this retransmitter has been provided an externally managed scheduler, then just clear all msgs and the associated tasks, else stop the scheduler. In this case the method blocks until the scheduler's thread is dead. Only the owner of the scheduler should stop it.
-
reset
public void reset()
Remove all pending msgs from the hashtable. Cancel all associated tasks in the retransmission scheduler
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-