org.javagroups.stack
Class AckSenderWindow
java.lang.Object
|
+--org.javagroups.stack.AckSenderWindow
- All Implemented Interfaces:
- Retransmitter.RetransmitCommand
- public class AckSenderWindow
- extends java.lang.Object
- implements Retransmitter.RetransmitCommand
ACK-based sliding window for a sender. Messages are added to the window keyed by seqno
When an ACK is received, the corresponding message is removed. The Retransmitter
continously iterates over the entries in the hashmap, retransmitting messages based on their
creation time and an (increasing) timeout. When there are no more messages in the retransmission
table left, the thread terminates. It will be re-activated when a new entry is added to the
retransmission table.
- Author:
- Bela Ban
Method Summary |
void |
ack(long seqno)
Removes the message from msgs , removing them also from retransmission. |
void |
add(long seqno,
Message msg)
Adds a new message to the retransmission table. |
static void |
main(java.lang.String[] args)
|
void |
reset()
|
void |
retransmit(long first_seqno,
long last_seqno,
Address sender)
Get the missing messages between sequence numbers
first_seqno and last_seqno . |
void |
setWindowSize(int window_size,
int min_threshold)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
AckSenderWindow
public AckSenderWindow(AckSenderWindow.RetransmitCommand com)
- Creates a new instance. Thre retransmission thread has to be started separately with
start()
.
- Parameters:
com
- If not null, its method retransmit()
will be called when a message
needs to be retransmitted (called by the Retransmitter).
AckSenderWindow
public AckSenderWindow(AckSenderWindow.RetransmitCommand com,
long[] interval)
AckSenderWindow
public AckSenderWindow(AckSenderWindow.RetransmitCommand com,
long[] interval,
Protocol transport)
- This constructor whould be used when we want AckSenderWindow to send the message added
by add(), rather then ourselves.
setWindowSize
public void setWindowSize(int window_size,
int min_threshold)
reset
public void reset()
add
public void add(long seqno,
Message msg)
- Adds a new message to the retransmission table. If the message won't have received an ack within
a certain time frame, the retransmission thread will retransmit the message to the receiver. If
a sliding window protocol is used, we only add up to
window_size
messages. If the table is
full, we add all new messages to a queue. Those will only be added once the table drains below a certain
threshold (min_threshold
)
ack
public void ack(long seqno)
- Removes the message from
msgs
, removing them also from retransmission. If
sliding window protocol is used, and was queueing, check whether we can resume adding elements.
Add all elements. If this goes above window_size, stop adding and back to queueing. Else
set queueing to false.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
retransmit
public void retransmit(long first_seqno,
long last_seqno,
Address sender)
- Description copied from interface:
Retransmitter.RetransmitCommand
- Get the missing messages between sequence numbers
first_seqno
and last_seqno
. This can either be done by sending a
retransmit message to destination sender
(nak-based scheme), or by
retransmitting the missing message(s) to sender
(ack-based scheme).
- Specified by:
retransmit
in interface Retransmitter.RetransmitCommand
- Following copied from interface:
org.javagroups.stack.Retransmitter.RetransmitCommand
- Parameters:
first_seqno
- The sequence number of the first missing messagelast_seqno
- The sequence number of the last missing messagesender
- The destination of the member to which the retransmit request will be sent
(nak-based scheme), or to which the message will be retransmitted (ack-based scheme).
main
public static void main(java.lang.String[] args)
Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.