public interface Dispatcher
Dispatcher is created by CCS MessagingLayer. A single Dispatcher
handles all three buses.
MessagingLayer submits executable tasks (incoming message processing or disconnection notifications) through
the in(...) method. CCS framework submits message sending tasks through the out(...) method.
Dispatcher also provides API for the messaging system to send events (statistics, alerts, etc.)
to other CCS components. Various CCS components can retrieve information about the messaging system
and its current state through Dispatcher.
All implementations should provide public constructor that takes String argument.
This is a way to supply configuration parameters through the protocol string passed to TransportManager.
The string should be in "key[=value]&...&key[=value]" format, where value may be a comma-separated array.
Prohibited characters: :?.
Implementations should be thread-safe, methods of this interface can be called on any thread.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Dispatcher.AlertEvent |
static class |
Dispatcher.Event
Event published by
Dispatcher. |
static interface |
Dispatcher.Listener
Interface to be implemented by classes that should be notified of
Dispatcher events. |
static class |
Dispatcher.Order
Enumeration of order of execution and capacity control policies.
|
static class |
Dispatcher.Stage
Enumeration of task execution stages for which statistical data can be reported.
|
static interface |
Dispatcher.Task
Instrumented
Runnable for submission to Dispatcher. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Dispatcher.Listener listener)
Registers a listener.
|
void |
fireEvent(Dispatcher.Event event)
Notifies listeners of the given event.
|
Logger |
getLogger()
Returns a logger to be used for Dispatcher related messages.
|
List<Alert> |
getRegisteredAlerts()
Returns the list of alerts registered with this
Dispatcher. |
void |
in(Runnable task,
Bus bus,
String... agents)
Submits a task to process an incoming message or disconnection notification.
|
void |
initialize()
Initializes this dispatcher.
|
void |
out(Runnable task,
Bus bus,
Dispatcher.Order order)
Submits a task to process an outgoing message.
|
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.
|
void initialize()
void shutdown()
MessagingLayer will not be closed until this method returns.void in(Runnable task, Bus bus, String... agents)
If one or more agent names are given, the task if guaranteed to be executed after any previously submitted
tasks for the same bus and agent. If no agents are specified, the task is independent of other tasks,
subject to capacity controls imposed by the implementation of this Dispatcher. If the agents
argument is null, the task is independent of other tasks, not subject to capacity controls.
Calling this method has no effect if this Dispatcher has not been initialized or it has been shut down. No exceptions are thrown in this case.
task - Task to be executed.bus - Bus (LOG, STATUS, or COMMAND).agents - Names of affected agents (source or disconnected).TransportStateException - If this Dispatcher is unable to accept the
request for reasons other than being uninitialized or shut down.void out(Runnable task, Bus bus, Dispatcher.Order order)
Tasks submitted with outOfBand equal to false for the same bus are guaranteed to be
processed in the order of submission. If outOfBand equals true, the task is executed
independently of others, subject to capacity controls imposed by the implementation of this service.
If outOfBand equals null, the task is independent, not subject to capacity controls.
task - Task to be executed.bus - Bus (LOG, STATUS, or COMMAND).order - Order of execution and capacity control policies.TransportStateException - If this Dispatcher is unable to accept the request.void addListener(Dispatcher.Listener listener)
listener - Listener to add.void removeListener(Dispatcher.Listener listener)
listener - Listener to remove.void fireEvent(Dispatcher.Event event)
Dispatcher.event - void raiseAlert(String id, AlertState severity, String cause)
AlertEvent.
If an alert with matching id has not been registered, nothing is published.id - Alert id.severity - Alert severity.cause - Message.void raiseAlert(Alert alert, AlertState severity, String cause)
AlertEvent.
An event is published even if an alert with matching id has not been registered.alert - Alert instance.severity - Alert severity.cause - Message.List<Alert> getRegisteredAlerts()
Dispatcher.void registerAlert(Alert alert)
alert - Alert to add.Logger getLogger()
Copyright © 2024 LSST. All rights reserved.