stella
Class MasterErrorHandler

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiListener
                      extended by stella.AbstractErrorHandler
                          extended by stella.MasterErrorHandler
All Implemented Interfaces:
Cloneable, Remote, EventListener, ClusterDepending, ErrorHandling, ErrorListener, RmiErrorListener, RmiWeatherListener, WeatherListener, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiEventListener, RmiListener, RmiPropertyBearing

public class MasterErrorHandler
extends AbstractErrorHandler
implements WeatherListener, RmiWeatherListener, RmiErrorListener, Initializable

A collection of ErrorFinalizing objects. Incoming error messages are queried for their required follow-up action. A lookup table is then used to match the required follow-up action to an ErrorFinalizing object. The error is now passed to the ErrorFinalizing.finalizeError(stella.TargetDefinition, stella.ErrorEvent, stella.CommandLaunching[], stella.Sequencing, stella.ParameterClustering) method which should return fast and does all necessary steps to recover from the error. If recovery fails for any reason, i.e. if ErrorFinalizing.finalizeError(stella.TargetDefinition, stella.ErrorEvent, stella.CommandLaunching[], stella.Sequencing, stella.ParameterClustering) returns false, or if the error received cannot be matched to a finalizer, the fatalError(stella.ErrorEvent) method is called.

Additionally, errors related to Handable targets are treated. Whenever a TargetDefinition is started using the startTarget(stella.TargetDefinition) method, it is copied into the current list. PickConnected errors are then first assigned to the most currently started target. If this target has parents that are additionally in the current list, the error is propagated up until either no further parent is assigned to a target or if the parent in question is not in the current list. Targets may react to this errors with abort or retries, see e.g. DOMTarget.


Nested Class Summary
protected  class MasterErrorHandler.NoneErrorFinalizer
          A default finalizer class for ErrorEvent.NONE follow-ups.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  List<TargetDefinition> current
          A list of currently started targets for PickConnected errors.
private static String DEFPICKREPLACE
          Per default, we use a mail finalizer on pick-realated errors.
private  Map<String,ErrorFinalizing> handle
          A lookup table linking follow-ups to error handlers.
private  boolean ignore
          A boolean indicating that incoming error should be ignored.
static String KEY_HANDLERS
          The key to the coma-separated list of error finalizers.
static String KEY_PICKREPLACE
          Pick connected errors with NONE get a different error handler.
static String KEY_REMOTE
          The key to the remote error casters.
static String KEY_WEATHER
          The key to the remote weather caster.
private  Sequencing sequencer
          A link to the main sequencer.
private  CommandLaunching[] servers
          A link to the command servers.
private  ParameterClustering set
          A link to the main parameter set.
private  WeatherSurveying weather
          The local weather station if any.
 
Fields inherited from class util.rmi.AbstractRmiListener
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAY
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
MasterErrorHandler(Map<String,String> prop)
          Constructs a new simple error handler.
 
Method Summary
protected  boolean deregisterAtCaster(RmiCaster caster, Class service)
          Adds the ability to deregister at rmi-weather casters.
 boolean doAbort()
          Returns true if the error handler is dealing with a target abort.
 void endTarget(TargetDefinition end)
          Removes a target from the error-handlers current list.
 void errorOccured(ErrorEvent ee)
          The incomming errors.
 void exit()
          Signals that the error handler is shuting down and incoming errors should be ignored.
private  void fatalError(ErrorEvent ee)
          This error handler is invoked when everything else fails.
 void init()
          Registers at a remote weather caster to tranform bad weather events into BadWeather and GoodWeather errors.
private  void notifyTargets(ErrorEvent ee, ErrorFinalizing finish, ParameterClustering set)
          If a PickConnected error was registered, the list of currently active targets is traversed.
