org.objectweb.tribe.gms
Class GroupMembershipService

java.lang.Object
  extended byorg.objectweb.tribe.gms.GroupMembershipService
All Implemented Interfaces:
DiscoveryListener, GroupMembershipListener
Direct Known Subclasses:
JGroupsMembershipService

public class GroupMembershipService
extends java.lang.Object
implements DiscoveryListener, GroupMembershipListener

This class defines a GroupMembershipService

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
static java.lang.String GMS_KEY
          Destination key for GMS messages
protected  java.util.HashMap groupMemberships
           
protected  java.util.ArrayList listeners
           
protected static Trace logger
           
 
Constructor Summary
GroupMembershipService(IpAddress replyAddress, AbstractChannelPool channelPool, DiscoveryService discovery)
          Creates a new GroupMembershipService object
 
Method Summary
 void discoveryRequest(GroupIdentifier gid, Address sender)
          Callback when a discovery request for the given group is received.
 void failedMember(Member failed, GroupIdentifier gid, Member sender)
          Callback when a group member is suspected of failure.
 Group getGroup(GroupIdentifier gid)
          Get the list of members in a group.
protected static Trace getLogger()
          Returns the logger value.
protected  ReceiveBuffer getReceiveBuffer()
          Returns the receiveBuffer value.
 void groupComposition(Group g, Address sender)
          Callback when a member sends its view of a group composition.
 Member join(ReliableGroupChannelWithGms channel, GroupIdentifier gid)
          Joins the group that has the given group identifier.
 void joinMember(Member m, GroupIdentifier gid)
          Callback when a new member joins a group.
 void quit(ReliableGroupChannelWithGms channel, GroupIdentifier gid)
          Leaves the group that has the given group identifier.
 void quitMember(Member m, GroupIdentifier gid)
          Callback when a member leaves a group (intentionally or not).
 void registerGroupMembershipListener(GroupMembershipListener listener)
          Register a new GroupMembershipListener.
 void stop()
          Stop this GMS service and its associated thread (note that the discovery service must be stopped separately).
 boolean unregisterGroupMembershipListener(GroupMembershipListener listener)
          Unregister a GroupMembershipListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GMS_KEY

public static java.lang.String GMS_KEY
Destination key for GMS messages


groupMemberships

protected java.util.HashMap groupMemberships

listeners

protected java.util.ArrayList listeners

logger

protected static Trace logger
Constructor Detail

GroupMembershipService

public GroupMembershipService(IpAddress replyAddress,
                              AbstractChannelPool channelPool,
                              DiscoveryService discovery)
                       throws ChannelException
Creates a new GroupMembershipService object

Parameters:
replyAddress - address to send replies to
channelPool - channel pool for group communications
discovery - the discovery service to use
Throws:
ChannelException - if no channel can be bound to the reply address
Method Detail

getReceiveBuffer

protected ReceiveBuffer getReceiveBuffer()
Returns the receiveBuffer value.

Returns:
Returns the receiveBuffer.

getLogger

protected static Trace getLogger()
Returns the logger value.

Returns:
Returns the logger.

join

public Member join(ReliableGroupChannelWithGms channel,
                   GroupIdentifier gid)
            throws AlreadyMemberException,
                   NotConnectedException,
                   ChannelException
Joins the group that has the given group identifier.

Parameters:
channel - client channel to join the group
gid - the identifier of the group to join
Returns:
the Member corresponding to the newly joining member
Throws:
AlreadyMemberException - if we are already member of the group
NotConnectedException - if the channel is not connected
ChannelException - if an error is reported by the channel

quit

public void quit(ReliableGroupChannelWithGms channel,
                 GroupIdentifier gid)
          throws ChannelException,
                 NotConnectedException
Leaves the group that has the given group identifier.

Parameters:
channel - client channel to leave the group
gid - the identifier of the group to quit
Throws:
ChannelException - if an error occurs
NotConnectedException - if m does not belong to this group

getGroup

public Group getGroup(GroupIdentifier gid)
Get the list of members in a group.

Parameters:
gid - the group identifier
Returns:
the Group corresponding to this gid or null if no such group is registered in the GMS.

registerGroupMembershipListener

public void registerGroupMembershipListener(GroupMembershipListener listener)
Register a new GroupMembershipListener.

Parameters:
listener - the listener to add

unregisterGroupMembershipListener

public boolean unregisterGroupMembershipListener(GroupMembershipListener listener)
Unregister a GroupMembershipListener.

Parameters:
listener - the listener to remove
Returns:
true if the listener was registered, false otherwise

discoveryRequest

public void discoveryRequest(GroupIdentifier gid,
                             Address sender)
Description copied from interface: DiscoveryListener
Callback when a discovery request for the given group is received.

Specified by:
discoveryRequest in interface DiscoveryListener
Parameters:
gid - group identifier requested
sender - sender of the request
See Also:
DiscoveryListener.discoveryRequest(org.objectweb.tribe.common.GroupIdentifier, org.objectweb.tribe.common.Address)

groupComposition

public void groupComposition(Group g,
                             Address sender)
Description copied from interface: GroupMembershipListener
Callback when a member sends its view of a group composition.

Specified by:
groupComposition in interface GroupMembershipListener
Parameters:
g - the group composition
sender - the member sending the group information
See Also:
GroupMembershipListener.groupComposition(Group, Address)

joinMember

public void joinMember(Member m,
                       GroupIdentifier gid)
Description copied from interface: GroupMembershipListener
Callback when a new member joins a group.

Specified by:
joinMember in interface GroupMembershipListener
Parameters:
m - the new member.
gid - the group identifier
See Also:
GroupMembershipListener.joinMember(org.objectweb.tribe.common.Member, org.objectweb.tribe.common.GroupIdentifier)

quitMember

public void quitMember(Member m,
                       GroupIdentifier gid)
Description copied from interface: GroupMembershipListener
Callback when a member leaves a group (intentionally or not).

Specified by:
quitMember in interface GroupMembershipListener
Parameters:
m - the member who left the group.
gid - the group identifier
See Also:
GroupMembershipListener.quitMember(org.objectweb.tribe.common.Member, org.objectweb.tribe.common.GroupIdentifier)

failedMember

public void failedMember(Member failed,
                         GroupIdentifier gid,
                         Member sender)
Description copied from interface: GroupMembershipListener
Callback when a group member is suspected of failure.

Specified by:
failedMember in interface GroupMembershipListener
Parameters:
failed - the member suspected of failure
gid - group identifier
sender - message sender (reporting the failure)
See Also:
GroupMembershipListener.failedMember(org.objectweb.tribe.common.Member, org.objectweb.tribe.common.GroupIdentifier, org.objectweb.tribe.common.Member)

stop

public void stop()
Stop this GMS service and its associated thread (note that the discovery service must be stopped separately).



Copyright © 2004 - ObjectWeb Consortium - All Rights Reserved.