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

Quick Search    Search Deep

org.jgroups.protocols.pbcast
Class GMS  view GMS download GMS.java

java.lang.Object
  extended byorg.jgroups.stack.Protocol
      extended byorg.jgroups.protocols.pbcast.GMS

public class GMS
extends org.jgroups.stack.Protocol

Group membership protocol. Handles joins/leaves/crashes (suspicions) and emits new views accordingly. Use VIEW_ENFORCER on top of this layer to make sure new members don't receive any messages until they are members.


Nested Class Summary
static class GMS.GmsHeader
           
static class GMS.Request
           
(package private)  class GMS.ViewHandler
          Class which processes JOIN, LEAVE and MERGE requests.
 
Field Summary
(package private)  org.jgroups.util.AckCollector ack_collector
          To collect VIEW_ACKs from all members
(package private) static java.lang.String CLIENT
           
(package private) static java.lang.String COORD
           
private  java.lang.Object digest_mutex
           
private  org.jgroups.util.Promise digest_promise
           
private  long digest_timeout
           
(package private)  boolean disable_initial_coord
           
(package private)  boolean handle_concurrent_startup
          Setting this to false disables concurrent startups.
private  GmsImpl impl
           
private  java.lang.Object impl_mutex
           
private  java.util.Hashtable impls
           
(package private)  long join_retry_timeout
           
(package private)  long join_timeout
           
private  java.util.Vector joining
          Members joined but for which no view has been received yet
(package private)  long leave_timeout
           
private  java.util.Vector leaving
          Members excluded from group, but for which no view has been received yet
(package private)  org.jgroups.Address local_addr
           
private  long ltime
           
(package private)  org.jgroups.Membership members
           
(package private)  boolean merge_leader
           
(package private)  long merge_timeout
           
(package private) static java.lang.String name
           
protected  int num_prev_mbrs
          Max number of old members to keep in history
(package private)  int num_views
           
(package private) static java.lang.String PART
           
(package private)  org.jgroups.util.BoundedList prev_members
          Keeps track of old members (up to num_prev_mbrs)
(package private)  org.jgroups.util.BoundedList prev_views
          Stores the last 20 views
private  boolean print_local_addr
           
private  boolean shun
           
(package private)  org.jgroups.util.TimeScheduler timer
           
private  org.jgroups.Membership tmp_members
           
(package private)  org.jgroups.View view
           
(package private)  long view_ack_collection_timeout
          Time in ms to wait for all VIEW acks (0 == wait forever)
 GMS.ViewHandler view_handler
          Class to process JOIN, LEAVE and MERGE requests
(package private)  org.jgroups.ViewId view_id
           
 
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
GMS()
           
 
Method Summary
 void becomeClient()
           
 void becomeCoordinator()
           
 void becomeParticipant()
           
 void castViewChange(java.util.Vector new_mbrs, java.util.Vector old_mbrs, java.util.Vector suspected_mbrs)
          Compute a new view, given the current view, the new members and the suspected/left members.
 void castViewChange(org.jgroups.View new_view, Digest digest)
           
protected  boolean checkSelfInclusion(java.util.Vector mbrs)
          Returns true if local_addr is member of mbrs, else false
protected  org.jgroups.Address determineCoordinator()
           
 void down(org.jgroups.Event evt)
          An event is to be sent down the stack.
 Digest getDigest()
          Sends down a GET_DIGEST event and waits for the GET_DIGEST_OK response, or timeout, whichever occurs first
 GmsImpl getImpl()
           
 long getJoinRetryTimeout()
           
 long getJoinTimeout()
           
 java.lang.String getLocalAddress()
           
(package private)  org.apache.commons.logging.Log getLog()
           
 java.lang.String getMembers()
           
 java.lang.String getName()
           
 org.jgroups.View getNextView(java.util.Vector new_mbrs, java.util.Vector old_mbrs, java.util.Vector suspected_mbrs)
          Computes the next view.
 int getNumberOfViews()
           
 int getNumMembers()
           
 java.lang.String getView()
           
(package private)  boolean haveCoordinatorRole()
           
 void init()
          Called after instance has been created (null constructor) and before protocol is started.
