Kea 2.5.8
isc::process::DProcessBase Class Referenceabstract

Application Process Interface. More...

#include <d_process.h>

+ Inheritance diagram for isc::process::DProcessBase:

Public Member Functions

 DProcessBase (const char *app_name, asiolink::IOServicePtr io_service, DCfgMgrBasePtr cfg_mgr)
 Constructor.
 
virtual ~DProcessBase ()
 Destructor.
 
virtual isc::data::ConstElementPtr configure (isc::data::ConstElementPtr config_set, bool check_only=false)=0
 Processes the given configuration.
 
const std::string getAppName () const
 Fetches the application name.
 
DCfgMgrBasePtrgetCfgMgr ()
 Fetches the process's configuration manager.
 
asiolink::IOServicePtrgetIOService ()
 Fetches the controller's IOService.
 
virtual void init ()=0
 May be used after instantiation to perform initialization unique to application.
 
virtual void run ()=0
 Implements the process's event loop.
 
void setShutdownFlag (bool value)
 Sets the process shut down flag to the given value.
 
bool shouldShutdown () const
 Checks if the process has been instructed to shut down.
 
virtual isc::data::ConstElementPtr shutdown (isc::data::ConstElementPtr args)=0
 Initiates the process's shutdown process.
 
void stopIOService ()
 Convenience method for stopping IOservice processing.
 

Detailed Description

Application Process Interface.

DProcessBase is an abstract class represents the primary "application" level object in a "managed" asynchronous application. It provides a uniform interface such that a managing layer can construct, initialize, and start the application's event loop. The event processing is centered around the use of isc::asiolink::io_service. The io_service is shared between the managing layer and the DProcessBase. This allows management layer IO such as directives to be sensed and handled, as well as processing IO activity specific to the application. In terms of management layer IO, there are methods shutdown, configuration updates, and commands unique to the application.

Definition at line 75 of file d_process.h.

Constructor & Destructor Documentation

◆ DProcessBase()

isc::process::DProcessBase::DProcessBase ( const char *  app_name,
asiolink::IOServicePtr  io_service,
DCfgMgrBasePtr  cfg_mgr 
)
inline

Constructor.

Parameters
app_nameis a text label for the process. Generally used in log statements, but otherwise arbitrary.
io_serviceis the io_service used by the caller for asynchronous event handling.
cfg_mgrthe configuration manager instance that handles configuration parsing.
Exceptions
DProcessBaseErroris io_service is NULL.

Definition at line 87 of file d_process.h.

References isc_throw.

◆ ~DProcessBase()

virtual isc::process::DProcessBase::~DProcessBase ( )
inlinevirtual

Destructor.

Definition at line 148 of file d_process.h.

Member Function Documentation

◆ configure()

virtual isc::data::ConstElementPtr isc::process::DProcessBase::configure ( isc::data::ConstElementPtr  config_set,
bool  check_only = false 
)
pure virtual

Processes the given configuration.

This method may be called multiple times during the process lifetime. Certainly once during process startup, and possibly later if the user alters configuration. This method must not throw, it should catch any processing errors and return a success or failure answer as described below. On success the last commit timestamp must be updated.

Parameters
config_seta new configuration (JSON) for the process
check_onlytrue if configuration is to be verified only, not applied
Returns
an Element that contains the results of configuration composed of an integer status value (0 means successful, non-zero means failure), and a string explanation of the outcome.

Implemented in isc::agent::CtrlAgentProcess, isc::d2::D2Process, and isc::netconf::NetconfProcess.

◆ getAppName()

const std::string isc::process::DProcessBase::getAppName ( ) const
inline

Fetches the application name.

Returns
application name string.

Definition at line 169 of file d_process.h.

◆ getCfgMgr()

DCfgMgrBasePtr & isc::process::DProcessBase::getCfgMgr ( )
inline

◆ getIOService()

asiolink::IOServicePtr & isc::process::DProcessBase::getIOService ( )
inline

Fetches the controller's IOService.

Returns
a reference to the controller's IOService.

Definition at line 176 of file d_process.h.

Referenced by isc::d2::D2Process::D2Process(), isc::d2::D2Process::~D2Process(), isc::agent::CtrlAgentProcess::configure(), isc::d2::D2Process::configure(), isc::d2::D2Process::init(), and isc::d2::D2Process::runIO().

◆ init()

virtual void isc::process::DProcessBase::init ( )
pure virtual

May be used after instantiation to perform initialization unique to application.

It must be invoked prior to invoking run. This would likely include the creation of additional IO sources and their integration into the io_service.

Exceptions
DProcessBaseErrorif the initialization fails.

Implemented in isc::agent::CtrlAgentProcess, isc::d2::D2Process, and isc::netconf::NetconfProcess.

◆ run()

virtual void isc::process::DProcessBase::run ( )
pure virtual

Implements the process's event loop.

In its simplest form it would an invocation io_service_->run(). This method should not exit until the process itself is exiting due to a request to shutdown or some anomaly is forcing an exit.

Exceptions
DProcessBaseErrorif an operational error is encountered.

Implemented in isc::agent::CtrlAgentProcess, isc::d2::D2Process, and isc::netconf::NetconfProcess.

◆ setShutdownFlag()

void isc::process::DProcessBase::setShutdownFlag ( bool  value)
inline

Sets the process shut down flag to the given value.

Parameters
valueis the new value to assign the flag.

Definition at line 162 of file d_process.h.

Referenced by isc::agent::CtrlAgentProcess::shutdown(), isc::d2::D2Process::shutdown(), and isc::netconf::NetconfProcess::shutdown().

◆ shouldShutdown()

bool isc::process::DProcessBase::shouldShutdown ( ) const
inline

Checks if the process has been instructed to shut down.

Returns
true if process shutdown flag is true.

Definition at line 155 of file d_process.h.

Referenced by isc::d2::D2Process::canShutdown(), isc::d2::D2Process::checkQueueStatus(), isc::agent::CtrlAgentProcess::run(), and isc::netconf::NetconfProcess::run().

◆ shutdown()

virtual isc::data::ConstElementPtr isc::process::DProcessBase::shutdown ( isc::data::ConstElementPtr  args)
pure virtual

Initiates the process's shutdown process.

This is last step in the shutdown event callback chain, that is intended to notify the process it is to begin its shutdown process.

Parameters
argsan Element set of shutdown arguments (if any) that are supported by the process derivation.
Returns
an Element that contains the results of argument processing, consisting of an integer status value (0 means successful, non-zero means failure), and a string explanation of the outcome.
Exceptions
DProcessBaseErrorif an operational error is encountered.

Implemented in isc::agent::CtrlAgentProcess, isc::d2::D2Process, and isc::netconf::NetconfProcess.

◆ stopIOService()

void isc::process::DProcessBase::stopIOService ( )
inline

Convenience method for stopping IOservice processing.

Invoking this will cause the process to exit any blocking IOService method such as run(). No further IO events will be processed.

Definition at line 184 of file d_process.h.

Referenced by isc::agent::CtrlAgentProcess::run(), and isc::netconf::NetconfProcess::run().


The documentation for this class was generated from the following file: