![]() |
Kea 3.1.1
|
Backend Store Factory. More...
#include <legal_log_mgr_factory.h>
Static Public Member Functions | |
static void | addBackend (db::DatabaseConnection::ParameterMap ¶meters, 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 ¶meters, 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 LegalLogMgrPtr & | instance (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. | |
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.
|
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 | database parameters. |
id | the forensic backend manager ID (default value is 0 and it is used only in unit tests). |
InvalidParameter | if access string lacks database type value. |
db::InvalidType | if the type of the database backend is not supported. |
Unexpected | if 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().
|
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().
|
static |
Deletes all backends of the given type from the pool.
db_type | backend to remove. |
Definition at line 130 of file legal_log_mgr_factory.cc.
References pool_.
|
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.
db_type | backend to remove. |
parameters | database parameters. |
if_unusable | Flag which indicates if the config backend should be deleted only if it is unusable. |
Definition at line 183 of file legal_log_mgr_factory.cc.
References pool_.
|
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.
id | the forensic backend manager ID. |
if_unusable | Flag which indicates if the forensic backend should be deleted only if it is unusable. |
Definition at line 206 of file legal_log_mgr_factory.cc.
References pool_.
|
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().
|
inlinestatic |
Get the hook I/O service.
Definition at line 178 of file legal_log_mgr_factory.h.
References io_service_.
|
static |
Gets the forensic backend manager parameters.
id | the forensic backend manager ID (default value is 0 and it is used only in unit tests). |
Definition at line 174 of file legal_log_mgr_factory.cc.
References pool_.
|
inlinestatic |
Returns underlying forensic log backend pool.
Definition at line 166 of file legal_log_mgr_factory.h.
References pool_.
|
static |
Returns true is respective backend store is present, false otherwise.
type | the backend store type to check if it exists. |
Definition at line 259 of file legal_log_mgr_factory.cc.
References pool_.
|
static |
Returns the forensic backend manager with specified ID.
id | the forensic backend manager ID (default value is 0 and it is used only in unit tests). |
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().
|
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().
|
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.
db_type | backend type, e.g. "mysql". |
factory | pointer to the backend factory function. |
no_log | do not log (default false) |
db_version | forensic backend version |
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().
|
static |
Check if a backend store factory was registered.
db_type | database type |
Definition at line 225 of file legal_log_mgr_factory.cc.
References map_.
|
inlinestatic |
Set the hook I/O service.
io_service | the hook I/O service. |
Definition at line 185 of file legal_log_mgr_factory.h.
References io_service_.
|
static |
Sets the forensic backend manager parameters.
parameters | database parameters. |
id | the 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_.
|
static |
Unregisters the backend factory function for a given backend type.
db_type | backend type, e.g. "mysql". |
no_log | do not log (default false) |
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().
|
staticprotected |
The hook I/O service.
Definition at line 192 of file legal_log_mgr_factory.h.
Referenced by getIOService(), and setIOService().
|
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().
|
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().