public class UNICAST extends Protocol implements AckSenderWindow.RetransmitCommand, AgeOutCache.Handler<Address>
This
layer is used to reliably transmit point-to-point messages, that is, either messages sent to a
single receiver (vs. messages multicast to a group) or for example replies to a multicast message. The
sender uses an AckSenderWindow
which retransmits messages for which it hasn't received
an ACK, the receiver uses AckReceiverWindow
which keeps track of the lowest seqno
received so far, and keeps messages in order.
Messages in both AckSenderWindows and AckReceiverWindows will be removed. A message will be removed from
AckSenderWindow when an ACK has been received for it and messages will be removed from AckReceiverWindow
whenever a message is received: the new message is added and then we try to remove as many messages as
possible (until we stop at a gap, or there are no more messages).
UNICAST was enhanced in April 2009, the new design is described in doc/design/UNICAST.new.txt
Modifier and Type | Class and Description |
---|---|
static class |
UNICAST.UnicastHeader |
Constructor and Description |
---|
UNICAST() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
down(Event evt)
An event is to be sent down the stack.
|
java.util.Map<java.lang.String,java.lang.Object> |
dumpStats() |
void |
expired(Address key)
Called by AgeOutCache, to removed expired connections
|
AgeOutCache |
getAgeOutCache() |
int |
getAgeOutCacheSize() |
java.lang.String |
getLocalAddress() |
long |
getMaxRetransmitTime() |
java.lang.String |
getMembers() |
java.lang.String |
getName()
All protocol names have to be unique !
|
long |
getNumAcksReceived() |
long |
getNumAcksSent() |
int |
getNumberOfMessagesInReceiveWindows() |
long |
getNumberOfRetransmitRequestsReceived() |
int |
getNumberOfUnackedMessages()
The number of messages in all Entry.sent_msgs tables (haven't received an ACK yet)
|
long |
getNumBytesReceived() |
long |
getNumBytesSent() |
long |
getNumMessagesReceived() |
long |
getNumMessagesSent() |
java.lang.String |
getUnackedMessages() |
java.lang.String |
printAgeOutCache() |
java.lang.String |
printConnections() |
void |
removeAllConnections()
This method is public only so it can be invoked by unit testing, but should not otherwise be used !
|
boolean |
removeConnection(Address mbr)
Removes and resets from connection table (which is already locked).
|
void |
resetStats() |
void |
retransmit(long seqno,
Message msg)
Called by AckSenderWindow to resend messages for which no ACK has been received yet
|
void |
setMaxRetransmitTime(long max_retransmit_time) |
boolean |
setProperties(java.util.Properties props)
Configures the protocol initially.
|
void |
start()
This method is called on a
Channel.connect(String) . |
void |
stop()
This method is called on a
Channel.disconnect() . |
java.lang.Object |
up(Event evt)
An event was received from the layer below.
|
destroy, downThreadEnabled, enableStats, getDownProtocol, getProperties, getProtocolStack, getThreadFactory, getTransport, getUpProtocol, init, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
public java.lang.String getName()
public java.lang.String getLocalAddress()
public java.lang.String getMembers()
public java.lang.String printConnections()
public long getNumMessagesSent()
public long getNumMessagesReceived()
public long getNumBytesSent()
public long getNumBytesReceived()
public long getNumAcksSent()
public long getNumAcksReceived()
public long getNumberOfRetransmitRequestsReceived()
public long getMaxRetransmitTime()
public void setMaxRetransmitTime(long max_retransmit_time)
public int getAgeOutCacheSize()
public java.lang.String printAgeOutCache()
public AgeOutCache getAgeOutCache()
public int getNumberOfUnackedMessages()
public java.lang.String getUnackedMessages()
public int getNumberOfMessagesInReceiveWindows()
public void resetStats()
resetStats
in class Protocol
public java.util.Map<java.lang.String,java.lang.Object> dumpStats()
public boolean setProperties(java.util.Properties props)
Protocol
"loopback=false;unicast_inport=4444"
setProperties
in class Protocol
public void start() throws java.lang.Exception
Protocol
Channel.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.start
in class Protocol
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
Channel.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 flushedpublic java.lang.Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.public java.lang.Object down(Event evt)
Protocol
down_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 using up_prot.up()
.public boolean removeConnection(Address mbr)
public void removeAllConnections()
public void retransmit(long seqno, Message msg)
retransmit
in interface AckSenderWindow.RetransmitCommand
public void expired(Address key)
expired
in interface AgeOutCache.Handler<Address>
key
- Copyright ? 1998-2008 Bela Ban. All Rights Reserved.