All Packages Class Hierarchy This Package Previous Next Index
Class JavaGroups.AckSenderWindow
java.lang.Object
|
+----JavaGroups.AckSenderWindow
- public class AckSenderWindow
- extends Object
- implements Runnable
ACK-based sliding window for a sender. Messages are added to the window according to message
IDs. When an ACK is received, the corresponding entry is marked and the window advanced as
much as possible. The addition of a message to a full window will block until a slot becomes
free (when receiving an ACK). A retransmission thread continously iterates over the entries,
retransmitting messages for which no ACK has been received in timeout
time.
-
AckSenderWindow(AckSenderWindow. RetransmitCommand, long)
- Creates a new instance.
-
AckSenderWindow(int, AckSenderWindow. RetransmitCommand, long)
- Creates a new instance.
-
Ack(long)
- Marks one message as received.
-
Add(long, Message)
-
Add a new message.
-
GetLowMark()
-
-
GetTimeout()
-
-
main(String[])
-
-
run()
- Iterate over msgs.
-
SetTimeout(long)
-
-
Start()
- Starts the retransmission thread (will not be started automatically !).
-
Stop()
-
-
toString()
-
AckSenderWindow
public AckSenderWindow(AckSenderWindow. RetransmitCommand com,
long low_mark)
- 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 thread).
- low_mark - The next sequence number to expect ACKs for.
AckSenderWindow
public AckSenderWindow(int window_size,
AckSenderWindow. RetransmitCommand com,
long low_mark)
- Creates a new instance. Thre retransmission thread has to be started separately with
Start
.
- Parameters:
- window_size - Determines how many messages can be added to the window before it blocks.
The caller will be unblocked when a message is removed.
- com - If not null, its method
Retransmit
will be called when a message
needs to be retransmitted (called by the retransmitter thread).
- low_mark - The next sequence number to expect ACKs for.
GetLowMark
public long GetLowMark()
GetTimeout
public long GetTimeout()
SetTimeout
public void SetTimeout(long timeout)
Start
public void Start()
- Starts the retransmission thread (will not be started automatically !). The thread scans over
the messages sent and requests retransmission for those that haven't received an ACK for
a certain period of time.
Stop
public void Stop()
Add
public void Add(long seq_no,
Message msg)
- Add a new message.
seq_no
should always be 1 higher than the previous
one. Messages will be ordered according to seq_no. When the number of entries exceeds
the maximum window size, the caller will be blocked until an ACK has been received
(removing 1 message).
Ack
public void Ack(long seq_no)
- Marks one message as received. Removes as many messages as possible,
sets
low_mark
correspondingly.
run
public void run()
- Iterate over msgs. For entries that haven't received an ACK within
timeout
time, issue a retransmission command.
toString
public String toString()
- Overrides:
- toString in class Object
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index