Kea 2.7.6
|
Process controller for LFC process. More...
#include <lfc_controller.h>
Public Member Functions | |
LFCController () | |
Constructor. | |
~LFCController () | |
Destructor. | |
void | fileRotate () const |
Rotate files. | |
void | launch (int argc, char *argv[], const bool test_mode) |
Acts as the primary entry point to start execution of the process. | |
void | parseArgs (int argc, char *argv[]) |
Process the command line arguments. | |
Static Public Attributes | |
static const char * | lfc_app_name_ = "DhcpLFC" |
Defines the application name, it may be used to locate configuration data and appears in log statements. | |
static const char * | lfc_bin_name_ = "kea-lfc" |
Defines the executable name, by convention this should match the executable name. | |
Accessor methods mainly used for testing purposes | |
int | getProtocolVersion () const |
Gets the protocol version of the leases files. | |
std::string | getConfigFile () const |
Gets the config file name. | |
std::string | getPreviousFile () const |
Gets the previous file name. | |
std::string | getCopyFile () const |
Gets the copy file name. | |
std::string | getOutputFile () const |
Gets the output file name. | |
std::string | getFinishFile () const |
Gets the finish file name. | |
std::string | getPidFile () const |
Gets the pid file name. | |
Process controller for LFC process.
This class provides the LFC process functions. These are used to: manage the command line, check for already running instances, invoke the code to process the lease files and finally to rename the lease files as necessary.
Definition at line 37 of file lfc_controller.h.
isc::lfc::LFCController::LFCController | ( | ) |
Constructor.
Definition at line 50 of file lfc_controller.cc.
isc::lfc::LFCController::~LFCController | ( | ) |
Destructor.
Definition at line 55 of file lfc_controller.cc.
void isc::lfc::LFCController::fileRotate | ( | ) | const |
Rotate files.
After we have a finish file, either from doing the cleanup or because a previous instance was interrupted, delete the work files (previous & copy) and move the finish file to be the new previous file.
RunTimeFail | if we can't manipulate the files. |
Definition at line 385 of file lfc_controller.cc.
References getCopyFile(), getPreviousFile(), and isc_throw.
Referenced by launch().
|
inline |
Gets the config file name.
Definition at line 115 of file lfc_controller.h.
|
inline |
Gets the copy file name.
Definition at line 129 of file lfc_controller.h.
Referenced by fileRotate().
|
inline |
Gets the finish file name.
Definition at line 143 of file lfc_controller.h.
Referenced by launch().
|
inline |
Gets the output file name.
Definition at line 136 of file lfc_controller.h.
|
inline |
Gets the pid file name.
Definition at line 150 of file lfc_controller.h.
|
inline |
Gets the previous file name.
Definition at line 122 of file lfc_controller.h.
Referenced by fileRotate().
|
inline |
Gets the protocol version of the leases files.
Definition at line 108 of file lfc_controller.h.
Referenced by launch().
void isc::lfc::LFCController::launch | ( | int | argc, |
char * | argv[], | ||
const bool | test_mode ) |
Acts as the primary entry point to start execution of the process.
Provides the control logic to combine two lease files and weed out duplicate and expired leases. A description of the design can be found at https://gitlab.isc.org/isc-projects/kea/wikis/designs/Lease-File-Cleanup-design
argc | Number of strings in the argv array. |
argv | Array of arguments passed in via the program's main function. |
test_mode | is a bool value which indicates if launch should be run in the test mode (if true). This parameter doesn't have a default value to force test implementers to enable test mode explicitly. |
InvalidUsage | if the command line parameters are invalid. |
Definition at line 59 of file lfc_controller.cc.
References isc::util::PIDFile::check(), isc::util::PIDFile::deleteFile(), isc::util::CSVFile::exists(), fileRotate(), getFinishFile(), getProtocolVersion(), isc::lfc::LFC_FAIL_PID_CREATE, isc::lfc::LFC_FAIL_PID_DEL, isc::lfc::LFC_FAIL_PROCESS, isc::lfc::LFC_FAIL_ROTATE, isc::lfc::lfc_logger, isc::lfc::LFC_PROCESSING, isc::lfc::LFC_ROTATING, isc::lfc::LFC_RUNNING, isc::lfc::LFC_START, isc::lfc::LFC_TERMINATE, LOG_FATAL, LOG_INFO, parseArgs(), usage(), isc::Exception::what(), and isc::util::PIDFile::write().
Referenced by main().
void isc::lfc::LFCController::parseArgs | ( | int | argc, |
char * | argv[] ) |
Process the command line arguments.
It is the first step taken after the process has been launched.
argc | Number of strings in the argv array. |
argv | Array of arguments passed in via the program's main function. |
InvalidUsage | if the command line parameters are invalid. |
Definition at line 146 of file lfc_controller.cc.
References isc::detail::getConfigReport(), isc_throw, and usage().
Referenced by launch().
|
static |
Defines the application name, it may be used to locate configuration data and appears in log statements.
Definition at line 41 of file lfc_controller.h.
|
static |
Defines the executable name, by convention this should match the executable name.
Defines the executable name.
Definition at line 45 of file lfc_controller.h.