groupmgmt
Class GroupManager

java.lang.Object
  |
  +--groupmgmt.GroupManager
All Implemented Interfaces:
java.util.EventListener, GroupChangedListener

public class GroupManager
extends java.lang.Object
implements GroupChangedListener

The Group Manager; Built for use in LIME 1.1; Maintains local information about the group that the current host is a part of (list of members).
Can be switched on and off by the controlling class.
Controls the MemberDetector - Detects new/stopping members & dropped connections.
and the GroupDisseminator - Effects changes in the group based on data from the Detector.

Version:
July 2003
Author:
Christine Julien, Tom Elgin

Constructor Summary
GroupManager(int groupmgmtPort, MemberDetector detector, GroupDisseminator disseminator, boolean sendSelfEngagement)
          Constructor, initializes the GroupManager with the provided MemberDetector and GroupDisseminator.
 
Method Summary
 void addGroupChangedListener(GroupChangedListener listener)
          Registers a GroupChangedListener to receive all GroupChangedEvents generated by this GroupDisseminator.
 void connect()
          Turn the GroupManager on.
 void disconnect()
          Turn the GroupManager off.
 MemberDetector getDetector()
          Accessor to get the MemberDetector.
 GroupDisseminator getDisseminator()
          Accessor to get the GroupDisseminator.
static Member getMember()
          Static accessor for Detectors/Disseminators to get a Member object representing this group member.
 void groupChanged(GroupChangedEvent event)
          Method required by the GroupChangedListener interface.
static void main(java.lang.String[] args)
          ## Main method just for testing on the command-line.
static void print(java.lang.String msg)
          Static utility method to log output from any groupmgmt class.
 void removeGroupChangedListener(GroupChangedListener listener)
          Unregisters a GroupChangedListener, stops sending GroupChangedEvents to the listener.
 void resumeUpdates()
          Resume sending GroupChangedEvents to the listeners.
 void setDebug(boolean debugging)
          Determine whether to output logging messages.
 boolean setDetector(MemberDetector newDetector)
          Change the MemberDetector.
 boolean setDisseminator(GroupDisseminator newDisseminator)
          Change the GroupDisseminator and tell the MemberDetector.
 void suppressUpdates()
          Allows the calling class to tell us to temporarily stop sending GroupChangedEvents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupManager

public GroupManager(int groupmgmtPort,
                    MemberDetector detector,
                    GroupDisseminator disseminator,
                    boolean sendSelfEngagement)
Constructor, initializes the GroupManager with the provided MemberDetector and GroupDisseminator.
Parameters:
groupmgmtPort - The port to use to identify this group member.
detector - The MemberDetector to use.
disseminator - The GroupDisseminator to use.
sendSelfEngagement - Whether to fire a GroupChangedEvent when the Member engages with itself.
Method Detail

setDebug

public void setDebug(boolean debugging)
Determine whether to output logging messages. Doesn't do anything in GroupManager because it never needed debug messages.
Parameters:
debugging - Outputs messages if true.

connect

public void connect()
Turn the GroupManager on. Start both the MemberDetector and the GroupDisseminator.

disconnect

public void disconnect()
Turn the GroupManager off. Stop both the MemberDetector and the GroupDisseminator.

suppressUpdates

public void suppressUpdates()
Allows the calling class to tell us to temporarily stop sending GroupChangedEvents. Note that this suppresses events to ALL listeners, not just one.

resumeUpdates

public void resumeUpdates()
Resume sending GroupChangedEvents to the listeners. If any updates were suppressed, the most recent GroupChangedEvent is immediately fired.

getMember

public static Member getMember()
Static accessor for Detectors/Disseminators to get a Member object representing this group member.
Returns:
This group member.

getDetector

public MemberDetector getDetector()
Accessor to get the MemberDetector.
Returns:
The MemberDetector currently being used.

setDetector

public boolean setDetector(MemberDetector newDetector)
Change the MemberDetector. Only works if inactive.
Parameters:
The - new MemberDetector to use.
Returns:
True if the MemberDetector was successfully changed.

getDisseminator

public GroupDisseminator getDisseminator()
Accessor to get the GroupDisseminator.
Returns:
The GroupDisseminator currently being used.

setDisseminator

public boolean setDisseminator(GroupDisseminator newDisseminator)
Change the GroupDisseminator and tell the MemberDetector. Only works if both are inactive.
Parameters:
The - new GroupDisseminator to use.
Returns:
True if the MemberDetector was successfully changed.

groupChanged

public void groupChanged(GroupChangedEvent event)
Method required by the GroupChangedListener interface. Called whenever the Group I'm in has changed and tells me the new group configuration(s). If the new group I'm in differs from the members list (it might not), then update the members list and inform my listeners via a GroupChangedEvent.
Specified by:
groupChanged in interface GroupChangedListener

addGroupChangedListener

public void addGroupChangedListener(GroupChangedListener listener)
Registers a GroupChangedListener to receive all GroupChangedEvents generated by this GroupDisseminator.
Parameters:
listener - The GroupChangedListener to receive events.

removeGroupChangedListener

public void removeGroupChangedListener(GroupChangedListener listener)
Unregisters a GroupChangedListener, stops sending GroupChangedEvents to the listener.
Parameters:
listener - The GroupChangedListener to stop receiving events.

print

public static void print(java.lang.String msg)
Static utility method to log output from any groupmgmt class. Calls System.out.println with "groupmgmt:" followed by the message.
Parameters:
msg - The message to display.

main

public static void main(java.lang.String[] args)
## Main method just for testing on the command-line.