protected  boolean registerAtCaster(RmiCaster caster, Class service)
          Adds the ability to register at rmi-weather casters.
 void registerCluster(ParameterClustering cluster)
          Registers the parameter cluster.
 void registerLauncher(CommandLaunching[] device)
          Registers the command servers.
 void registerMonitor(Object sleeper)
          Registers the monitor.
 void registerSequencer(Sequencing seq)
          Registers the command sequencer.
 void registerWeather(WeatherSurveying fake)
          Registers a local weather station to the error handler.
 void rmiErrorOccured(ErrorEvent ee)
          This method is invoked by remote error casters.
 void rmiWeatherChanged(WeatherEvent we)
          Handles weather events.
 void setEnabled(boolean accept)
          Enables the error handler, meaning that incoming errors are no longer ignored.
 void startTarget(TargetDefinition start)
          Adds a target to the handler's current list.
 void weatherChanged(WeatherEvent we)
          Handles weather events.
 
Methods inherited from class stella.AbstractErrorHandler
createErrorHandler
 
Methods inherited from class util.rmi.AbstractRmiListener
allBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, rescanned, startBinding, startBinding
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.rmi.RmiEventListener
getListenerName
 
Methods inherited from interface util.rmi.RmiListener
disconnect, isConnected
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_HANDLERS

public static final String KEY_HANDLERS
The key to the coma-separated list of error finalizers.

See Also:
Constant Field Values

KEY_WEATHER

public static final String KEY_WEATHER
The key to the remote weather caster. Must be matched.

See Also:
Constant Field Values

KEY_REMOTE

public static final String KEY_REMOTE
The key to the remote error casters. Points to a comma-separated list.

See Also:
Constant Field Values

KEY_PICKREPLACE

public static final String KEY_PICKREPLACE
Pick connected errors with NONE get a different error handler.

See Also:
Constant Field Values

DEFPICKREPLACE

private static final String DEFPICKREPLACE
Per default, we use a mail finalizer on pick-realated errors.

See Also:
Constant Field Values

handle

private Map<String,ErrorFinalizing> handle
A lookup table linking follow-ups to error handlers.


servers

private CommandLaunching[] servers
A link to the command servers. They additionally act as error casters.


sequencer

private Sequencing sequencer
A link to the main sequencer.


set

private ParameterClustering set
A link to the main parameter set. Used with pipe-raised errors.


weather

private WeatherSurveying weather
The local weather station if any.


ignore

private boolean ignore
A boolean indicating that incoming error should be ignored.


current

private List<TargetDefinition> current
A list of currently started targets for PickConnected errors.

Constructor Detail

MasterErrorHandler

public MasterErrorHandler(Map<String,String> prop)
                   throws RemoteException
Constructs a new simple error handler. Registering the command servers, the sequencer, and the scheduler are done in the parent class.

Throws:
RemoteException
Method Detail

init

public void init()
Registers at a remote weather caster to tranform bad weather events into BadWeather and GoodWeather errors. Additionally registers at all remote error casters given with the KEY_REMOTE property. Scans the KEY_HANDLERS key to construct and load appropriate MasterErrorHandler.NoneErrorFinalizers for handling of incoming errors. If the ErrorEvent.NONE has no explicit handler specified, the MasterErrorHandler.NoneErrorFinalizer is used.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

setEnabled

public void setEnabled(boolean accept)
Enables the error handler, meaning that incoming errors are no longer ignored.

Specified by:
setEnabled in interface ErrorHandling

registerLauncher

public void registerLauncher(CommandLaunching[] device)
Registers the command servers. Additionally, this devices registers itself as an error listener to all command servers if they can be cast to error casters. Note that remote error caster registration is done at construct using the KEY_REMOTE.

Specified by:
registerLauncher in interface ErrorHandling

registerSequencer

public void registerSequencer(Sequencing seq)
Registers the command sequencer. In case of errors, the flow of command might change. This is directly reported to the sequencer instance.

Specified by:
registerSequencer in interface ErrorHandling

registerWeather

public void registerWeather(WeatherSurveying fake)
Registers a local weather station to the error handler. This it not identical to registering to a remote weather station using the KEY_WEATHER key. Local weather station may be present in case of simulated action only.

