org.portico.core
Class Reaper
java.lang.Object
org.portico.core.Reaper
public class Reaper
- extends Object
This class implements a kind of "Grim Reaper". The reaper can forcefully "harvet" a federate
and remove it from the federation, simulating a resign call so that the federation can happily
move on without being stalled by a federate that is no longer connected.
The reaper can kill a federate through the harvestSoul(RTIConnection)
method that works
on the connection associated with it.
The reaper used to be able to run in auto mode, although I have now removed that because the old
algorithm produced too many false positives. Now, the reaper only works on request.
Constructor Summary |
Reaper(RTIExec rti)
Creates a new reaper for the given RTI. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
execution
private RTIExec execution
logger
private org.apache.log4j.Logger logger
Reaper
public Reaper(RTIExec rti)
- Creates a new reaper for the given RTI. It will use the same logger as the RTI to inform
everyone of its activities.
doHarvest
private boolean doHarvest(Federate victim,
Federation federation)
- The given federate will be forcefully resigned from the given federation. This will also
result in the closing of the
RTIConnection
associated with the Federate
.
harvestSoul
public boolean harvestSoul(RTIConnection connection)
- This method will find the federate associated with the given
RTIConnection
. It will
look through each active federation in the RTIExec
associated with this reaper
instance and in each it will look through all active federates for the one that has the
given connection. It compares connection instances using ==
, so it is a straight
reference comparision rather than something more complex.
If an associated federation is found and successfully removed, true
is returned.
If the given connection is null, or the associated federate can't be found,
false
is returned. If there is a problem removing the federate once it has been
found, false
is returned.
- Parameters:
connection
- The connection to find the associated federate for (and remove from the
federation it is currently joined to
- Returns:
true
if the federate was found and successfully removed,
false
otherwise