Kea: isc::lfc::LFCController Class Reference

| Kea 3.0.2-git

isc::lfc::LFCController Class Reference

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.

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ LFCController()

isc::lfc::LFCController::LFCController | ( |  | ) |

Constructor.

Definition at line 50 of file lfc_controller.cc.

## ◆ ~LFCController()

isc::lfc::LFCController::~LFCController | ( |  | ) |

Destructor.

Definition at line 55 of file lfc_controller.cc.

## Member Function Documentation

## ◆ fileRotate()

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.

Exceptions

  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().

Here is the call graph for this function:

## ◆ getConfigFile()

std::string isc::lfc::LFCController::getConfigFile | ( |  | ) | const
| inline

Gets the config file name.

Returns
  Returns the path to the config file

Definition at line 115 of file lfc_controller.h.

## ◆ getCopyFile()

std::string isc::lfc::LFCController::getCopyFile | ( |  | ) | const
| inline

Gets the copy file name.

Returns
  Returns the path to the copy file

Definition at line 129 of file lfc_controller.h.

Referenced by fileRotate().

## ◆ getFinishFile()

std::string isc::lfc::LFCController::getFinishFile | ( |  | ) | const
| inline

Gets the finish file name.

Returns
  Returns the path to the finish file

Definition at line 143 of file lfc_controller.h.

Referenced by launch().

## ◆ getOutputFile()

std::string isc::lfc::LFCController::getOutputFile | ( |  | ) | const
| inline

Gets the output file name.

Returns
  Returns the path to the output file

Definition at line 136 of file lfc_controller.h.

## ◆ getPidFile()

std::string isc::lfc::LFCController::getPidFile | ( |  | ) | const
| inline

Gets the pid file name.

Returns
  Returns the path to the pid file

Definition at line 150 of file lfc_controller.h.

## ◆ getPreviousFile()

std::string isc::lfc::LFCController::getPreviousFile | ( |  | ) | const
| inline

Gets the previous file name.

Returns
  Returns the path to the previous file

Definition at line 122 of file lfc_controller.h.

Referenced by fileRotate().

## ◆ getProtocolVersion()

int isc::lfc::LFCController::getProtocolVersion | ( |  | ) | const
| inline

Gets the protocol version of the leases files.

Returns
  Returns the value of the DHCP protocol version. This can be 4 or 6 while in use and 0 before parsing any arguments.

Definition at line 108 of file lfc_controller.h.

Referenced by launch().

## ◆ 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

1. parse command line arguments
2. verify that it is the only instance
3. create pid file
4. read leases files
5. write lease file
6. move leases files
7. cleanup artifacts
8. remove pid file
9. exit to the caller

Parameters

  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.

Exceptions

  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().

Here is the call graph for this function:

## ◆ parseArgs()

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.

Parameters

  argc | Number of strings in the `argv` array.
  argv | Array of arguments passed in via the program's main function.

Exceptions

  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().

Here is the call graph for this function:

## Member Data Documentation

## ◆ lfc_app_name_

const char * isc::lfc::LFCController::lfc_app_name_ = "DhcpLFC"
| 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.

## ◆ lfc_bin_name_

const char * isc::lfc::LFCController::lfc_bin_name_ = "kea-lfc"
| 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.

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

- lfc_controller.h
- lfc_controller.cc