Package org.jgroups.protocols
Class UNICAST2
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.UNICAST2
- All Implemented Interfaces:
Retransmitter.RetransmitCommand,AgeOutCache.Handler<Address>
public class UNICAST2
extends Protocol
implements Retransmitter.RetransmitCommand, AgeOutCache.Handler<Address>
Reliable unicast layer. Implemented with negative acks. Every sender keeps its messages in an AckSenderWindow. A
receiver stores incoming messages in a NakReceiverWindow, and asks the sender for retransmission if a gap is
detected. Every now and then (stable_interval), a timer task sends a STABLE message to all senders, including the
highest received and delivered seqnos. A sender purges messages lower than highest delivered and asks the STABLE
sender for messages it might have missed (smaller than highest received). A STABLE message can also be sent when
a receiver has received more than max_bytes from a given sender.
The advantage of this protocol over
UNICAST is that it doesn't send acks for every
message. Instead, it sends 'acks' after receiving max_bytes and/ or periodically (stable_interval).- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe following types and fields are serialized: -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longprotected longprotected longprotected intprotected long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompact()An event is to be sent down the stack.voidCalled by AgeOutCache, to removed expired connectionsintlongintlonglonglonglonglonglong[]getTimer()voidinit()Called after instance has been created (null constructor) and before protocol is started.voidvoidThis method is public only so it can be invoked by unit testing, but should not otherwise be used !voidremoveConnection(Address mbr) Removes and resets from connection table (which is already locked).voidvoidretransmit(long first_seqno, long last_seqno, Address sender) Get the missing messages between sequence numbersfirst_seqnoandlast_seqno.protected voidsendStableMessage(Address dest, long low, long high) voidvoidsetMaxMessageBatchSize(int size) voidsetMaxRetransmitTime(long max_retransmit_time) voidsetTimeout(long[] val) voidsetTimer(TimeScheduler timer) Only used for unit tests, don't use !protected voidPurge all messages in window for local_addr, which are invalid input: '<'= low.voidstart()This method is called on aChannel.connect(String).voidstop()This method is called on aChannel.disconnect().An event was received from the layer below.Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, upThreadEnabled
-
Field Details
-
DEFAULT_FIRST_SEQNO
public static final long DEFAULT_FIRST_SEQNO- See Also:
-
max_bytes
protected long max_bytes -
stable_interval
protected long stable_interval -
max_stable_msgs
protected int max_stable_msgs -
max_retransmit_time
protected long max_retransmit_time
-
-
Constructor Details
-
UNICAST2
public UNICAST2()
-
-
Method Details
-
getTimeout
public long[] getTimeout() -
setTimeout
public void setTimeout(long[] val) -
setMaxMessageBatchSize
public void setMaxMessageBatchSize(int size) -
getLocalAddress
-
getMembers
-
printConnections
-
getNumMessagesSent
public long getNumMessagesSent() -
getNumMessagesReceived
public long getNumMessagesReceived() -
getNumBytesSent
public long getNumBytesSent() -
getNumBytesReceived
public long getNumBytesReceived() -
getNumberOfRetransmissions
public long getNumberOfRetransmissions() -
getMaxRetransmitTime
public long getMaxRetransmitTime() -
setMaxRetransmitTime
public void setMaxRetransmitTime(long max_retransmit_time) -
getAgeOutCacheSize
public int getAgeOutCacheSize() -
printAgeOutCache
-
getAgeOutCache
-
getNumberOfMessagesInReceiveWindows
public int getNumberOfMessagesInReceiveWindows() -
printRetransmitTableSizes
-
compact
public void compact() -
purgeAndCompact
public void purgeAndCompact() -
resetStats
public void resetStats()- Overrides:
resetStatsin classProtocol
-
dumpStats
-
getTimer
-
setTimer
Only used for unit tests, don't use !- Parameters:
timer-
-
init
Description copied from class:ProtocolCalled after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent. -
start
Description copied from class:ProtocolThis method is called on aChannel.connect(String). Starts work. Protocols are connected and queues are ready to receive events. Will be called from bottom to top. This call will replace the START and START_OK events.- Overrides:
startin classProtocol- Throws:
Exception- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soChannel.connect(String)will throw an exception
-
stop
public void stop()Description copied from class:ProtocolThis method is called on aChannel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed -
up
Description copied from class:ProtocolAn event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack usingdown_prot.down()or c) the event (or another event) is sent up the stack usingup_prot.up(). -
down
Description copied from class:ProtocolAn event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down(). In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack usingup_prot.up(). -
stable
Purge all messages in window for local_addr, which are invalid input: '<'= low. Check if the window's highest received message is > high: if true, retransmit all messages from high - win.high to sender- Parameters:
sender-highest_delivered-highest_seen-
-
sendStableMessages
public void sendStableMessages() -
sendStableMessage
-
removeConnection
Removes and resets from connection table (which is already locked). Returns true if member was found, otherwise false. This method is public only so it can be invoked by unit testing, but should not otherwise be used ! -
removeAllConnections
public void removeAllConnections()This method is public only so it can be invoked by unit testing, but should not otherwise be used ! -
retransmit
Description copied from interface:Retransmitter.RetransmitCommandGet the missing messages between sequence numbersfirst_seqnoandlast_seqno. This can either be done by sending a retransmit message to destinationsender(nak-based scheme), or by retransmitting the missing message(s) tosender(ack-based scheme).- Specified by:
retransmitin interfaceRetransmitter.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).
-
expired
Called by AgeOutCache, to removed expired connections- Specified by:
expiredin interfaceAgeOutCache.Handler<Address>- Parameters:
key-
-