public abstract class AbstractDispatcher extends Object implements Dispatcher
Dispatcher.
Functionality provided by this class:
Dispatcher.Task that adds access to BusMessage and reference time, as well as
empty callback implementation.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractDispatcher.Task
Instrumented
Runnable for submission to Dispatcher. |
Dispatcher.AlertEvent, Dispatcher.Event, Dispatcher.Listener, Dispatcher.Order, Dispatcher.Stage| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Alert> |
alerts
Registered alerts.
|
protected HashMap<String,String> |
config
Configuration obtained from constructor argument string.
|
protected ScheduledExecutorService |
serviceExec
Executor for service tasks, including monitoring and listener notifications.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDispatcher(String args)
Constructs
Dispatcher instance in specified configuration. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Dispatcher.Listener listener)
Registers a listener.
|
protected void |
deliverEvent(Dispatcher.Event event) |
void |
fireEvent(Dispatcher.Event event)
Notifies listeners of the given event.
|
protected boolean |
getBooleanArg(String key)
Retrieves boolean configuration parameter value from the constructor argument.
|
protected int |
getIntArg(String key,
int defaultValue)
Retrieves integer configuration parameter value from the constructor argument.
|
protected int[] |
getIntArrayArg(String key,
int[] defaultValue)
Retrieves
int[] configuration parameter value from the constructor argument. |
protected int[] |
getIntArrayArg(String key,
int defaultValue,
int length)
Retrieves
int[] configuration parameter value from the constructor argument. |
Logger |
getLogger()
Returns a logger to be used for Dispatcher related messages.
|
List<Alert> |
getRegisteredAlerts()
Returns a set of alerts registered with this
Dispatcher. |
void |
initialize()
Initializes this dispatcher.
|
void |
raiseAlert(Alert alert,
AlertState severity,
String cause)
Notifies listeners by publishing an
AlertEvent. |
void |
raiseAlert(String id,
AlertState severity,
String cause)
Notifies listeners by publishing an
AlertEvent. |
void |
registerAlert(Alert alert)
Registers an alert with this Dispatcher.
|
void |
removeListener(Dispatcher.Listener listener)
Removes a listener.
|
void |
shutdown()
Orderly shuts down this dispatcher.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitin, outprotected HashMap<String,String> config
get...Arg(...) methods.protected final ScheduledExecutorService serviceExec
protected AbstractDispatcher(String args)
Dispatcher instance in specified configuration.args - Configuration string in key[=value]&...&key[=value] format.public void initialize()
initialize in interface Dispatcherpublic void shutdown()
shutdown in interface Dispatcherpublic void addListener(Dispatcher.Listener listener)
addListener in interface Dispatcherlistener - Listener to add.public void removeListener(Dispatcher.Listener listener)
removeListener in interface Dispatcherlistener - Listener to remove.public void fireEvent(Dispatcher.Event event)
Dispatcher.fireEvent in interface Dispatcherevent - protected void deliverEvent(Dispatcher.Event event)
public void raiseAlert(String id, AlertState severity, String cause)
AlertEvent.
If an alert with matching id has not been registered, nothing is published.raiseAlert in interface Dispatcherid - Alert id.severity - Alert severity.cause - Message.public void raiseAlert(Alert alert, AlertState severity, String cause)
AlertEvent.
An event is published even if an alert with matching id has not been registered.raiseAlert in interface Dispatcheralert - Alert instance.severity - Alert severity.cause - Message.public List<Alert> getRegisteredAlerts()
Dispatcher.getRegisteredAlerts in interface Dispatcherpublic void registerAlert(Alert alert)
registerAlert in interface Dispatcheralert - Alert to add.public Logger getLogger()
getLogger in interface Dispatcherprotected final int getIntArg(String key, int defaultValue)
key - Parameter key.defaultValue - Value to return if the argument strings do not provide value for the specified key.IllegalArgumentException - If the specified key exists but the corresponding value is not integer.protected final boolean getBooleanArg(String key)
key - Parameter key.protected final int[] getIntArrayArg(String key, int defaultValue, int length)
int[] configuration parameter value from the constructor argument.
If the configuration string passed to the constructor did not contain the specified key,
an array of the specified length with all elements equal to defaultValue is returned.
This method should only be called inside constructor.key - Parameter key.defaultValue - Default value for all array elements.length - Array length.IllegalArgumentException - If the given key exists but the corresponding value is not an integer array of the specified length.protected final int[] getIntArrayArg(String key, int[] defaultValue)
int[] configuration parameter value from the constructor argument.
If the configuration string passed to the constructor did not contain the specified key, defaultValue is returned.
This method should only be called inside constructor.key - Parameter key.defaultValue - Default value. If empty, no constraints on the length of the
array retrieved from the configuration string are enforced.IllegalArgumentException - If the given key exists but the corresponding value is
not an integer array of the same length as defaultValue.Copyright © 2024 LSST. All rights reserved.