Package org.jgroups.stack
Class AckReceiverWindow
java.lang.Object
org.jgroups.stack.AckReceiverWindow
Counterpart of AckSenderWindow. Simple FIFO buffer.
Every message received is ACK'ed (even duplicates) and added to a hashmap
keyed by seqno. The next seqno to be received is stored in
Change May 28 2002 (bela): replaced TreeSet with HashMap. Keys do not need to be sorted, and adding a key to a sorted set incurs overhead.
next_to_remove. When a message with
a seqno less than next_to_remove is received, it will be discarded. The remove() method removes
and returns a message whose seqno is equal to next_to_remove, or null if not found.Change May 28 2002 (bela): replaced TreeSet with HashMap. Keys do not need to be sorted, and adding a key to a sorted set incurs overhead.
- Author:
- Bela Ban
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAckReceiverWindow(long initial_seqno) AckReceiverWindow(long initial_seqno, int segment_capacity) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a new message.byteAdds a message if not yet receivedremove()Removes a message whose seqno is equal tonext_to_remove, increments the latter.removeMany(int max) Removes as many messages as possible (in sequence, without gaps)removeManyAsList(int max) voidreset()intsize()toString()
-
Field Details
-
TOMBSTONE
-
-
Constructor Details
-
AckReceiverWindow
public AckReceiverWindow(long initial_seqno) -
AckReceiverWindow
public AckReceiverWindow(long initial_seqno, int segment_capacity)
-
-
Method Details
-
getProcessing
-
add
Adds a new message. Message cannot be null- Returns:
- True if the message was added, false if not (e.g. duplicate, message was already present)
-
add2
Adds a message if not yet received- Parameters:
seqno-msg-- Returns:
- -1 if not added because seqno invalid input: '<' next_to_remove, 0 if not added because already present, 1 if added successfully
-
remove
Removes a message whose seqno is equal tonext_to_remove, increments the latter. Returns message that was removed, or null, if no message can be removed. Messages are thus removed in order. -
removeMany
Removes as many messages as possible (in sequence, without gaps)- Parameters:
max- Max number of messages to be removed- Returns:
- Tupleinvalid input: '<'List
,Long>: a tuple of the message list and the highest seqno removed
-
removeManyAsList
-
reset
public void reset() -
size
public int size() -
toString
-
printMessages
-