public class NakReceiverWindow
extends java.lang.Object
remove()
removes the first message with a sequence
number that is 1 higher than next_to_remove
(this variable is
then incremented), or it returns null if no message is present, or if no
message's sequence number is 1 higher.
When there is a gap upon adding a message, its seqno will be added to the Retransmitter, which (using a timer) requests retransmissions of missing messages and keeps on trying until the message has been received, or the member who sent the message is suspected. There are 3 variables which keep track of messages:
Modifier and Type | Class and Description |
---|---|
static interface |
NakReceiverWindow.Listener |
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log |
static Message |
NULL_MSG
dummy for null values: ConcurrentHashMap doesn't allow null values
|
Constructor and Description |
---|
NakReceiverWindow(Address local_addr,
Address sender,
Retransmitter.RetransmitCommand cmd,
long highest_delivered_seqno,
long lowest_seqno,
TimeScheduler sched) |
NakReceiverWindow(Address sender,
Retransmitter.RetransmitCommand cmd,
long highest_delivered_seqno)
Creates a new instance with the given retransmit command
|
NakReceiverWindow(Address sender,
Retransmitter.RetransmitCommand cmd,
long highest_delivered_seqno,
long lowest_seqno,
TimeScheduler sched)
Creates a new instance with the given retransmit command
|
NakReceiverWindow(Address sender,
Retransmitter.RetransmitCommand cmd,
long highest_delivered_seqno,
TimeScheduler sched)
Creates a new instance with the given retransmit command
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(long seqno,
Message msg)
Adds a message according to its seqno (sequence number).
|
void |
destroy()
Stop the retransmitter and reset the nak window
|
Message |
get(long seqno)
Returns the message from xmit_table
|
long |
getHighestDelivered()
Returns the highest sequence number of a message consumed by the application (by
remove() ). |
long |
getHighestReceived()
Returns the highest sequence number received so far (which may be
higher than the highest seqno delivered so far; e.g., for
1,2,3,5,6 it would be 6.
|
java.util.concurrent.locks.ReentrantLock |
getLock() |
double |
getLossRate()
Returns the loss rate, which is defined as the number of pending retransmission requests / the total number of
messages in xmit_table
|
long |
getLowestSeen() |
int |
getMaxXmitBufSize() |
int |
getPendingXmits() |
double |
getSmoothedLossRate() |
boolean |
hasMessagesToRemove() |
java.lang.String |
printLossRate() |
Message |
remove() |
Message |
removeOOBMessage() |
void |
reset()
Reset the retransmitter and the nak window
|
void |
setDiscardDeliveredMessages(boolean flag) |
void |
setListener(NakReceiverWindow.Listener l) |
void |
setMaxXmitBufSize(int max_xmit_buf_size) |
void |
setRetransmitTimeouts(Interval timeouts) |
int |
size() |
void |
stable(long seqno)
Delete all messages <= seqno (they are stable, that is, have been received at all members).
|
java.lang.String |
toString() |
public static final Message NULL_MSG
protected static final org.apache.commons.logging.Log log
public NakReceiverWindow(Address sender, Retransmitter.RetransmitCommand cmd, long highest_delivered_seqno, long lowest_seqno, TimeScheduler sched)
sender
- The sender associated with this instancecmd
- The command used to retransmit a missing message, will
be invoked by the table. If null, the retransmit thread will not be startedhighest_delivered_seqno
- The next seqno to remove is highest_delivered_seqno +1lowest_seqno
- The low seqno purgedsched
- the external scheduler to use for retransmission
requests of missing msgs. If it's not provided or is null, an internalpublic NakReceiverWindow(Address local_addr, Address sender, Retransmitter.RetransmitCommand cmd, long highest_delivered_seqno, long lowest_seqno, TimeScheduler sched)
public NakReceiverWindow(Address sender, Retransmitter.RetransmitCommand cmd, long highest_delivered_seqno, TimeScheduler sched)
sender
- The sender associated with this instancecmd
- The command used to retransmit a missing message, will
be invoked by the table. If null, the retransmit thread will not be startedhighest_delivered_seqno
- The next seqno to remove is highest_delivered_seqno +1sched
- the external scheduler to use for retransmission
requests of missing msgs. If it's not provided or is null, an internalpublic NakReceiverWindow(Address sender, Retransmitter.RetransmitCommand cmd, long highest_delivered_seqno)
sender
- The sender associated with this instancecmd
- The command used to retransmit a missing message, will
be invoked by the table. If null, the retransmit thread will not be startedhighest_delivered_seqno
- The next seqno to remove is highest_delivered_seqno +1public java.util.concurrent.locks.ReentrantLock getLock()
public void setRetransmitTimeouts(Interval timeouts)
public void setDiscardDeliveredMessages(boolean flag)
public int getMaxXmitBufSize()
public void setMaxXmitBufSize(int max_xmit_buf_size)
public void setListener(NakReceiverWindow.Listener l)
public int getPendingXmits()
public double getLossRate()
public double getSmoothedLossRate()
public boolean add(long seqno, Message msg)
There are 4 cases where messages are added:
public Message remove()
public Message removeOOBMessage()
public boolean hasMessagesToRemove()
public void stable(long seqno)
public void reset()
public void destroy()
public long getLowestSeen()
remove()
)public long getHighestDelivered()
remove()
).
Note that this is different from the highest deliverable seqno. E.g. in 23,24,26,27,29, the highest
delivered message may be 22, whereas the highest deliverable message may be 24 !remove()
)public long getHighestReceived()
getHighestDelivered()
public Message get(long seqno)
seqno
- public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String printLossRate()
Copyright ? 1998-2008 Bela Ban. All Rights Reserved.