Kea 3.1.1
isc::dhcp::LegalLogMgrFactory Class Reference

Backend Store Factory. More...

#include <legal_log_mgr_factory.h>

+ Inheritance diagram for isc::dhcp::LegalLogMgrFactory:

Static Public Member Functions

static void addBackend (db::DatabaseConnection::ParameterMap &parameters, ManagerID id=0)
 Create an instance of a forensic log backend.
 
static void delAllBackends ()
 Removes all backends from the pool.
 
static void delAllBackends (const std::string &db_type)
 Deletes all backends of the given type from the pool.
 
static bool delBackend (const std::string &db_type, db::DatabaseConnection::ParameterMap &parameters, bool if_unusable=false)
 Delete a forensic backend manager.
 
static bool delBackend (ManagerID id, bool if_unusable=false)
 Delete a forensic backend manager.
 
static std::list< std::string > getDBVersions ()
 Return extended version info for registered backends.
 
static isc::asiolink::IOServicePtr getIOService ()
 Get the hook I/O service.
 
static isc::db::DatabaseConnection::ParameterMap getParameters (ManagerID id=0)
 Gets the forensic backend manager parameters.
 
static LegalLogMgrPool getPool ()
 Returns underlying forensic log backend pool.
 
static bool haveInstance (std::string type)
 Returns true is respective backend store is present, false otherwise.
 
static LegalLogMgrPtrinstance (ManagerID id=0)
 Returns the forensic backend manager with specified ID.
 
static void logRegistered ()
 Logs out all registered backends.
 
static bool registerBackendFactory (const std::string &db_type, const Factory &factory, bool no_log=false, DBVersion db_version=DBVersion())
 Registers new backend factory function for a given backend type.
 
static bool registeredFactory (const std::string &db_type)
 Check if a backend store factory was registered.
 
static void setIOService (isc::asiolink::IOServicePtr io_service)
 Set the hook I/O service.
 
static void setParameters (isc::db::DatabaseConnection::ParameterMap parameters, ManagerID id=0)
 Sets the forensic backend manager parameters.
 
static bool unregisterBackendFactory (const std::string &db_type, bool no_log=false)
 Unregisters the backend factory function for a given backend type.
 

Static Protected Attributes

static isc::asiolink::IOServicePtr io_service_
 The hook I/O service.
 
static std::map< std::string, std::pair< LegalLogMgrFactory::Factory, LegalLogMgrFactory::DBVersion > > map_
 A map holding registered backend factory functions.
 
static LegalLogMgrPool pool_
 Pointer to the forensic log backends pool.
 

Detailed Description

Backend Store Factory.

This class comprises nothing but static methods used to create a forensic backend store. It analyzes the database information passed to the creation function and instantiates an appropriate forensic backend store based on the type requested.

Strictly speaking these functions could be stand-alone functions. However, it is convenient to encapsulate them in a class for naming purposes.

Definition at line 32 of file legal_log_mgr_factory.h.

Member Function Documentation

◆ addBackend()

void isc::dhcp::LegalLogMgrFactory::addBackend ( db::DatabaseConnection::ParameterMap & parameters,
ManagerID id = 0 )
static

Create an instance of a forensic log backend.

This method uses provided parameters map representing database connection information to create an instance of the forensic log backend. If the specified backend type is not supported, i.e. there is no relevant factory function registered, an exception is thrown.

Parameters
parametersdatabase parameters.
idthe forensic backend manager ID (default value is 0 and it is used only in unit tests).
Exceptions
InvalidParameterif access string lacks database type value.
db::InvalidTypeif the type of the database backend is not supported.
Unexpectedif the backend factory function returned NULL.

Definition at line 72 of file legal_log_mgr_factory.cc.

References isc_throw, map_, and pool_.

Referenced by load().

◆ delAllBackends() [1/2]

void isc::dhcp::LegalLogMgrFactory::delAllBackends ( )
static

Removes all backends from the pool.

Definition at line 125 of file legal_log_mgr_factory.cc.

References pool_.

Referenced by unload(), and unregisterBackendFactory().

◆ delAllBackends() [2/2]

void isc::dhcp::LegalLogMgrFactory::delAllBackends ( const std::string & db_type)
static

Deletes all backends of the given type from the pool.

Parameters
db_typebackend to remove.

Definition at line 130 of file legal_log_mgr_factory.cc.

References pool_.

◆ delBackend() [1/2]

bool isc::dhcp::LegalLogMgrFactory::delBackend ( const std::string & db_type,
db::DatabaseConnection::ParameterMap & parameters,
bool if_unusable = false )
static

Delete a forensic backend manager.

Delete the first instance of a config database manager which matches specific parameters. This should have the effect of closing the database connection.

Parameters
db_typebackend to remove.
parametersdatabase parameters.
if_unusableFlag which indicates if the config backend should be deleted only if it is unusable.
Returns
false when not removed because it is not found or because it is still usable (if_unusable is true), true otherwise.

Definition at line 183 of file legal_log_mgr_factory.cc.

References pool_.

◆ delBackend() [2/2]

bool isc::dhcp::LegalLogMgrFactory::delBackend ( ManagerID id,
bool if_unusable = false )
static

Delete a forensic backend manager.

Delete the first instance of a config database manager which matches specific parameters. This should have the effect of closing the database connection.

Parameters
idthe forensic backend manager ID.
if_unusableFlag which indicates if the forensic backend should be deleted only if it is unusable.
Returns
false when not removed because it is not found or because it is still usable (if_unusable is true), true otherwise.

Definition at line 206 of file legal_log_mgr_factory.cc.

References pool_.

◆ getDBVersions()

list< string > isc::dhcp::LegalLogMgrFactory::getDBVersions ( )
static

Return extended version info for registered backends.

Definition at line 246 of file legal_log_mgr_factory.cc.

References map_, and version().

Referenced by isc::dhcp::Dhcpv4Srv::getVersion(), and isc::dhcp::Dhcpv6Srv::getVersion().

+ Here is the call graph for this function:

◆ getIOService()

static isc::asiolink::IOServicePtr isc::dhcp::LegalLogMgrFactory::getIOService ( )
inlinestatic

Get the hook I/O service.

Returns
the hook I/O service.

Definition at line 178 of file legal_log_mgr_factory.h.

References io_service_.

◆ getParameters()

DatabaseConnection::ParameterMap isc::dhcp::LegalLogMgrFactory::getParameters ( ManagerID id = 0)
static

Gets the forensic backend manager parameters.

Parameters
idthe forensic backend manager ID (default value is 0 and it is used only in unit tests).
Returns
database parameters.

Definition at line 174 of file legal_log_mgr_factory.cc.

References pool_.

◆ getPool()

static LegalLogMgrPool isc::dhcp::LegalLogMgrFactory::getPool ( )
inlinestatic

Returns underlying forensic log backend pool.

Definition at line 166 of file legal_log_mgr_factory.h.

References pool_.

◆ haveInstance()

bool isc::dhcp::LegalLogMgrFactory::haveInstance ( std::string type)
static

Returns true is respective backend store is present, false otherwise.

Parameters
typethe backend store type to check if it exists.

Definition at line 259 of file legal_log_mgr_factory.cc.

References pool_.

◆ instance()

LegalLogMgrPtr & isc::dhcp::LegalLogMgrFactory::instance ( ManagerID id = 0)
static

Returns the forensic backend manager with specified ID.

Parameters
idthe forensic backend manager ID (default value is 0 and it is used only in unit tests).
Returns
the forensic backend manager instance or null pointer.

Definition at line 143 of file legal_log_mgr_factory.cc.

References pool_.

Referenced by addDuration(), command_processed(), getCustomEntry(), getCustomEntry(), handleLease4Cmds(), handleLease6Cmds(), legalLog4Handler(), legalLog6Handler(), and setParameters().

◆ logRegistered()

void isc::dhcp::LegalLogMgrFactory::logRegistered ( )
static

Logs out all registered backends.

We need a dedicated method for this, because we sometimes can't log the backend type when doing early initialization for backends initialized statically.

Definition at line 231 of file legal_log_mgr_factory.cc.