(package private)  void initState()
           
 void installView(org.jgroups.View new_view)
          Sets the new view and sends a VIEW_CHANGE event up and down the stack.
 void installView(org.jgroups.View new_view, Digest digest)
          Sets the new view and sends a VIEW_CHANGE event up and down the stack.
 boolean isCoordinator()
           
 boolean isShun()
           
 org.jgroups.View makeView(java.util.Vector mbrs)
           
 org.jgroups.View makeView(java.util.Vector mbrs, org.jgroups.ViewId vid)
           
 void mergeDigest(Digest d)
          Send down a MERGE_DIGEST event
 java.lang.String printPreviousMembers()
           
 java.lang.String printPreviousViews()
           
 void receiveUpEvent(org.jgroups.Event evt)
          This method is overridden to avoid hanging on getDigest(): when a JOIN is received, the coordinator needs to retrieve the digest from the NAKACK layer.
 java.util.Vector requiredDownServices()
          List of events that are required to be answered by some layer below.
 void resetStats()
           
 void setDigest(Digest d)
          Send down a SET_DIGEST event
 void setImpl(GmsImpl new_impl)
           
 void setJoinRetryTimeout(long t)
           
 void setJoinTimeout(long t)
           
 boolean setProperties(java.util.Properties props)
          Setup the Protocol instance according to the configuration string
 void setShun(boolean s)
           
 void start()
          This method is called on a Channel.connect(String)>Channel.connect(String) 55 .
 void stop()
          This method is called on a Channel.disconnect()>Channel.disconnect() 55 .
 void up(org.jgroups.Event evt)
          An event was received from the layer below.
protected  boolean wouldBeNewCoordinator(org.jgroups.Address potential_new_coord)
          Checks whether the potential_new_coord would be the new coordinator (2nd in line)
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, requiredUpServices, 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

impl

private GmsImpl impl

local_addr

org.jgroups.Address local_addr

members

final org.jgroups.Membership members

tmp_members

private final org.jgroups.Membership tmp_members

joining

private final java.util.Vector joining
Members joined but for which no view has been received yet


leaving

private final java.util.Vector leaving
Members excluded from group, but for which no view has been received yet


view

org.jgroups.View view

view_id

org.jgroups.ViewId view_id

ltime

private long ltime

join_timeout

long join_timeout

join_retry_timeout

long join_retry_timeout

leave_timeout

long leave_timeout

digest_timeout

private long digest_timeout

merge_timeout

long merge_timeout

impl_mutex

private final java.lang.Object impl_mutex

digest_mutex

private final java.lang.Object digest_mutex

digest_promise

private final org.jgroups.util.Promise digest_promise

impls

private final java.util.Hashtable impls

shun

private boolean shun

merge_leader

boolean merge_leader

print_local_addr

private boolean print_local_addr

disable_initial_coord

boolean disable_initial_coord

handle_concurrent_startup

boolean handle_concurrent_startup
Setting this to false disables concurrent startups. This is only used by unit testing code for testing merging. To everybody else: don't change it to false !


CLIENT

static final java.lang.String CLIENT
See Also:
Constant Field Values

COORD

static final java.lang.String COORD
See Also:
Constant Field Values

PART

static final java.lang.String PART
See Also:
Constant Field Values

timer

org.jgroups.util.TimeScheduler timer

num_prev_mbrs

protected int num_prev_mbrs
Max number of old members to keep in history


prev_members

org.jgroups.util.BoundedList prev_members
Keeps track of old members (up to num_prev_mbrs)


num_views

int num_views

prev_views

org.jgroups.util.BoundedList prev_views
Stores the last 20 views


view_handler

public final GMS.ViewHandler view_handler
Class to process JOIN, LEAVE and MERGE requests


ack_collector

final org.jgroups.util.AckCollector ack_collector
To collect VIEW_ACKs from all members


view_ack_collection_timeout

long view_ack_collection_timeout
Time in ms to wait for all VIEW acks (0 == wait forever)


name

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

GMS

public GMS()
Method Detail

getName

public java.lang.String getName()

getView

public java.lang.String getView()

getNumberOfViews

public int getNumberOfViews()

getLocalAddress

public java.lang.String getLocalAddress()

getMembers

public java.lang.String getMembers()

getNumMembers

public int getNumMembers()

getJoinTimeout

public long getJoinTimeout()

setJoinTimeout

public void setJoinTimeout(long t)

getJoinRetryTimeout

public long getJoinRetryTimeout()

setJoinRetryTimeout

public void setJoinRetryTimeout(long t)

isShun

public boolean isShun()

setShun

public void setShun(boolean s)

printPreviousMembers

public java.lang.String printPreviousMembers()

getLog

org.apache.commons.logging.Log getLog()

printPreviousViews

public java.lang.String printPreviousViews()

isCoordinator

