org.jgroups.protocols.pbcast

Class GMS


public class GMS
extends 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

Field Summary

protected int
num_prev_mbrs
Max number of old members to keep in history
org.jgroups.protocols.pbcast.GMS.ViewHandler
view_handler
Class to process JOIN, LEAVE and MERGE requests

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(Vector new_mbrs, Vector old_mbrs, Vector suspected_mbrs)
Compute a new view, given the current view, the new members and the suspected/left members.
void
castViewChange(View new_view, Digest digest)
void
castViewChangeWithDest(View new_view, Digest digest, java.util.List members)
Broadcasts the new view and digest, and waits for acks from all members in the list given as argument.
protected boolean
checkSelfInclusion(Vector mbrs)
Returns true if local_addr is member of mbrs, else false
protected Address
determineCoordinator()
void
down(Event evt)
String
dumpViewHandlerHistory()
String
dumpViewHandlerQueue()
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()
String
getLocalAddress()
String
getMembers()
String
getName()
View
getNextView(Vector new_mbrs, Vector old_mbrs, Vector suspected_mbrs)
Computes the next view.
int
getNumMembers()
int
getNumberOfViews()
String
getView()
void
init()
void
installView(View new_view)
Sets the new view and sends a VIEW_CHANGE event up and down the stack.
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
isShun()
boolean
isViewHandlerSuspended()
View
makeView(Vector mbrs)
View
makeView(Vector mbrs, ViewId vid)
void
mergeDigest(Digest d)
Send down a MERGE_DIGEST event
String
printPreviousMembers()
String
printPreviousViews()
void
receiveUpEvent(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.
Vector
requiredDownServices()
void
resetStats()
void
resumeViewHandler()
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(Properties props)
Setup the Protocol instance according to the configuration string
void
setShun(boolean s)
void
start()
void
stop()
void
suspendViewHandler()
void
up(Event evt)
int
viewHandlerSize()
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, down, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stop, stopInternal, up, upThreadEnabled

Field Details

num_prev_mbrs

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

view_handler

public final org.jgroups.protocols.pbcast.GMS.ViewHandler view_handler
Class to process JOIN, LEAVE and MERGE requests

Constructor Details

GMS

public GMS()

Method Details

becomeClient

public void becomeClient()

becomeCoordinator

public void becomeCoordinator()

becomeParticipant

public void becomeParticipant()

castViewChange

public void castViewChange(Vector new_mbrs,
                           Vector old_mbrs,
                           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(View new_view,
                           Digest digest)

castViewChangeWithDest

public void castViewChangeWithDest(View new_view,
                                   Digest digest,
                                   java.util.List members)
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
Parameters:
new_view -
digest -
members -

checkSelfInclusion

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

determineCoordinator

protected Address determineCoordinator()

down

public void down(Event evt)
Overrides:
down in interface Protocol

dumpViewHandlerHistory

public String dumpViewHandlerHistory()

dumpViewHandlerQueue

public String dumpViewHandlerQueue()

getDigest

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

getImpl

public GmsImpl getImpl()

getJoinRetryTimeout

public long getJoinRetryTimeout()

getJoinTimeout

public long getJoinTimeout()

getLocalAddress

public String getLocalAddress()

getMembers

public String getMembers()

getName

public String getName()
Overrides:
getName in interface Protocol

getNextView

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

getNumMembers

public int getNumMembers()

getNumberOfViews

public int getNumberOfViews()

getView

public String getView()

init

public void init()
            throws Exception
Overrides:
init in interface Protocol

installView

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

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.

isCoordinator

public boolean isCoordinator()

isShun

public boolean isShun()

isViewHandlerSuspended

public boolean isViewHandlerSuspended()

makeView

public View makeView(Vector mbrs)

makeView

public View makeView(Vector mbrs,
                     ViewId vid)

mergeDigest

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

printPreviousMembers

public String printPreviousMembers()

printPreviousViews

public String printPreviousViews()

receiveUpEvent

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

Overrides:
receiveUpEvent in interface Protocol

requiredDownServices

public Vector requiredDownServices()
Overrides:
requiredDownServices in interface Protocol

resetStats

public void resetStats()
Overrides:
resetStats in interface Protocol

resumeViewHandler

public void resumeViewHandler()

setDigest

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

setImpl

public void setImpl(GmsImpl new_impl)

setJoinRetryTimeout

public void setJoinRetryTimeout(long t)

setJoinTimeout

public void setJoinTimeout(long t)

setProperties

public boolean setProperties(Properties props)
Setup the Protocol instance according to the configuration string
Overrides:
setProperties in interface Protocol

setShun

public void setShun(boolean s)

start

public void start()
            throws Exception
Overrides:
start in interface Protocol

stop

public void stop()
Overrides:
stop in interface Protocol

suspendViewHandler

public void suspendViewHandler()

up

public void up(Event evt)
Overrides:
up in interface Protocol

viewHandlerSize

public int viewHandlerSize()

wouldBeNewCoordinator

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

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.