|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroupmgmt.MemberDetector
groupmgmt.impl.SafeDistanceDetector
The SafeDistanceDetector class; Detects members based on beacons, using a BeaconServer. If a new beacon is received, we check the distance, and if it is within a safe range, reportChange is called and it passes the change on to the Disseminator. If a beacon is received with 'stopping' set or if a beacon moves beyond the safe distance, then reportChange is called to remove the member. This class is also in charge of multicasting beacons to its neighbors.
Everything here is done locally, there is no need for a MemberDetector leader because all Members act the same. (It would be possible to implement a less chatty [fewer beacons] and thus more scalable model by designating a MemberDetector leader.)
Uses: MemberBeacon, BeaconEvent, BeaconListener, BeaconServer. also uses Location and LocationGenerator from the location package.
Field Summary | |
private BeaconServer |
beaconServer
The BeaconServer for this host. |
private boolean |
debugging
Determines whether to output log messages. |
private Location |
location
The physical location of this Member. |
private LocationGenerator |
locationGenerator
The LocationGenerator - the object that updates our location (via LocationChangedEvents). |
private java.util.Hashtable |
neighborBeacons
The neighbors table. |
private double |
safeDistance
The safe distance for this host, calculated based on the provided input parameters. |
private java.lang.Boolean |
stopping
Object to use for waiting to exit the Group after I set my beacon to stopping. |
Fields inherited from class groupmgmt.MemberDetector |
disseminator |
Constructor Summary | |
SafeDistanceDetector(int beaconPort,
java.lang.String beaconAddress,
int beaconPeriod,
double range,
double maxSpeed,
double networkLatency,
LocationGenerator locationGenerator)
Constructor. |
Method Summary | |
void |
groupChanged(GroupChangedEvent evt)
Implements the GroupChangedListener interface. |
void |
locationChanged(LocationEvent event)
Implements the LocationListener interface. |
private void |
log(java.lang.String msg)
For testing. |
void |
newMemberBeacon(BeaconEvent memberBeaconEvent)
Implements the BeaconListener interface. |
private void |
reportArriving(Member member)
Private utility method to report an arriving Member to the Disseminator. |
private void |
reportDeparting(Member member)
Private utility method to report a departing Member to the Disseminator. |
void |
setDebug(boolean debugging)
Determine whether to output logging messages. |
protected void |
start()
Begin looking for changes in the group (hosts to engage/disengage with) and start sending beacons. |
protected void |
stop()
Stop reporting changes in the group, stop looking for beacons, and stop sending beacons. |
Methods inherited from class groupmgmt.MemberDetector |
isActive, reportChange |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private BeaconServer beaconServer
private java.util.Hashtable neighborBeacons
private Location location
private LocationGenerator locationGenerator
private double safeDistance
private java.lang.Boolean stopping
private boolean debugging
Constructor Detail |
public SafeDistanceDetector(int beaconPort, java.lang.String beaconAddress, int beaconPeriod, double range, double maxSpeed, double networkLatency, LocationGenerator locationGenerator)
beaconPort
- The port to multicast beacons to.beaconAddress
- The multicast address to send beacons to.beaconPeriod
- How often to send beacons (milliseconds).range
- The transmission range of the network (meters).maxSpeed
- The maximum speed of the host (meters/second).networkLatency
- Lag in the network (milliseconds).locationGenerator
- Where to receive locationChanged events from.Method Detail |
public void setDebug(boolean debugging)
debugging
- Outputs messages if true.protected void start()
start
in class MemberDetector
protected void stop()
stop
in class MemberDetector
public void locationChanged(LocationEvent event)
locationChanged
in interface LocationListener
event
- The LocationEvent containing the new Location.public void groupChanged(GroupChangedEvent evt)
groupChanged
in interface GroupChangedListener
evt
- The GroupChangedEvent.public void newMemberBeacon(BeaconEvent memberBeaconEvent)
newMemberBeacon
in interface BeaconListener
memberBeaconEvent
- The event generated by the receipt of the
new beacon.private void reportArriving(Member member)
member
- The member that's arriving.private void reportDeparting(Member member)
member
- The member that's departing.private void log(java.lang.String msg)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |