Kea  2.3.5-git
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. More...
 
virtual ~DProcessBase ()
 Destructor. More...
 
virtual isc::data::ConstElementPtr configure (isc::data::ConstElementPtr config_set, bool check_only=false)=0
 Processes the given configuration. More...
 
const std::string getAppName () const
 Fetches the application name. More...
 
DCfgMgrBasePtrgetCfgMgr ()
 Fetches the process's configuration manager. More...
 
asiolink::IOServicePtrgetIoService ()
 Fetches the controller's IOService. More...
 
virtual void init ()=0
 May be used after instantiation to perform initialization unique to application. More...
 
virtual void run ()=0
 Implements the process's event loop. More...
 
void setShutdownFlag (bool value)
 Sets the process shut down flag to the given value. More...
 
bool shouldShutdown () const
 Checks if the process has been instructed to shut down. More...
 
virtual isc::data::ConstElementPtr shutdown (isc::data::ConstElementPtr args)=0
 Initiates the process's shutdown process. More...
 
void stopIOService ()
 Convenience method for stopping IOservice processing. More...
 

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 81 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 93 of file d_process.h.

References isc_throw.

◆ ~DProcessBase()

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

Destructor.

Definition at line 154 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::d2::D2Process, isc::agent::CtrlAgentProcess, 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 173 of file d_process.h.

◆ getCfgMgr()

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

◆ getIoService()

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

◆ 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::d2::D2Process, isc::agent::CtrlAgentProcess, 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::d2::D2Process, isc::agent::CtrlAgentProcess, 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 166 of file d_process.h.

Referenced by isc::netconf::NetconfProcess::shutdown(), isc::agent::CtrlAgentProcess::shutdown(), and isc::d2::D2Process::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 159 of file d_process.h.

Referenced by isc::d2::D2Process::canShutdown(), isc::d2::D2Process::checkQueueStatus(), isc::netconf::NetconfProcess::run(), and isc::agent::CtrlAgentProcess::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::d2::D2Process, isc::agent::CtrlAgentProcess, 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 188 of file d_process.h.

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


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