groupmgmt
Class MemberDetector

java.lang.Object
  extended bygroupmgmt.MemberDetector
Direct Known Subclasses:
BeaconingDetector, SafeDistanceDetector

public abstract class MemberDetector
extends java.lang.Object

The MemberDetector abstract class; Detects members based on anything (most likely with a GroupBeaconListener) and some sort of filter (ie safe-distance calculations).

If the constructor is overridden it must call super(groupmgmtPort).
start() and stop() should be implemented.
When a change is detected, reportChange() should be called.

In the default implementation:
It multicasts periodic beacons to our neighbors for discovery.
It listens for the beacons and keeps a list of neighbors it has discovered.
It calls reportChange when new members are discovered and when a known member's beacon has 'stopping' set.
And in the safe-distance based module we also check the location info in the beacons for safe distance.

Version:
July 2003
Author:
Christine Julien, Tom Elgin

Field Summary
private  boolean active
          Is this MemberDetector active (detecting members and notifying the GroupDisseminator)?
protected  GroupDisseminator disseminator
          The GroupDisseminator to use to effect changes in the group.
 
Constructor Summary
MemberDetector()
          Constructor.
 
Method Summary
(package private)  void activate()
          The GroupManager calls this when we should activate the detector.
(package private)  void deactivate()
          The GroupManager calls this when we should deactivate the detector.
 boolean isActive()
          Check if this MemberDetector is active.
protected  boolean reportChange(Member[] arriving, Member[] departing)
          Called by the implementing class to process a change in this Member's connections.
(package private)  boolean setDisseminator(GroupDisseminator disseminator)
          Change the GroupDisseminator.
protected abstract  void start()
          Begin looking for changes in the group (hosts to engage/disengage with).
protected abstract  void stop()
          Stop reporting changes in the group (and presumably stop looking).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

disseminator

protected GroupDisseminator disseminator
The GroupDisseminator to use to effect changes in the group. Note that if we notify the disseminator of a local change in connectivity this does not necessarily mean the group will change.


active

private boolean active
Is this MemberDetector active (detecting members and notifying the GroupDisseminator)?

Constructor Detail

MemberDetector

public MemberDetector()
Constructor.

Method Detail

activate

void activate()
The GroupManager calls this when we should activate the detector. Don't override this method, use start().


deactivate

void deactivate()
The GroupManager calls this when we should deactivate the detector. Don't override this method, use stop().


start

protected abstract void start()
Begin looking for changes in the group (hosts to engage/disengage with). Notify the GroupDisseminator when you find one. This method is called after GroupManager.connect() is called.


stop

protected abstract void stop()
Stop reporting changes in the group (and presumably stop looking). This method is called after GroupManager.disconnect() is called.


isActive

public boolean isActive()
Check if this MemberDetector is active.

Returns:
Whether the MemberDetector is active or not.

setDisseminator

boolean setDisseminator(GroupDisseminator disseminator)
Change the GroupDisseminator. Cannot be done while active.

Returns:
Whether or not the GroupDisseminator was changed.

reportChange

protected boolean reportChange(Member[] arriving,
                               Member[] departing)
Called by the implementing class to process a change in this Member's connections. If this MemberDetector is active, it passes it on to the Disseminator and, if the Disseminator is also active, it returns true. Otherwise it returns false.

Parameters:
arriving - The arriving Member(s).
departing - The departing Member(s).
Returns:
Whether or not the change was reported to the GroupDisseminator.