Specified by:
registerWeather in interface ErrorHandling

registerCluster

public void registerCluster(ParameterClustering cluster)
Registers the parameter cluster. Parameters that are error casting will be enlistened to the error handler.

Specified by:
registerCluster in interface ClusterDepending

registerMonitor

public void registerMonitor(Object sleeper)
Registers the monitor. In most cases this is the master mind who might be awaken by certain ErrorFinalizing instances. This method should only be called after all error finalizers have been initialized.

Specified by:
registerMonitor in interface ErrorHandling

startTarget

public void startTarget(TargetDefinition start)
Adds a target to the handler's current list. All targets stored there may receive PickConnected errors. If such an error is received, the most recently added targets receives it first.

Specified by:
startTarget in interface ErrorHandling

endTarget

public void endTarget(TargetDefinition end)
Removes a target from the error-handlers current list. Errors occuring later may not back-react on this target.

Specified by:
endTarget in interface ErrorHandling

doAbort

public boolean doAbort()
Returns true if the error handler is dealing with a target abort. This error is unique because it should also block sequence loading or target selection in the master mind.

Specified by:
doAbort in interface ErrorHandling

exit

public void exit()
Signals that the error handler is shuting down and incoming errors should be ignored. Additionally, we de-register from all error-casting parameters.

Specified by:
exit in interface ExitCleaning
Overrides:
exit in class AbstractRmiListener

rmiWeatherChanged

public void rmiWeatherChanged(WeatherEvent we)
                       throws RemoteException
Handles weather events. Initiates shutdown if weather is bad.

Specified by:
rmiWeatherChanged in interface RmiWeatherListener
Throws:
RemoteException

weatherChanged

public void weatherChanged(WeatherEvent we)
Handles weather events. Initiates shutdown if weather is bad.

Specified by:
weatherChanged in interface WeatherListener

rmiErrorOccured

public void rmiErrorOccured(ErrorEvent ee)
                     throws RemoteException
This method is invoked by remote error casters. It is re-directed to the local errorOccured(stella.ErrorEvent) method.

Specified by:
rmiErrorOccured in interface RmiErrorListener
Throws:
RemoteException

errorOccured

public void errorOccured(ErrorEvent ee)
The incomming errors. Errors are queried for theit follow-up and the appropriate ErrorFinalizing object is loaded and executed. If the error has a raised pipe-flag, it is passed to the parameter cluster registered to this error handler.

To judge fast return from this event-handling methods, consider:

Specified by:
errorOccured in interface ErrorListener

registerAtCaster

protected boolean registerAtCaster(RmiCaster caster,
                                   Class service)
Adds the ability to register at rmi-weather casters. If the argument handed over is not of the appropriate instance the superclass's registerAtCaster method is called.

Specified by:
registerAtCaster in class AbstractRmiListener
Returns:
True, if this listener can register at the specified caster

deregisterAtCaster

protected boolean deregisterAtCaster(RmiCaster caster,
                                     Class service)
Adds the ability to deregister at rmi-weather casters. If the argument handed over is not of the appropriate instance the superclass's deregisterAtCaster method is called.

Specified by:
deregisterAtCaster in class AbstractRmiListener
Returns:
True, if this listener can deregister at the specified caster

notifyTargets

private void notifyTargets(ErrorEvent ee,
                           ErrorFinalizing finish,
                           ParameterClustering set)
If a PickConnected error was registered, the list of currently active targets is traversed. Starting from the currently executing target (the last one added with startTarget(stella.TargetDefinition)), all precursors present in current are notified. The individual target getting notifies receives the error on its appropriate end. An error that occured in the currently observed target radiates to Handable.errorMain(stella.ErrorEvent, stella.ErrorFinalizing, stella.ParameterClustering), while precursors that have the currently queried target as successor or daughter are notified accordingly.


fatalError

private void fatalError(ErrorEvent ee)
This error handler is invoked when everything else fails. It does a shutdown on all instruments by casting the CommandLaunching.getShutdownCommand() to the peripherals.