|
xorp
|
Base class for Services. More...
#include <service.hh>
Public Member Functions | |
| ServiceBase (const string &name="Unknown") | |
| virtual int | startup ()=0 |
| Start service. | |
| virtual int | shutdown ()=0 |
| Shutdown service. | |
| virtual int | reset () |
| Reset service. | |
| virtual int | pause () |
| Pause service. | |
| virtual int | resume () |
| Resume paused service. | |
| const string & | service_name () const |
| Get name of service. | |
| ServiceStatus | status () const |
| Get the current status. | |
| const string & | status_note () const |
| Get annotation associated with current status. | |
| const char * | status_name () const |
| Get a character representation of the current service status. | |
| int | set_observer (ServiceChangeObserverBase *so) |
| Set service status change observer. | |
| int | unset_observer (ServiceChangeObserverBase *so) |
| Remove service status change observer. | |
Protected Member Functions | |
| void | set_status (ServiceStatus status, const string ¬e) |
| Set current status. | |
| void | set_status (ServiceStatus status) |
| Set current status and clear status note. | |
Protected Attributes | |
| string | _name |
| ServiceStatus | _status |
| string | _note |
| ServiceChangeObserverBase * | _observer |
Base class for Services.
This class provides a base for services within Xorp processes. A service instance is an entity that can logically started and stopped and typically needs some asynchronous processing in order to start and stop. An example service within a routing process would be a RIB communicator service, which needs to co-ordinate with the RIB which is within a different process and may be on a different machine.
A service may be started and shutdown by calling startup() and shutdown(). The status of a service may be determined by calling status(). Additional notes on the current status may be obtained by calling status_note().
Synchronous service status changes may be received through the ServiceChangeObserverBase class. Instances of objects derived from this class can register for status change notifications in a Service instance by calling set_observer().
| int ServiceBase::pause | ( | ) | [virtual] |
Pause service.
Service should transition from SERVICE_RUNNING to SERVICE_PAUSING and asynchronously into SERVICE_PAUSED.
The default implementation always returns false as there is no default behaviour.
| int ServiceBase::reset | ( | ) | [virtual] |
Reset service.
Service should transition in SERVICE_READY from whichever state it is in.
The default implementation always returns false as there is no default behaviour.
Reimplemented in ProtoState.
| int ServiceBase::resume | ( | ) | [virtual] |
Resume paused service.
Service should transition from SERVICE_PAUSED to SERVICE_PAUSING and asynchronously into SERVICE_RUNNING.
The default implementation always returns false as there is no default behaviour.
| const string& ServiceBase::service_name | ( | ) | const [inline] |
Get name of service.
| int ServiceBase::set_observer | ( | ServiceChangeObserverBase * | so | ) |
Set service status change observer.
The observer will receive synchronous notifications of changes in service state.
| so | service change observer to add. |
| void ServiceBase::set_status | ( | ServiceStatus | status | ) | [protected] |
Set current status and clear status note.
| status | new status. |
| void ServiceBase::set_status | ( | ServiceStatus | status, |
| const string & | note | ||
| ) | [protected] |
Set current status.
| status | new status. |
| note | comment on new service status. |
| virtual int ServiceBase::shutdown | ( | ) | [pure virtual] |
Shutdown service.
Service should transition from SERVICE_RUNNING to SERVICE_SHUTTING_DOWN immediately and onto SERVICE_SHUTDOWN or SERVICE_FAILED in the near future.
Implemented in BGPMain, XrlMld6igmpNode, DebugIO< A >, XrlIO< A >, XrlPort, InterfaceMonitor, XrlMfeaNode, Fib2mribNode, XrlFib2mribNode, IfMgrXrlMirror, ProtoState, TestService, XrlMld6igmpNode, AreaRouter< A >, DebugIO< A >, XrlIO< A >, XrlPimNode, ShowDistancesProcessor, ShowRoutesProcessor, XrlJobQueue, XrlPortIO< A >, XrlPortManager< A >, XrlProcessSpy, XrlRedistManager< A >, XrlRibNotifier< A >, StaticRoutesNode, XrlStaticRoutesNode, XrlIO< IPv4 >, XrlIO< IPv4 >, XrlPortManager< IPv6 >, XrlPortManager< IPv4 >, XrlRedistManager< IPv6 >, and XrlRedistManager< IPv4 >.
| virtual int ServiceBase::startup | ( | ) | [pure virtual] |
Start service.
Service should transition from SERVICE_READY to SERVICE_STARTING immediately and onto SERVICE_RUNNING or SERVICE_FAILED in the near future.
Implemented in BGPMain, XrlMld6igmpNode, DebugIO< A >, XrlIO< A >, XrlPort, InterfaceMonitor, XrlMfeaNode, Fib2mribNode, XrlFib2mribNode, IfMgrXrlMirror, ProtoState, TestService, XrlMld6igmpNode, AreaRouter< A >, DebugIO< A >, XrlIO< A >, XrlPimNode, ShowDistancesProcessor, ShowRoutesProcessor, XrlJobQueue, XrlPortIO< A >, XrlPortManager< A >, XrlProcessSpy, XrlRedistManager< A >, XrlRibNotifier< A >, StaticRoutesNode, XrlStaticRoutesNode, XrlIO< IPv4 >, XrlIO< IPv4 >, XrlPortManager< IPv6 >, XrlPortManager< IPv4 >, XrlRedistManager< IPv6 >, and XrlRedistManager< IPv4 >.
| const string& ServiceBase::status_note | ( | ) | const [inline] |
Get annotation associated with current status.
The annotation when set is an explanation of the state, ie "waiting for Y"
| int ServiceBase::unset_observer | ( | ServiceChangeObserverBase * | so | ) |
Remove service status change observer.
| so | observer to remove. |