org.jgroups.protocols.pbcast
Class GMS

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.pbcast.GMS
All Implemented Interfaces:
DiagnosticsHandler.ProbeHandler

public class GMS
extends Protocol
implements DiagnosticsHandler.ProbeHandler

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

Author:
Bela Ban

Nested Class Summary
static class GMS.GmsHeader
           
 
Field Summary
protected  AckCollector ack_collector
          To collect VIEW_ACKs from all members
protected  java.lang.Class<java.util.concurrent.Callable<java.lang.Boolean>> flushInvokerClass
           
protected  Address local_addr
           
protected  long ltime
           
protected  Membership members
           
protected  AckCollector merge_ack_collector
           
protected  int num_prev_mbrs
           
protected  TimeScheduler timer
           
protected  View view
           
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
GMS()
           
 
Method Summary
 MergeId _getMergeId()
           
protected  boolean _startFlush(View new_view, int maxAttempts, boolean resumeIfFailed, long randomFloor, long randomCeiling)
           
 void becomeClient()
           
 void becomeCoordinator()
           
 void becomeParticipant()
           
 void cancelMerge()
           
 void castViewChange(View new_view, Digest digest, JoinRsp jr, java.util.Collection<Address> newMembers)
          Broadcasts the new view and digest, and waits for acks from all members in the list given as argument.
protected  Address determineCoordinator()
           
 java.lang.Object down(Event evt)
          An event is to be sent down the stack.
 java.lang.String dumpViewHandlerHistory()
           
 java.lang.String dumpViewHandlerQueue()
           
 void fixDigests()
           
 Digest getDigest()
          Sends down a GET_DIGEST event and waits for the GET_DIGEST_OK response, or timeout, whichever occurs first
 GmsImpl getImpl()
           
 long getJoinTimeout()
           
 java.lang.String getLocalAddress()
           
 boolean getLogCollectMessages()
           
 long getMaxBundlingTime()
           
 long getMaxJoinAttempts()
           
 java.lang.String getMembers()
           
 java.lang.String getMergeId()
           
 Merger getMerger()
          Only used for internal testing, don't use this method !
 long getMergeTimeout()
           
 View getNextView(java.util.Collection<Address> new_mbrs, java.util.Collection<Address> old_mbrs, java.util.Collection<Address> suspected_mbrs)
          Computes the next view.
 int getNumberOfViews()
           
 int getNumMembers()
           
 java.lang.String getView()
           
 long getViewAckCollectionTimeout()
           
 Tuple<View,Digest> getViewAndDigest()
          Returns the current view and digest
 int getViewHandlerSize()
           
 ViewId getViewId()
           
 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.
 void installView(View new_view)
           
 void installView(View new_view, Digest digest)
          Sets the new view and sends a VIEW_CHANGE event up and down the stack.
 boolean isCoordinator()
           
 boolean isMergeInProgress()
           
 boolean isMergeKillerRunning()
           
 boolean isMergeTaskRunning()
           
 boolean isViewBundling()
           
 boolean isViewHandlerSuspended()
           
 void mergeDigest(Digest d)
          Send down a MERGE_DIGEST event
 java.lang.String printMergeIdHistory()
           
 java.lang.String printPreviousMembers()
           
 java.lang.String printPreviousViews()
           
 java.util.List<java.lang.Integer> providedDownServices()
          List of events that are provided to layers below (they will be handled when sent down below)
 java.util.List<java.lang.Integer> requiredDownServices()
          List of events that are required to be answered by some layer below
 void resetStats()
           
 void resumeViewHandler()
           
 void sendJoinResponse(JoinRsp rsp, Address dest)
           
 void setDigest(Digest d)
          Send down a SET_DIGEST event
 void setImpl(GmsImpl new_impl)
           
 void setJoinTimeout(long t)
           
 void setLogCollectMessages(boolean flag)
           
 void setMaxBundlingTime(long max_bundling_time)
           
 void setMaxJoinAttempts(long t)
           
 void setMergeTimeout(long timeout)
           
 void setPrintLocalAddr(boolean flag)
           
 void setPrintLocalAddress(boolean flag)
           
 void setViewAckCollectionTimeout(long view_ack_collection_timeout)
           
 void setViewBundling(boolean view_bundling)
           
 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
 void suspect(java.lang.String suspected_member)
           
 void suspendViewHandler()
           
 java.lang.Object up(Event evt)
          An event was received from the layer below.
