org.jgroups.protocols.pbcast

Class NAKACK

Implemented Interfaces:
NakReceiverWindow.Listener, Retransmitter.RetransmitCommand

public class NAKACK
extends Protocol
implements Retransmitter.RetransmitCommand, NakReceiverWindow.Listener

Negative AcKnowledgement layer (NAKs). Messages are assigned a monotonically increasing sequence number (seqno). Receivers deliver messages ordered according to seqno and request retransmission of missing messages. Retransmitted messages are bundled into bigger ones, e.g. when getting an xmit request for messages 1-10, instead of sending 10 unicast messages, we bundle all 10 messages into 1 and send it. However, since this protocol typically sits below FRAG, we cannot count on FRAG to fragement/defragment the (possibly) large message into smaller ones. Therefore we only bundle messages up to max_xmit_size bytes to prevent too large messages. For example, if the bundled message size was a total of 34000 bytes, and max_xmit_size=16000, we'd send 3 messages: 2 16K and a 2K message. Note that max_xmit_size should be the same value as FRAG.frag_size (or smaller).
Retransmit requests are always sent to the sender. If the sender dies, and not everyone has received its messages, they will be lost. In the future, this may be changed to have receivers store all messages, so that retransmit requests can be answered by any member. Trivial to implement, but not done yet. For most apps, the default retransmit properties are sufficient, if not use vsync.
Author:
Bela Ban

Field Summary

Fields inherited from class org.jgroups.stack.Protocol

down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, trace, up_handler, up_prot, up_queue, up_thread, up_thread_prio, warn

Constructor Summary

NAKACK()

Method Summary

void
down(Event evt)
Callback.
Map
dumpStats()
int
getGcLag()
int
getMaxXmitBufSize()
long
getMaxXmitSize()
long
getMissingMessagesReceived()
String
getName()
int
getPendingRetransmissionRequests()
int
getReceivedTableSize()
int
getSentTableSize()
long
getXmitRequestsReceived()
long
getXmitRequestsSent()
long
getXmitResponsesReceived()
long
getXmitResponsesSent()
void
init()
Called after instance has been created (null constructor) and before protocol is started.
boolean
isDiscardDeliveredMsgs()
boolean
isUseMcastXmit()
boolean
isXmitFromRandomMember()
void
missingMessageReceived(long seqno, Message msg)
String
printMessages()
String
printSentMsgs()
String
printStats()
Vector
providedDownServices()
List of events that are provided to layers below (they will be handled when sent down from below).
Vector
providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above).
void
resetStats()
void
retransmit(long first_seqno, long last_seqno, Address sender)
Implementation of Retransmitter.RetransmitCommand.
void
setDiscardDeliveredMsgs(boolean discard_delivered_msgs)
void
setGcLag(int gc_lag)
void
setMaxXmitBufSize(int max_xmit_buf_size)
void
setMaxXmitSize(long max_xmit_size)
boolean
setProperties(Properties props)
Configures the protocol initially.
void
setUseMcastXmit(boolean use_mcast_xmit)
void
setXmitFromRandomMember(boolean xmit_from_random_member)
void
start()
This method is called on a Channel.connect(String).
void
stop()
This method is called on a Channel.disconnect().
void
up(Event evt)
Callback.

Methods inherited from class org.jgroups.stack.Protocol

destroy, down, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stop, stopInternal, up, upThreadEnabled

Constructor Details

NAKACK

public NAKACK()

Method Details

down

public void down(Event evt)
Callback. Called by superclass when event may be handled.

Do not use passDown() in this method as the event is passed down by default by the superclass after this method returns !

Overrides:
down in interface Protocol

dumpStats

public Map dumpStats()
Overrides:
dumpStats in interface Protocol

getGcLag

public int getGcLag()

getMaxXmitBufSize

public int getMaxXmitBufSize()

getMaxXmitSize

public long getMaxXmitSize()

getMissingMessagesReceived

public long getMissingMessagesReceived()

getName

public String getName()
Overrides:
getName in interface Protocol

getPendingRetransmissionRequests

public int getPendingRetransmissionRequests()

getReceivedTableSize

public int getReceivedTableSize()

getSentTableSize

public int getSentTableSize()

getXmitRequestsReceived

public long getXmitRequestsReceived()

getXmitRequestsSent

public long getXmitRequestsSent()

getXmitResponsesReceived

public long getXmitResponsesReceived()

getXmitResponsesSent

public long getXmitResponsesSent()

init

public void init()
            throws Exception
Called 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.
Overrides:
init in interface Protocol

isDiscardDeliveredMsgs

public boolean isDiscardDeliveredMsgs()

isUseMcastXmit

public boolean isUseMcastXmit()

isXmitFromRandomMember

public boolean isXmitFromRandomMember()

missingMessageReceived

public void missingMessageReceived(long seqno,
                                   Message msg)
Specified by:
missingMessageReceived in interface NakReceiverWindow.Listener

printMessages

public String printMessages()

printSentMsgs

public String printSentMsgs()

printStats

public String printStats()
Overrides:
printStats in interface Protocol

providedDownServices

public Vector providedDownServices()
List of events that are provided to layers below (they will be handled when sent down from below).
Overrides:
providedDownServices in interface Protocol
Returns:
Vector (of Integers)

providedUpServices

public Vector providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above).
Overrides:
providedUpServices in interface Protocol
Returns:
Vector (of Integers)

resetStats

public void resetStats()
Overrides:
resetStats in interface Protocol

retransmit

public void retransmit(long first_seqno,
                       long last_seqno,
                       Address sender)
Implementation of Retransmitter.RetransmitCommand. Called by retransmission thread when gap is detected.
Specified by:
retransmit in interface Retransmitter.RetransmitCommand

setDiscardDeliveredMsgs

public void setDiscardDeliveredMsgs(boolean discard_delivered_msgs)

setGcLag

public void setGcLag(int gc_lag)

setMaxXmitBufSize

public void setMaxXmitBufSize(int max_xmit_buf_size)

setMaxXmitSize

public void setMaxXmitSize(long max_xmit_size)

setProperties

public boolean setProperties(Properties props)
Configures the protocol initially. A configuration string consists of name=value items, separated by a ';' (semicolon), e.g.:
 "loopback=false;unicast_inport=4444"
 
Overrides:
setProperties in interface Protocol

setUseMcastXmit

public void setUseMcastXmit(boolean use_mcast_xmit)

setXmitFromRandomMember

public void setXmitFromRandomMember(boolean xmit_from_random_member)

start

public void start()
            throws Exception
This method is called on a 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.
Overrides:
start in interface Protocol

stop

public void stop()
This method is called on a 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 flushed
Overrides:
stop in interface Protocol

up

public void up(Event evt)
Callback. Called by superclass when event may be handled.

Do not use PassUp in this method as the event is passed up by default by the superclass after this method returns !

Overrides:
up in interface Protocol

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.