public boolean isCoordinator()

resetStats

public void resetStats()

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.


setImpl

public void setImpl(GmsImpl new_impl)

getImpl

public GmsImpl getImpl()

init

public void init()
          throws java.lang.Exception
Description copied from class: org.jgroups.stack.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.


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.


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


becomeCoordinator

public void becomeCoordinator()

becomeParticipant

public void becomeParticipant()

becomeClient

public void becomeClient()

haveCoordinatorRole

boolean haveCoordinatorRole()

getNextView

public org.jgroups.View getNextView(java.util.Vector new_mbrs,
                                    java.util.Vector old_mbrs,
                                    java.util.Vector suspected_mbrs)
Computes the next view. Returns a copy that has old_mbrs and suspected_mbrs removed and new_mbrs added.


castViewChange

public void castViewChange(java.util.Vector new_mbrs,
                           java.util.Vector old_mbrs,
                           java.util.Vector suspected_mbrs)
Compute a new view, given the current view, the new members and the suspected/left members. Then simply mcast the view to all members. This is different to the VS GMS protocol, in which we run a FLUSH protocol which tries to achive consensus on the set of messages mcast in the current view before proceeding to install the next view. The members for the new view are computed as follows:
     existing          leaving        suspected          joining

     1. new_view      y                 n               n                 y
     2. tmp_view      y                 y               n                 y
     (view_dest)
     
  1. The new view to be installed includes the existing members plus the joining ones and excludes the leaving and suspected members.
  2. A temporary view is sent down the stack as an event. This allows the bottom layer (e.g. UDP or TCP) to determine the members to which to send a multicast message. Compared to the new view, leaving members are included since they have are waiting for a view in which they are not members any longer before they leave. So, if we did not set a temporary view, joining members would not receive the view (signalling that they have been joined successfully). The temporary view is essentially the current view plus the joining members (old members are still part of the current view).


castViewChange

public void castViewChange(org.jgroups.View new_view,
                           Digest digest)

installView

public void installView(org.jgroups.View new_view,
                        Digest digest)
Sets the new view and sends a VIEW_CHANGE event up and down the stack. If the view is a MergeView (subclass of View), then digest will be non-null and has to be set before installing the view.


installView

public void installView(org.jgroups.View new_view)
Sets the new view and sends a VIEW_CHANGE event up and down the stack.


determineCoordinator

protected org.jgroups.Address determineCoordinator()

wouldBeNewCoordinator

protected boolean wouldBeNewCoordinator(org.jgroups.Address potential_new_coord)
Checks whether the potential_new_coord would be the new coordinator (2nd in line)


checkSelfInclusion

protected boolean checkSelfInclusion(java.util.Vector mbrs)
Returns true if local_addr is member of mbrs, else false


makeView

public org.jgroups.View makeView(java.util.Vector mbrs)

makeView

public org.jgroups.View makeView(java.util.Vector mbrs,
                                 org.jgroups.ViewId vid)

setDigest

public void setDigest(Digest d)
Send down a SET_DIGEST event


mergeDigest

public void mergeDigest(Digest d)
Send down a MERGE_DIGEST event


getDigest

public Digest getDigest()
Sends down a GET_DIGEST event and waits for the GET_DIGEST_OK response, or timeout, whichever occurs first


up

public void up(org.jgroups.Event evt)
Description copied from class: org.jgroups.stack.Protocol
An event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack using passDown() or c) the event (or another event) is sent up the stack using passUp().


receiveUpEvent

public void receiveUpEvent(org.jgroups.Event evt)
This method is overridden to avoid hanging on getDigest(): when a JOIN is received, the coordinator needs to retrieve the digest from the NAKACK layer. It therefore sends down a GET_DIGEST event, to which the NAKACK layer responds with a GET_DIGEST_OK event.

However, the GET_DIGEST_OK event will not be processed because the thread handling the JOIN request won't process the GET_DIGEST_OK event until the JOIN event returns. The receiveUpEvent() method is executed by the up-handler thread of the lower protocol and therefore can handle the event. All we do here is unblock the mutex on which JOIN is waiting, allowing JOIN to return with a valid digest. The GET_DIGEST_OK event is then discarded, because it won't be processed twice.


down

public void down(org.jgroups.Event evt)
Description copied from class: org.jgroups.stack.Protocol
An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack using passDown(). 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 passUp().


setProperties

public boolean setProperties(java.util.Properties props)
Setup the Protocol instance according to the configuration string


initState

void initState()