References isc::dhcp::DHCPSRV_FORENSIC_BACKENDS_REGISTERED, isc::dhcp::dhcpsrv_logger, LOG_INFO, and map_.

Referenced by isc::dhcp::configureDhcp4Server(), and isc::dhcp::configureDhcp6Server().

◆ registerBackendFactory()

bool isc::dhcp::LegalLogMgrFactory::registerBackendFactory ( const std::string & db_type,
const Factory & factory,
bool no_log = false,
DBVersion db_version = DBVersion() )
static

Registers new backend factory function for a given backend type.

If the backend of the given type has already been registered, perhaps by another hooks library, the CBM will refuse to register another backend of the same type.

Parameters
db_typebackend type, e.g. "mysql".
factorypointer to the backend factory function.
no_logdo not log (default false)
db_versionforensic backend version
Returns
true if the factory was successfully added to the map, false if it already exists.

Definition at line 23 of file legal_log_mgr_factory.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::DHCPSRV_FORENSIC_BACKEND_REGISTER, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and map_.

Referenced by isc::legal_log::RotatingFileInit::RotatingFileInit(), and load().

◆ registeredFactory()

bool isc::dhcp::LegalLogMgrFactory::registeredFactory ( const std::string & db_type)
static

Check if a backend store factory was registered.

Parameters
db_typedatabase type
Returns
true if a factory was registered for db_type, false if not.

Definition at line 225 of file legal_log_mgr_factory.cc.

References map_.

◆ setIOService()

static void isc::dhcp::LegalLogMgrFactory::setIOService ( isc::asiolink::IOServicePtr io_service)
inlinestatic

Set the hook I/O service.

Parameters
io_servicethe hook I/O service.

Definition at line 185 of file legal_log_mgr_factory.h.

References io_service_.

◆ setParameters()

void isc::dhcp::LegalLogMgrFactory::setParameters ( isc::db::DatabaseConnection::ParameterMap parameters,
ManagerID id = 0 )
static

Sets the forensic backend manager parameters.

Parameters
parametersdatabase parameters.
idthe forensic backend manager ID (default value is 0 and it is used only in unit tests).

Definition at line 162 of file legal_log_mgr_factory.cc.

References instance(), and pool_.

+ Here is the call graph for this function:

◆ unregisterBackendFactory()

bool isc::dhcp::LegalLogMgrFactory::unregisterBackendFactory ( const std::string & db_type,
bool no_log = false )
static

Unregisters the backend factory function for a given backend type.

Parameters
db_typebackend type, e.g. "mysql".
no_logdo not log (default false)
Returns
false if no factory for the given type was unregistered, true if the factory was removed.

Definition at line 53 of file legal_log_mgr_factory.cc.

References delAllBackends(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::DHCPSRV_FORENSIC_BACKEND_DEREGISTER, isc::dhcp::dhcpsrv_logger, LOG_DEBUG, and map_.

Referenced by isc::legal_log::RotatingFileInit::~RotatingFileInit(), and unload().

+ Here is the call graph for this function:

Member Data Documentation

◆ io_service_

isc::asiolink::IOServicePtr isc::dhcp::LegalLogMgrFactory::io_service_
staticprotected

The hook I/O service.

Definition at line 192 of file legal_log_mgr_factory.h.

Referenced by getIOService(), and setIOService().

◆ map_

map< string, pair< LegalLogMgrFactory::Factory, LegalLogMgrFactory::DBVersion > > isc::dhcp::LegalLogMgrFactory::map_
staticprotected

A map holding registered backend factory functions.

Definition at line 195 of file legal_log_mgr_factory.h.

Referenced by addBackend(), getDBVersions(), logRegistered(), registerBackendFactory(), registeredFactory(), and unregisterBackendFactory().

◆ pool_

LegalLogMgrPool isc::dhcp::LegalLogMgrFactory::pool_
staticprotected

Pointer to the forensic log backends pool.

Definition at line 198 of file legal_log_mgr_factory.h.

Referenced by addBackend(), delAllBackends(), delAllBackends(), delBackend(), delBackend(), getParameters(), getPool(), haveInstance(), instance(), and setParameters().


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