org.jgroups.protocols.pbcast
Class NAKACK

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.pbcast.NAKACK
All Implemented Interfaces:
DiagnosticsHandler.ProbeHandler, Retransmitter.RetransmitCommand

public class NAKACK
extends Protocol
implements Retransmitter.RetransmitCommand, DiagnosticsHandler.ProbeHandler

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.
Retransmit requests are usually sent to the original sender of a message, but this can be changed by xmit_from_random_member (send to random member) or use_mcast_xmit_req (send to everyone). Responses can also be sent to everyone instead of the requester by setting use_mcast_xmit to true.

Author:
Bela Ban

Field Summary
protected  BoundedList<Message> become_server_queue
           
protected  int become_server_queue_size
           
protected  BoundedList<java.lang.String> digest_history
          Keeps a bounded list of the last N digest sets
protected  int num_messages_received
           
protected  int num_messages_sent
           
protected  boolean print_stability_history_on_failed_xmit
          When not finding a message on an XMIT request, include the last N stability messages in the error message
protected  BoundedList<Digest> stability_msgs
          BoundedList, keeps the last 10 stability messages
protected  SuppressLog<Address> suppress_log_non_member
          Log to suppress identical warnings for messages from non-members
protected  long suppress_time_non_member_warnings
           
protected  long xmit_stagger_timeout
           
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
NAKACK()
           
 
Method Summary
protected  void checkForRebroadcasts()
           
 void clearNonMemberCache()
           
 void compact()
           
 java.lang.Object down(Event evt)
          Callback.
 java.util.Map<java.lang.String,java.lang.Object> dumpStats()
           
protected  void flushBecomeServerQueue()
          Flushes the queue.
 long getCurrentSeqno()
           
 Digest getDigest()
          Returns a message digest: for each member P the highest delivered and received seqno is added
 Digest getDigest(Address mbr)
           
 boolean getLogDiscardMessages()
           
 int getNonMemberMessages()
           
 int getPendingXmitRequests()
           
 long getSizeOfAllMessages()
           
 long getSizeOfAllMessagesInclHeaders()
           
 NakReceiverWindow getWindow(Address mbr)
          Please don't use this method; it is only provided for unit testing !
 long getXmitRequestsReceived()
           
 long getXmitRequestsSent()
           
 long getXmitResponsesReceived()
           
 long getXmitResponsesSent()
           
 int getXmitTableMissingMessages()
           
 int getXmitTableSize()
           
 java.util.Map<java.lang.String,java.lang.String> handleProbe(java.lang.String... keys)
          Handles a probe.
 void init()
          Called after instance has been created (null constructor) and before protocol is started.
 boolean isDiscardDeliveredMsgs()
           
 boolean isUseMcastXmit()
           
 boolean isXmitFromRandomMember()
           
 java.lang.String printDigestHistory()
           
 java.lang.String printLossRates()
           
 java.lang.String printMessages()
           
 java.lang.String printRetransmitStats()
           
 java.lang.String printRetransmitTableSizes()
           
 java.lang.String printStabilityHistory()
           
 java.lang.String printStabilityMessages()
           
 java.lang.String printStats()
           
 java.util.List<java.lang.Integer> 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.
protected  void retransmit(long first_seqno, long last_seqno, Address sender, boolean multicast_xmit_request)
           
protected  void send(Event evt, Message msg)
          Adds the message to the sent_msgs table and then passes it down the stack.
 void setDiscardDeliveredMsgs(boolean discard_delivered_msgs)
           
 void setLogDiscardMessages(boolean flag)
           
 void setLogDiscardMsgs(boolean flag)
           
 void setTimer(TimeScheduler timer)
          Only used for unit tests, don't use !
 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().
 java.lang.String[] supportedKeys()
          Returns a list of supported keys
 java.lang.Object up(Event evt)
          Callback.
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmit_stagger_timeout

protected long xmit_stagger_timeout

print_stability_history_on_failed_xmit

protected boolean print_stability_history_on_failed_xmit
When not finding a message on an XMIT request, include the last N stability messages in the error message


become_server_queue_size

protected int become_server_queue_size

suppress_time_non_member_warnings

protected long suppress_time_non_member_warnings

num_messages_sent

protected int num_messages_sent

num_messages_received

protected int num_messages_received

stability_msgs

protected final BoundedList<Digest> stability_msgs
BoundedList, keeps the last 10 stability messages


digest_history

protected final BoundedList<java.lang.String> digest_history
Keeps a bounded list of the last N digest sets


become_server_queue

protected BoundedList<Message> become_server_queue

suppress_log_non_member

protected SuppressLog<Address> suppress_log_non_member
Log to suppress identical warnings for messages from non-members

Constructor Detail

NAKACK

public NAKACK()
Method Detail

getNonMemberMessages

public int getNonMemberMessages()

clearNonMemberCache

public void clearNonMemberCache()

getXmitRequestsReceived

public long getXmitRequestsReceived()

getXmitRequestsSent

