Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jgroups.protocols.pbcast
Class ClientGmsImpl  view ClientGmsImpl download ClientGmsImpl.java

java.lang.Object
  extended byorg.jgroups.protocols.pbcast.GmsImpl
      extended byorg.jgroups.protocols.pbcast.ClientGmsImpl

public class ClientGmsImpl
extends GmsImpl

Client part of GMS. Whenever a new member wants to join a group, it starts in the CLIENT role. No multicasts to the group will be received and processed until the member has been joined and turned into a SERVER (either coordinator or participant, mostly just participant). This class only implements Join (called by clients who want to join a certain group, and ViewChange which is called by the coordinator that was contacted by this client, to tell the client what its initial membership is.

Version:
$Revision: 1.27 $

Field Summary
private  java.util.Vector initial_mbrs
           
private  boolean initial_mbrs_received
           
private  org.jgroups.util.Promise join_promise
           
 
Fields inherited from class org.jgroups.protocols.pbcast.GmsImpl
gms, leaving, log, trace, warn
 
Constructor Summary
ClientGmsImpl(GMS g)
           
 
Method Summary
(package private)  void becomeSingletonMember(org.jgroups.Address mbr)
           
private  org.jgroups.Address determineCoord(java.util.Vector mbrs)
          The coordinator is determined by a majority vote.
(package private)  void findInitialMembers()
          Pings initial members.
 void handleJoin(org.jgroups.Address mbr)
           
 void handleJoinResponse(JoinRsp join_rsp)
           
 void handleLeave(org.jgroups.Address mbr, boolean suspected)
          Returns false.
 void handleLeaveResponse()
           
 void handleSuspect(org.jgroups.Address mbr)
          Returns immediately.
 boolean handleUpEvent(org.jgroups.Event evt)
           
 void handleViewChange(org.jgroups.View new_view, Digest digest)
          Does nothing.
 void init()
           
private  boolean installView(org.jgroups.View new_view)
          Called by join().
 void join(org.jgroups.Address mbr)
          Joins this process to a group.
 void leave(org.jgroups.Address mbr)
           
(package private)  void sendJoinMessage(org.jgroups.Address coord, org.jgroups.Address mbr)
           
 void suspect(org.jgroups.Address mbr)
           
 void unsuspect(org.jgroups.Address mbr)
           
 
Methods inherited from class org.jgroups.protocols.pbcast.GmsImpl
handleDownEvent, handleExit, handleMergeCancelled, handleMergeRequest, handleMergeResponse, handleMergeView, iWouldBeCoordinator, merge, start, stop, wrongMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initial_mbrs

private final java.util.Vector initial_mbrs

initial_mbrs_received

private boolean initial_mbrs_received

join_promise

private final org.jgroups.util.Promise join_promise
Constructor Detail

ClientGmsImpl

public ClientGmsImpl(GMS g)
Method Detail

init

public void init()
          throws java.lang.Exception
Overrides:
init in class GmsImpl

join

public void join(org.jgroups.Address mbr)
Joins this process to a group. Determines the coordinator and sends a unicast handleJoin() message to it. The coordinator returns a JoinRsp and then broadcasts the new view, which contains a message digest and the current membership (including the joiner). The joiner is then supposed to install the new view and the digest and starts accepting mcast messages. Previous mcast messages were discarded (this is done in PBCAST).

If successful, impl is changed to an instance of ParticipantGmsImpl. Otherwise, we continue trying to send join() messages to the coordinator, until we succeed (or there is no member in the group. In this case, we create our own singleton group).

When GMS.disable_initial_coord is set to true, then we won't become coordinator on receiving an initial membership of 0, but instead will retry (forever) until we get an initial membership of > 0.

Specified by:
join in class GmsImpl

leave

public void leave(org.jgroups.Address mbr)
Specified by:
leave in class GmsImpl

handleJoinResponse

public void handleJoinResponse(JoinRsp join_rsp)
Specified by:
handleJoinResponse in class GmsImpl

handleLeaveResponse

public void handleLeaveResponse()
Specified by:
handleLeaveResponse in class GmsImpl

suspect

public void suspect(org.jgroups.Address mbr)
Specified by:
suspect in class GmsImpl

unsuspect

public void unsuspect(org.jgroups.Address mbr)
Specified by:
unsuspect in class GmsImpl

handleJoin

public void handleJoin(org.jgroups.Address mbr)
Specified by:
handleJoin in class GmsImpl

handleLeave

public void handleLeave(org.jgroups.Address mbr,
                        boolean suspected)
Returns false. Clients don't handle leave() requests

Specified by:
handleLeave in class GmsImpl

handleViewChange

public void handleViewChange(org.jgroups.View new_view,
                             Digest digest)
Does nothing. Discards all views while still client.

Specified by:
handleViewChange in class GmsImpl

installView

private boolean installView(org.jgroups.View new_view)
Called by join(). Installs the view returned by calling Coord.handleJoin() and becomes coordinator.


handleSuspect

public void handleSuspect(org.jgroups.Address mbr)
Returns immediately. Clients don't handle suspect() requests

Specified by:
handleSuspect in class GmsImpl

handleUpEvent

public boolean handleUpEvent(org.jgroups.Event evt)
Overrides:
handleUpEvent in class GmsImpl

sendJoinMessage

void sendJoinMessage(org.jgroups.Address coord,
                     org.jgroups.Address mbr)

findInitialMembers

void findInitialMembers()
Pings initial members. Removes self before returning vector of initial members. Uses IP multicast or gossiping, depending on parameters.


determineCoord

private org.jgroups.Address determineCoord(java.util.Vector mbrs)
The coordinator is determined by a majority vote. If there are an equal number of votes for more than 1 candidate, we determine the winner randomly.


becomeSingletonMember

void becomeSingletonMember(org.jgroups.Address mbr)