Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jgroups.protocols
Class NAKACK  view NAKACK download NAKACK.java

java.lang.Object
  extended byorg.jgroups.stack.Protocol
      extended byorg.jgroups.protocols.NAKACK

public class NAKACK
extends org.jgroups.stack.Protocol

Negative AcKnowledgement layer (NAKs), paired with positive ACKs. The default is to send a message using NAKs: the sender sends messages with monotonically increasing seqnos, receiver requests retransmissions of missing messages (gaps). When a SWITCH_NAK_ACK event is received, the mode is switched to using NAK_ACKS: the sender still uses monotonically increasing seqnos, but the receiver acknowledges every message. NAK and NAK_ACK seqnos are the same, when switching the mode, the current seqno is reused. Both NAK and NAK_ACK messages use the current view ID in which the message is sent to queue messages destined for an upcoming view, or discard messages sent in a previous view. Both modes reset their seqnos to 0 when receiving a view change. The NAK_ACK scheme is used for broadcasting view changes.

The third mode is for out-of-band control messages (activated by SWITCH_OUT_OF_BAND): this mode does neither employ view IDs, nor does it use the same seqnos as NAK and NAK_ACK. It uses its own seqnos, unrelated to the ones used by NAK and NAK_ACK, and never resets them. In combination with the sender's address, this makes every out-of-band message unique. Out-of-band messages are used for example for broadcasting FLUSH messages.

Once a mode is set, it remains in effect until exactly 1 message has been sent, afterwards the default mode NAK is used again.

The following communication between 2 peers exists (left side is initiator, right side receiver):

 

send_out_of_band --------------> synchronous (1) <------------- ack

send_nak --------------> asynchronous (2)

send_nak_ack --------------> synchronous (3) <-------------- ack

retransmit <-------------- asynchronous (4)

When a message is sent, it will contain a header describing the type of the message, and containing additional data, such as sequence number etc. When a message is received, it is fed into either the OutOfBander or NAKer, depending on the header's type.

Note that in the synchronous modes, ACKs are sent for each request. If a reliable unicast protocol layer exists somewhere underneath this layer, then even the ACKs are transmitted reliably, thus increasing the number of messages exchanged. However, since it is envisaged that ACK/OUT_OF_BAND are not used frequently, this problem is currently not addressed.


Nested Class Summary
(package private)  class NAKACK.NAKer
           
(package private)  class NAKACK.OutOfBander
           
 
Field Summary
(package private)  boolean is_server
           
(package private)  org.jgroups.Address local_addr
           
(package private)  java.util.Vector members
           
(package private)  NAKACK.NAKer naker
           
(package private)  NAKACK.OutOfBander out_of_bander
           
(package private)  org.jgroups.util.List queued_msgs
           
(package private)  long rebroadcast_timeout
           
(package private)  long[] retransmit_timeout
           
(package private)  boolean send_next_msg_acking
           
(package private)  boolean send_next_msg_out_of_band
           
(package private)  org.jgroups.util.TimeScheduler timer
           
(package private)  org.jgroups.ViewId vid
           
(package private)  org.jgroups.View view
           
(package private) static java.lang.String WRAPPED_MSG_KEY
           
 
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
(package private)  boolean coordinator()
           
(package private)  void deliverQueuedMessages()
          Deliver all messages in the queue where msg.vid == vid holds.
 void down(org.jgroups.Event evt)
          Callback.
 java.lang.String getName()
           
 void init()
          Do some initial tasks
 java.util.Vector providedDownServices()
          List of events that are provided to layers below (they will be handled when sent down from below).
 java.util.Vector providedUpServices()
          List of events that are provided to layers above (they will be handled when sent down from above).
(package private)  void rebroadcastMsgs(java.util.Vector v)
          Rebroadcasts the messages given as arguments
 boolean setProperties(java.util.Properties props)
          Configures the protocol initially.
 void stop()
          This method is called on a Channel.disconnect()>Channel.disconnect() 55 .
 void up(org.jgroups.Event evt)
          Callback.
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, isTrace, isWarn, passDown, passUp, printStats, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stopInternal, upThreadEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

retransmit_timeout

long[] retransmit_timeout

naker

NAKACK.NAKer naker

out_of_bander

NAKACK.OutOfBander out_of_bander

vid

org.jgroups.ViewId vid

view

org.jgroups.View view

is_server

boolean is_server

local_addr

org.jgroups.Address local_addr

queued_msgs

final org.jgroups.util.List queued_msgs

members

java.util.Vector members

send_next_msg_out_of_band

boolean send_next_msg_out_of_band

send_next_msg_acking

boolean send_next_msg_acking

rebroadcast_timeout

long rebroadcast_timeout

timer

org.jgroups.util.TimeScheduler timer

WRAPPED_MSG_KEY

static final java.lang.String WRAPPED_MSG_KEY
See Also:
Constant Field Values
Constructor Detail

NAKACK

public NAKACK()
Method Detail

init

public void init()
          throws java.lang.Exception
Do some initial tasks


stop

public void stop()
Description copied from class: org.jgroups.stack.Protocol
This method is called on a Channel.disconnect()>Channel.disconnect() 55 . 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


getName

public java.lang.String getName()

providedUpServices

public java.util.Vector providedUpServices()
Description copied from class: org.jgroups.stack.Protocol
List of events that are provided to layers above (they will be handled when sent down from above).


providedDownServices

public java.util.Vector providedDownServices()
Description copied from class: org.jgroups.stack.Protocol
List of events that are provided to layers below (they will be handled when sent down from below).


up

public void up(org.jgroups.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 !


down

public void down(org.jgroups.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 !


coordinator

boolean coordinator()

rebroadcastMsgs

void rebroadcastMsgs(java.util.Vector v)
Rebroadcasts the messages given as arguments


deliverQueuedMessages

void deliverQueuedMessages()
Deliver all messages in the queue where msg.vid == vid holds. Messages were stored in the queue because their vid was greater than the current view.


setProperties

public boolean setProperties(java.util.Properties props)
Description copied from class: org.jgroups.stack.Protocol
Configures the protocol initially. A configuration string consists of name=value items, separated by a ';' (semicolon), e.g.:
 "loopback=false;unicast_inport=4444"