public long getXmitRequestsSent()

getXmitResponsesReceived

public long getXmitResponsesReceived()

getXmitResponsesSent

public long getXmitResponsesSent()

getPendingXmitRequests

public int getPendingXmitRequests()

getXmitTableSize

public int getXmitTableSize()

getXmitTableMissingMessages

public int getXmitTableMissingMessages()

getSizeOfAllMessages

public long getSizeOfAllMessages()

getSizeOfAllMessagesInclHeaders

public long getSizeOfAllMessagesInclHeaders()

getCurrentSeqno

public long getCurrentSeqno()

printRetransmitStats

public java.lang.String printRetransmitStats()

getWindow

public NakReceiverWindow getWindow(Address mbr)
Please don't use this method; it is only provided for unit testing !

Parameters:
mbr -
Returns:

setTimer

public void setTimer(TimeScheduler timer)
Only used for unit tests, don't use !

Parameters:
timer -

resetStats

public void resetStats()
Overrides:
resetStats in class Protocol

init

public void init()
          throws java.lang.Exception
Description copied from class: Protocol
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 class Protocol
Throws:
java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception

isUseMcastXmit

public boolean isUseMcastXmit()

setUseMcastXmit

public void setUseMcastXmit(boolean use_mcast_xmit)

isXmitFromRandomMember

public boolean isXmitFromRandomMember()

setXmitFromRandomMember

public void setXmitFromRandomMember(boolean xmit_from_random_member)

isDiscardDeliveredMsgs

public boolean isDiscardDeliveredMsgs()

setDiscardDeliveredMsgs

public void setDiscardDeliveredMsgs(boolean discard_delivered_msgs)

setLogDiscardMessages

public void setLogDiscardMessages(boolean flag)

setLogDiscardMsgs

public void setLogDiscardMsgs(boolean flag)

getLogDiscardMessages

public boolean getLogDiscardMessages()

dumpStats

public java.util.Map<java.lang.String,java.lang.Object> dumpStats()
Overrides:
dumpStats in class Protocol

printStats

public java.lang.String printStats()
Overrides:
printStats in class Protocol

printStabilityMessages

public java.lang.String printStabilityMessages()

printStabilityHistory

public java.lang.String printStabilityHistory()

printDigestHistory

public java.lang.String printDigestHistory()

printLossRates

public java.lang.String printLossRates()

printRetransmitTableSizes

public java.lang.String printRetransmitTableSizes()

compact

public void compact()

providedUpServices

public java.util.List<java.lang.Integer> providedUpServices()
Description copied from class: Protocol
List of events that are provided to layers above (they will be handled when sent down from above)

Overrides:
providedUpServices in class Protocol

start

public void start()
           throws java.lang.Exception
Description copied from class: Protocol
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 class Protocol
Throws:
java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so Channel.connect(String) will throw an exception

stop

public void stop()
Description copied from class: Protocol
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 class Protocol

down

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

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

Overrides:
down in class Protocol

up

public java.lang.Object 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 class Protocol

send

protected void send(Event evt,
                    Message msg)
Adds the message to the sent_msgs table and then passes it down the stack. Change Bela Ban May 26 2002: we don't store a copy of the message, but a reference ! This saves us a lot of memory. However, this also means that a message should not be changed after storing it in the sent-table ! See protocols/DESIGN for details. Made seqno increment and adding to sent_msgs atomic, e.g. seqno won't get incremented if adding to sent_msgs fails e.g. due to an OOM (see http://jira.jboss.com/jira/browse/JGRP-179). bela Jan 13 2006


flushBecomeServerQueue

protected void flushBecomeServerQueue()
Flushes the queue. Done in a separate thread as we don't want to block the ClientGmsImpl.installView(org.jgroups.View,org.jgroups.util.Digest) method (called when a view is installed).


checkForRebroadcasts

protected void checkForRebroadcasts()

getDigest

public Digest getDigest()
Returns a message digest: for each member P the highest delivered and received seqno is added


getDigest

public Digest getDigest(Address mbr)

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
Parameters:
first_seqno - The sequence number of the first missing message
last_seqno - The sequence number of the last missing message
sender - 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).

retransmit

protected void retransmit(long first_seqno,
                          long last_seqno,
                          Address sender,
                          boolean multicast_xmit_request)

printMessages

public java.lang.String printMessages()

handleProbe

public java.util.Map<java.lang.String,java.lang.String> handleProbe(java.lang.String... keys)
Description copied from interface: DiagnosticsHandler.ProbeHandler
Handles a probe. For each key that is handled, the key and its result should be in the returned map.

Specified by:
handleProbe in interface DiagnosticsHandler.ProbeHandler
Returns:
Map. A map of keys and values. A null return value is permissible.

supportedKeys

public java.lang.String[] supportedKeys()
Description copied from interface: DiagnosticsHandler.ProbeHandler
Returns a list of supported keys

Specified by:
supportedKeys in interface DiagnosticsHandler.ProbeHandler


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.