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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.jgroups.stack.Protocol
      extended byorg.jgroups.stack.MessageProtocol
          extended byorg.jgroups.stack.RpcProtocol
              extended byorg.jgroups.protocols.FLUSH
All Implemented Interfaces:
org.jgroups.blocks.RequestHandler

public class FLUSH
extends org.jgroups.stack.RpcProtocol

The task of the FLUSH protocol is to flush all pending messages out of the system. This is done before a view change by stopping all senders and then agreeing on what messages should be delivered in the current view (before switching to the new view). A coordinator broadcasts a FLUSH message. The message contains an array of the highest sequence number for each member as seen by the coordinator so far. Each member responds with its highest sequence numbers seen so far (for each member): if its sequence number for a member P is higher than the one sent by the coordinator, it will append the messages apparently not received by the coordinator to its reply. The coordinator (when all replies have been received), computes for each member the lowest and highest sequence number and re-broadcasts messages accordingly (using ACKs rather then NAKs to ensure reliable delivery).

Example:


   FLUSH  ---> (p=10, q=22, r=7)

   <-- (p=10, q=20, r=7)    (did not receive 2 messages from q)
   <-- (p=12, q=23, r=7)    (attached are messages p11, p12, and q23)
   <-- (p=10, q=22, r=8)    (attached is message r8)
   ---------------------
   min:   11    21    8
   max:   12    23    8
   
The coordinator now computes the range for each member and re-broadcasts messages p11, p12, q21, q22, q23 and r8. This is essentially the exclusive min and inclusive max of all replies. Note that messages p11, p12 and q23 were not received by the coordinator itself before. They were only returned as result of the FLUSH replies and the coordinator now re-broadcasts them.


Field Summary
(package private)  java.lang.Object block_mutex
           
(package private)  long block_timeout
           
(package private)  boolean blocked
           
(package private)  Digest digest
           
(package private)  java.lang.Object digest_mutex
           
(package private)  long digest_timeout
           
(package private)  org.jgroups.util.List get_msgs
           
(package private)  java.lang.Object get_msgs_mutex
           
(package private)  long get_msgs_timeout
           
(package private)  long[] highest_delivered_msgs
           
(package private)  java.lang.Object highest_delivered_mutex
           
(package private)  boolean is_server
           
(package private)  org.jgroups.Address local_addr
           
(package private)  java.util.Vector mbrs
           
 
Fields inherited from class org.jgroups.stack.MessageProtocol
_corr, members
 
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
FLUSH()
           
 
Method Summary
private  FlushRsp flush(java.util.Vector dests)
          Triggered by reception of FLUSH event from GMS layer (must be coordinator).
(package private)  void getHighestDeliveredSeqnos()
          Returns the highest seqnos (for each member) seen so far (using the NAKACK layer)
(package private)  void getMessageDigest(long[] highest_seqnos)
          Interacts with a lower layer to retrieve unstable messages (e.g.
 java.lang.String getName()
           
 boolean handleDownEvent(org.jgroups.Event evt)
          Callback.
 Digest handleFlush(java.util.Vector flush_dests, long[] highest_seqnos)
          Called by coordinator running the FLUSH protocol.
 boolean handleUpEvent(org.jgroups.Event evt)
          Callback.
 java.util.Vector providedUpServices()
          List of events that are provided to layers above (they will be handled when sent down from above).
 void receiveDownEvent(org.jgroups.Event evt)
          The default handling adds the event to the down-queue where events are handled in order of addition by a thread.
 java.util.Vector requiredDownServices()
          List of events that are required to be answered by some layer below.
 boolean setProperties(java.util.Properties props)
          Configures the protocol initially.
 void start()
          This method is called on a Channel.connect(String)>Channel.connect(String) 55 .
 
Methods inherited from class org.jgroups.stack.RpcProtocol
callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethods, callRemoteMethods, callRemoteMethods, handle
 
Methods inherited from class org.jgroups.stack.MessageProtocol
castMessage, down, sendMessage, stop, up, updateView
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, receiveUpEvent, requiredUpServices, resetStats, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, 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

mbrs

final java.util.Vector mbrs

is_server

boolean is_server

block_mutex

final java.lang.Object block_mutex

block_timeout

long block_timeout

local_addr

org.jgroups.Address local_addr

blocked

boolean blocked

digest_mutex

final java.lang.Object digest_mutex

digest_timeout

long digest_timeout

highest_delivered_mutex

final java.lang.Object highest_delivered_mutex

highest_delivered_msgs

long[] highest_delivered_msgs

digest

Digest digest

get_msgs_mutex

final java.lang.Object get_msgs_mutex

get_msgs_timeout

final long get_msgs_timeout
See Also:
Constant Field Values

get_msgs

org.jgroups.util.List get_msgs
Constructor Detail

FLUSH

public FLUSH()
Method Detail

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).


requiredDownServices

public java.util.Vector requiredDownServices()
Description copied from class: org.jgroups.stack.Protocol
List of events that are required to be answered by some layer below.


start

public void start()
           throws java.lang.Exception
Description copied from class: org.jgroups.stack.Protocol
This method is called on a Channel.connect(String)>Channel.connect(String) 55 . 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.


flush

private FlushRsp flush(java.util.Vector dests)
Triggered by reception of FLUSH event from GMS layer (must be coordinator). Calls HandleFlush in all members and returns FLUSH_OK event.


handleFlush

public Digest handleFlush(java.util.Vector flush_dests,
                          long[] highest_seqnos)
Called by coordinator running the FLUSH protocol. Argument is an array of the highest seqnos as seen by the coordinator (for each member). handleFlush() checks for each member its own highest seqno seen for that member. If it is higher than the one seen by the coordinator, all higher messages are attached to the return value (a message digest).


getHighestDeliveredSeqnos

void getHighestDeliveredSeqnos()
Returns the highest seqnos (for each member) seen so far (using the NAKACK layer)


getMessageDigest

void getMessageDigest(long[] highest_seqnos)
Interacts with a lower layer to retrieve unstable messages (e.g. NAKACK)


handleUpEvent

public boolean handleUpEvent(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 !


handleDownEvent

public boolean handleDownEvent(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 !


receiveDownEvent

public void receiveDownEvent(org.jgroups.Event evt)
The default handling adds the event to the down-queue where events are handled in order of addition by a thread. However, there exists a deadlock between the FLUSH and BLOCK_OK down events: when a FLUSH event is received, a BLOCK is sent up, which triggers a BLOCK_OK event to be sent down to be handled by the FLUSH layer. However, the FLUSH layer's thread is still processing the FLUSH down event and is therefore blocked, waiting for a BLOCK_OK event. Therefore, the BLOCK_OK event has to 'preempt' the FLUSH event processing. This is done by overriding this method: when a BLOCK_OK event is received, it is processed immediately (in parallel to the FLUSH event), which causes the FLUSH event processing to return.


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"