protected  boolean wouldBeNewCoordinator(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, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedUpServices, 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

num_prev_mbrs

protected int num_prev_mbrs

flushInvokerClass

protected java.lang.Class<java.util.concurrent.Callable<java.lang.Boolean>> flushInvokerClass

local_addr

protected Address local_addr

members

protected final Membership members

view

protected View view

ltime

protected long ltime

timer

protected TimeScheduler timer

ack_collector

protected final AckCollector ack_collector
To collect VIEW_ACKs from all members


merge_ack_collector

protected final AckCollector merge_ack_collector
Constructor Detail

GMS

public GMS()
Method Detail

getViewId

public ViewId getViewId()

getViewAndDigest

public Tuple<View,Digest> getViewAndDigest()
Returns the current view and digest


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)

getMergeTimeout

public long getMergeTimeout()

setMergeTimeout

public void setMergeTimeout(long timeout)

getMaxJoinAttempts

public long getMaxJoinAttempts()

setMaxJoinAttempts

public void setMaxJoinAttempts(long t)

getMergeId

public java.lang.String getMergeId()

isMergeInProgress

public boolean isMergeInProgress()

getMerger

public Merger getMerger()
Only used for internal testing, don't use this method !


printMergeIdHistory

public java.lang.String printMergeIdHistory()

printPreviousMembers

public java.lang.String printPreviousMembers()

setPrintLocalAddress

public void setPrintLocalAddress(boolean flag)

setPrintLocalAddr

public void setPrintLocalAddr(boolean flag)

getViewAckCollectionTimeout

public long getViewAckCollectionTimeout()

setViewAckCollectionTimeout

public void setViewAckCollectionTimeout(long view_ack_collection_timeout)

isViewBundling

public boolean isViewBundling()

setViewBundling

public void setViewBundling(boolean view_bundling)

getMaxBundlingTime

public long getMaxBundlingTime()

setMaxBundlingTime

public void setMaxBundlingTime(long max_bundling_time)

getViewHandlerSize

public int getViewHandlerSize()

isViewHandlerSuspended

public boolean isViewHandlerSuspended()

dumpViewHandlerQueue

public java.lang.String dumpViewHandlerQueue()

dumpViewHandlerHistory

public java.lang.String dumpViewHandlerHistory()

suspendViewHandler

public void suspendViewHandler()

resumeViewHandler

public void resumeViewHandler()

printPreviousViews

public java.lang.String printPreviousViews()

suspect

public void suspect(java.lang.String suspected_member)

isCoordinator

public boolean isCoordinator()

_getMergeId

public MergeId _getMergeId()

setLogCollectMessages

public void setLogCollectMessages(boolean flag)

getLogCollectMessages

public boolean getLogCollectMessages()

resetStats

public void resetStats()
Overrides:
resetStats in class Protocol

requiredDownServices

public java.util.List<java.lang.Integer> requiredDownServices()
Description copied from class: Protocol
List of events that are required to be answered by some layer below

Overrides:
requiredDownServices in class Protocol

providedDownServices

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

Overrides:
providedDownServices in class Protocol

setImpl

public void setImpl(GmsImpl new_impl)

getImpl

public GmsImpl getImpl()

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

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

becomeCoordinator

public void becomeCoordinator()

becomeParticipant

public void becomeParticipant()

becomeClient

public void becomeClient()

fixDigests

public void fixDigests()

cancelMerge

public void cancelMerge()

isMergeTaskRunning

public boolean isMergeTaskRunning()

isMergeKillerRunning

public boolean isMergeKillerRunning()

getNextView

public View getNextView(java.util.Collection<Address> new_mbrs,
                        java.util.Collection<Address> old_mbrs,
                        java.util.Collection<Address> 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(View new_view,
                           Digest digest,
                           JoinRsp jr,
                           java.util.Collection<Address> newMembers)
Broadcasts the new view and digest, and waits for acks from all members in the list given as argument. If the list is null, we take the members who are part of new_view


sendJoinResponse

public void sendJoinResponse(JoinRsp rsp,
                             Address dest)

installView

public void installView(View new_view)

installView

public void installView(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.


determineCoordinator

protected Address determineCoordinator()

wouldBeNewCoordinator

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


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


_startFlush

protected boolean _startFlush(View new_view,
                              int maxAttempts,
                              boolean resumeIfFailed,
                              long randomFloor,
                              long randomCeiling)

up

public java.lang.Object up(Event evt)
Description copied from class: 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 down_prot.down() or c) the event (or another event) is sent up the stack using up_prot.up().

Overrides:
up in class Protocol

down

public java.lang.Object down(Event evt)
Description copied from class: 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 down_prot.down(). 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 up_prot.up().

Overrides:
down in class Protocol

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.