org.jgroups.protocols

Class GMS

Implemented Interfaces:
Runnable, RequestHandler

public class GMS
extends RpcProtocol
implements Runnable

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

Field Summary

String
group_addr
Object
impl_mutex
long
join_retry_timeout
long
join_timeout
long
leave_timeout
Address
local_addr
long
ltime
Membership
members
Properties
props
ViewId
view_id
Object
view_mutex

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, up_handler, up_prot, up_queue, up_thread, up_thread_prio

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.
protected boolean
checkSelfInclusion(Vector mbrs)
Returns true if local_addr is member of mbrs, else false
protected Address
determineCoordinator()
void
flush(Vector flush_dest, Vector suspected_mbrs)
FLUSH protocol.
String
getName()
View
getNextView(Vector new_mbrs, Vector old_mbrs, Vector suspected_mbrs)
Computes the next view.
boolean
handleDownEvent(Event evt)
Callback.
boolean
handleJoin(Address mbr)
void
handleLeave(Address mbr, boolean suspected)
View
handleMerge(ViewId other_vid, Vector other_members)
void
handleSuspect(Address mbr)
boolean
handleUpEvent(Event evt)
Callback.
void
handleViewChange(ViewId new_view, Vector mbrs)
void
installView(ViewId new_view, Vector mbrs)
Assigns the new ltime.
void
join(Address mbr)
void
leave(Address mbr)
View
makeView(Vector mbrs)
View
makeView(Vector mbrs, ViewId vid)
void
merge(Vector other_coords)
void
receiveDownEvent(Event evt)
Vector
requiredDownServices()
void
run()
void
setImpl(GmsImpl new_impl)
boolean
setProperties(Properties props)
Setup the Protocol instance acording to the configuration string
void
start()
void
suspect(Address mbr)

Methods inherited from class org.jgroups.stack.RpcProtocol

callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethods, callRemoteMethods, callRemoteMethods, getName, handle, handleDownEvent, handleUpEvent

Methods inherited from class org.jgroups.stack.MessageProtocol

castMessage, down, handle, handleDownEvent, handleUpEvent, sendMessage, start, stop, up, updateView

Methods inherited from class org.jgroups.stack.Protocol

destroy, down, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, passDown, passUp, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setUpProtocol, start, startDownHandler, startUpHandler, stop, stopInternal, up

Field Details

group_addr

public String group_addr


impl_mutex

public Object impl_mutex


join_retry_timeout

public long join_retry_timeout


join_timeout

public long join_timeout


leave_timeout

public long leave_timeout


local_addr

public Address local_addr


ltime

public long ltime


members

public Membership members


props

public Properties props


view_id

public ViewId view_id


view_mutex

public Object view_mutex

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. Run view update protocol to install a new view in all members (this involves casting the new view to all members). The targets for FLUSH and VIEW mcasts are computed as follows:

 existing          leaving        suspected          joining
 

1. FLUSH y y n n 2. new_view y n n y 3. tmp_view y y n y (view_dest)

  1. The FLUSH is only sent to the existing and leaving members (they are the only ones that might have old messages not yet seen by the group. The suspected members would not answer anyway (because they have failed) and the joining members have certainly no old messages.
  2. The new view to be installed includes the existing members plus the joining ones and excludes the leaving and suspected members.
  3. 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).


checkSelfInclusion

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


determineCoordinator

protected Address determineCoordinator()


flush

public void flush(Vector flush_dest,
                  Vector suspected_mbrs)
FLUSH protocol. Send to current mbrs - suspected_mbrs (not including new_mbrs, but including old_mbr) Send TMP_VIEW event down, this allows FLUSH/NAKACK to set membership correctly


getName

public String getName()
Overrides:
getName in interface RpcProtocol


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.


handleDownEvent

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

Overrides:
handleDownEvent in interface RpcProtocol

Returns:
boolean Defaults to true. If false, event will not be passed down the stack.


handleJoin

public boolean handleJoin(Address mbr)


handleLeave

public void handleLeave(Address mbr,
                        boolean suspected)


handleMerge

public View handleMerge(ViewId other_vid,
                        Vector other_members)


handleSuspect

public void handleSuspect(Address mbr)


handleUpEvent

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

Overrides:
handleUpEvent in interface RpcProtocol

Returns:
boolean Defaults to true. If false, event will not be passed up the stack.


handleViewChange

public void handleViewChange(ViewId new_view,
                             Vector mbrs)


installView

public void installView(ViewId new_view,
                        Vector mbrs)
Assigns the new ltime. Installs view and view_id. Changes role to coordinator if necessary. Sends VIEW_CHANGE event up and down the stack.


join

public void join(Address mbr)


leave

public void leave(Address mbr)


makeView

public View makeView(Vector mbrs)


makeView

public View makeView(Vector mbrs,
                     ViewId vid)


merge

public void merge(Vector other_coords)


receiveDownEvent

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


requiredDownServices

public Vector requiredDownServices()
Overrides:
requiredDownServices in interface Protocol


run

public void run()


setImpl

public void setImpl(GmsImpl new_impl)


setProperties

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


start

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


suspect

public void suspect(Address mbr)


Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.