org.javagroups.protocols
Class GMS
java.lang.Object
|
+--org.javagroups.stack.Protocol
|
+--org.javagroups.stack.MessageProtocol
|
+--org.javagroups.stack.RpcProtocol
|
+--org.javagroups.protocols.GMS
- All Implemented Interfaces:
- RequestHandler, java.lang.Runnable
- public class GMS
- extends RpcProtocol
- implements java.lang.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
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. |
protected boolean |
checkSelfInclusion(java.util.Vector mbrs)
Returns true if local_addr is member of mbrs, else false |
protected Address |
determineCoordinator()
|
void |
flush(java.util.Vector flush_dest,
java.util.Vector suspected_mbrs)
FLUSH protocol. |
java.lang.String |
getName()
|
View |
getNextView(java.util.Vector new_mbrs,
java.util.Vector old_mbrs,
java.util.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,
java.util.Vector other_members)
|
void |
handleSuspect(Address mbr)
|
boolean |
handleUpEvent(Event evt)
Callback. |
void |
handleViewChange(ViewId new_view,
java.util.Vector mbrs)
|
void |
installView(ViewId new_view,
java.util.Vector mbrs)
Assigns the new ltime. |
void |
join(Address mbr)
|
void |
leave(Address mbr)
|
View |
makeView(java.util.Vector mbrs)
|
View |
makeView(java.util.Vector mbrs,
ViewId vid)
|
void |
merge(java.util.Vector other_coords)
|
void |
receiveDownEvent(Event evt)
Internal method, should not be called by clients. |
java.util.Vector |
requiredDownServices()
List of events that are required to be answered by some layer below. |
void |
run()
|
void |
setImpl(GmsImpl new_impl)
|
boolean |
setProperties(java.util.Properties props)
Setup the Protocol instance acording to the configuration string |
void |
suspect(Address mbr)
|
Methods inherited from class org.javagroups.stack.RpcProtocol |
callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethods, callRemoteMethods, callRemoteMethods, callRemoteMethods, callRemoteMethods, callRemoteMethods, callRemoteMethods, handle |
Methods inherited from class org.javagroups.stack.Protocol |
getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, init, passDown, passUp, providedDownServices, providedUpServices, receiveUpEvent, requiredUpServices, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setUpProtocol, startDownHandler, startUpHandler, stopInternal |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
props
public java.util.Properties props
local_addr
public Address local_addr
group_addr
public java.lang.String group_addr
members
public Membership members
view_id
public ViewId view_id
ltime
public long ltime
join_timeout
public long join_timeout
join_retry_timeout
public long join_retry_timeout
leave_timeout
public long leave_timeout
impl_mutex
public java.lang.Object impl_mutex
view_mutex
public java.lang.Object view_mutex
GMS
public GMS()
getName
public java.lang.String getName()
- Overrides:
getName
in class RpcProtocol
requiredDownServices
public java.util.Vector requiredDownServices()
- Description copied from class:
Protocol
- List of events that are required to be answered by some layer below.
- Overrides:
requiredDownServices
in class Protocol
- Following copied from class:
org.javagroups.stack.Protocol
- Returns:
- Vector (of Integers)
setImpl
public void setImpl(GmsImpl new_impl)
becomeCoordinator
public void becomeCoordinator()
becomeParticipant
public void becomeParticipant()
becomeClient
public void becomeClient()
getNextView
public 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.
flush
public void flush(java.util.Vector flush_dest,
java.util.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
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. 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)
-
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.
-
The new view to be installed includes the existing members plus the joining ones and
excludes the leaving and suspected members.
-
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).
installView
public void installView(ViewId new_view,
java.util.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.
determineCoordinator
protected Address determineCoordinator()
checkSelfInclusion
protected boolean checkSelfInclusion(java.util.Vector mbrs)
- Returns true if local_addr is member of mbrs, else false
makeView
public View makeView(java.util.Vector mbrs)
makeView
public View makeView(java.util.Vector mbrs,
ViewId vid)
join
public void join(Address mbr)
leave
public void leave(Address mbr)
suspect
public void suspect(Address mbr)
merge
public void merge(java.util.Vector other_coords)
handleJoin
public boolean handleJoin(Address mbr)
handleLeave
public void handleLeave(Address mbr,
boolean suspected)
handleViewChange
public void handleViewChange(ViewId new_view,
java.util.Vector mbrs)
handleMerge
public View handleMerge(ViewId other_vid,
java.util.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 class RpcProtocol
- Returns:
- boolean Defaults to true. If false, event will not be passed up the stack.
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 class RpcProtocol
- Returns:
- boolean Defaults to true. If false, event will not be passed down the stack.
receiveDownEvent
public void receiveDownEvent(Event evt)
- Description copied from class:
Protocol
- Internal method, should not be called by clients. Used by ProtocolStack. I would have
used the 'friends' modifier, but this is available only in C++ ... If the down_handler thread
is not available (down_thread == false), then directly call the down() method: we will run on the
caller's thread (e.g. the protocol layer above us).
- Overrides:
receiveDownEvent
in class Protocol
setProperties
public boolean setProperties(java.util.Properties props)
- Setup the Protocol instance acording to the configuration string
- Overrides:
setProperties
in class Protocol
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.