Package org.jgroups.protocols.pbcast
Class GMS
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.pbcast.GMS
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
- Version:
- $Id: GMS.java,v 1.126.2.20.2.3 2009/04/22 06:57:51 belaban Exp $
- Author:
- Bela Ban
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected int
Max number of old members to keep in history -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
castViewChangeWithDest
(View new_view, Digest digest, JoinRsp jr, Collection<Address> newMembers) Broadcasts the new view and digest, and waits for acks from all members in the list given as argument.protected boolean
checkSelfInclusion
(Vector<Address> mbrs) Returns true if local_addr is member of mbrs, else falseprotected Address
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.Sends down a GET_DIGEST event and waits for the GET_DIGEST_OK response, or timeout, whichever occurs firstgetImpl()
long
Deprecated.long
long
getName()
getNextView
(Collection<Address> new_mbrs, Collection<Address> old_mbrs, Collection<Address> suspected_mbrs) Computes the next view.int
int
getView()
long
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
boolean
boolean
isShun()
boolean
boolean
static View
void
Send down a MERGE_DIGEST eventList of events that are required to be answered by some layer below.void
void
void
sendJoinResponse
(JoinRsp rsp, Address dest) void
Send down a SET_DIGEST eventvoid
void
setJoinRetryTimeout
(long t) Deprecated.void
setJoinTimeout
(long t) void
setMaxBundlingTime
(long max_bundling_time) void
setPrintLocalAddr
(boolean print_local_addr) boolean
setProperties
(Properties props) Setup the Protocol instance according to the configuration stringvoid
setShun
(boolean s) void
setViewAckCollectionTimeout
(long view_ack_collection_timeout) void
setViewBundling
(boolean view_bundling) void
start()
This method is called on aChannel.connect(String)
.void
stop()
This method is called on aChannel.disconnect()
.void
An event was received from the layer below.int
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, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getProperties, getProtocolStack, getThreadFactory, getTransport, getUpProtocol, printStats, providedDownServices, providedUpServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
-
Field Details
-
num_prev_mbrs
protected int num_prev_mbrsMax number of old members to keep in history -
name
- See Also:
-
-
Constructor Details
-
GMS
public GMS()
-
-
Method Details
-
getName
-
getView
-
getNumberOfViews
public int getNumberOfViews() -
getLocalAddress
-
getMembers
-
getNumMembers
public int getNumMembers() -
getJoinTimeout
public long getJoinTimeout() -
setJoinTimeout
public void setJoinTimeout(long t) -
getJoinRetryTimeout
public long getJoinRetryTimeout()Deprecated. -
setJoinRetryTimeout
public void setJoinRetryTimeout(long t) Deprecated. -
isShun
public boolean isShun() -
setShun
public void setShun(boolean s) -
isPrintLocalAddr
public boolean isPrintLocalAddr() -
setPrintLocalAddr
public void setPrintLocalAddr(boolean print_local_addr) -
printPreviousMembers
-
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) -
viewHandlerSize
public int viewHandlerSize() -
isViewHandlerSuspended
public boolean isViewHandlerSuspended() -
dumpViewHandlerQueue
-
dumpViewHandlerHistory
-
suspendViewHandler
public void suspendViewHandler() -
resumeViewHandler
public void resumeViewHandler() -
printPreviousViews
-
isCoordinator
public boolean isCoordinator() -
resetStats
public void resetStats()- Overrides:
resetStats
in classProtocol
-
requiredDownServices
Description copied from class:Protocol
List of events that are required to be answered by some layer below.- Overrides:
requiredDownServices
in classProtocol
- Returns:
- Vector (of Integers)
-
setImpl
-
getImpl
-
init
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. -
start
Description copied from class:Protocol
This method is called on aChannel.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 classProtocol
- Throws:
Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soChannel.connect(String)
will throw an exception
-
stop
public void stop()Description copied from class:Protocol
This method is called on aChannel.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 -
becomeCoordinator
public void becomeCoordinator() -
becomeParticipant
public void becomeParticipant() -
becomeClient
public void becomeClient() -
getNextView
public View getNextView(Collection<Address> new_mbrs, Collection<Address> old_mbrs, Collection<Address> suspected_mbrs) Computes the next view. Returns a copy that hasold_mbrs
andsuspected_mbrs
removed andnew_mbrs
added. -
castViewChangeWithDest
public void castViewChangeWithDest(View new_view, Digest digest, JoinRsp jr, 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- Parameters:
new_view
-digest
-newMembers
-
-
sendJoinResponse
-
installView
-
installView
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
-
wouldBeNewCoordinator
Checks whether the potential_new_coord would be the new coordinator (2nd in line) -
checkSelfInclusion
Returns true if local_addr is member of mbrs, else false -
makeView
-
makeView
-
setDigest
Send down a SET_DIGEST event -
mergeDigest
Send down a MERGE_DIGEST event -
getDigest
Sends down a GET_DIGEST event and waits for the GET_DIGEST_OK response, or timeout, whichever occurs first -
up
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 usingdown_prot.down()
or c) the event (or another event) is sent up the stack usingup_prot.up()
. -
down
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.
-
setProperties
Setup the Protocol instance according to the configuration string- Overrides:
setProperties
in classProtocol
-