Kea: isc::dhcp::LFCSetup Class Reference

| Kea 3.2.0-git

isc::dhcp::LFCSetup Class Reference

Represents a configuration for Lease File Cleanup. More...

## Public Member Functions
| LFCSetup (asiolink::IntervalTimer::Callback callback)
| Constructor.
| ~LFCSetup ()
| Destructor.
void | execute (const std::string &lease_file)
| Spawns a new process.
int | getExitStatus () const
| Returns exit code of the last completed cleanup.
int | getLastPid () const
| Returns pid of the last lease file cleanup.
bool | isRunning () const
| Checks if the lease file cleanup is in progress.
void | setup (const uint32_t lfc_interval, const boost::shared_ptr< CSVLeaseFile4 > &lease_file4, const boost::shared_ptr< CSVLeaseFile6 > &lease_file6, bool run_once_now=false)
| Sets the new configuration for the Lease File Cleanup.

## Detailed Description

Represents a configuration for Lease File Cleanup.

This class is solely used by the `Memfile_LeaseMgr` as a configuration information storage for Lease File Cleanup. Internally, it creates the interval timer and assigns a callback function (pointer to which is passed in the constructor), which will be called at the specified intervals to perform the cleanup. It is also responsible for creating and maintaining the object which is used to spawn the new process which executes the `kea-lfc` program.

This functionality is enclosed in a separate class so as the implementation details are not exposed in the `Memfile_LeaseMgr` header file and to maintain a single place with the LFC configuration, instead of multiple members and functions scattered in the `Memfile_LeaseMgr` class.

Definition at line 76 of file memfile_lease_mgr.cc.

## Constructor & Destructor Documentation

## ◆ LFCSetup()

isc::dhcp::LFCSetup::LFCSetup | ( | asiolink::IntervalTimer::Callback | callback | ) |

Constructor.

Assigns a pointer to the function triggered to perform the cleanup. This pointer should point to the appropriate method of the `Memfile_LeaseMgr` class.

Parameters

  callback | A pointer to the callback function.

Definition at line 142 of file memfile_lease_mgr.cc.

## ◆ ~LFCSetup()

isc::dhcp::LFCSetup::~LFCSetup | ( |  | ) |

Destructor.

Unregisters LFC timer.

Definition at line 147 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED, and LOG_DEBUG.

## Member Function Documentation

## ◆ execute()

void isc::dhcp::LFCSetup::execute | ( | const std::string & | lease_file | ) |

Spawns a new process.

Definition at line 243 of file memfile_lease_mgr.cc.

References isc::dhcp::Memfile_LeaseMgr::appendSuffix(), isc::util::PIDFile::check(), isc::util::PIDFile::deleteFile(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_EXECUTE, isc::dhcp::DHCPSRV_MEMFILE_LFC_FAIL_PID_CREATE, isc::dhcp::DHCPSRV_MEMFILE_LFC_RUNNING, isc::dhcp::DHCPSRV_MEMFILE_LFC_SPAWN_FAIL, isc::dhcp::Memfile_LeaseMgr::FILE_PID, isc::util::PIDFile::getLockname(), isc::util::PIDLock::isLocked(), LOG_ERROR, LOG_INFO, isc::Exception::what(), and isc::util::PIDFile::write().

Here is the call graph for this function:

## ◆ getExitStatus()

int isc::dhcp::LFCSetup::getExitStatus | ( |  | ) | const

Returns exit code of the last completed cleanup.

Definition at line 301 of file memfile_lease_mgr.cc.

References isc_throw.

## ◆ getLastPid()

int isc::dhcp::LFCSetup::getLastPid | ( |  | ) | const

Returns pid of the last lease file cleanup.

Definition at line 310 of file memfile_lease_mgr.cc.

## ◆ isRunning()

bool isc::dhcp::LFCSetup::isRunning | ( |  | ) | const

Checks if the lease file cleanup is in progress.

Returns
  true if the lease file cleanup is being executed.

Definition at line 296 of file memfile_lease_mgr.cc.

## ◆ setup()

void isc::dhcp::LFCSetup::setup | ( | const uint32_t | lfc_interval,
|  | const boost::shared_ptr< CSVLeaseFile4 > & | lease_file4,
|  | const boost::shared_ptr< CSVLeaseFile6 > & | lease_file6,
|  | bool | run_once_now = false )

Sets the new configuration for the Lease File Cleanup.

Parameters

  lfc_interval | An interval in seconds at which the cleanup should be performed.
  lease_file4 | A pointer to the DHCPv4 lease file to be cleaned up or null. If this is null, the `lease_file6` must be non-null.
  lease_file6 | A pointer to the DHCPv6 lease file to be cleaned up or null. If this is null, the `lease_file4` must be non-null.
  run_once_now | A flag that causes LFC to be invoked immediately, regardless of the value of lfc_interval. This is primarily used to cause lease file schema upgrades upon startup.

Definition at line 171 of file memfile_lease_mgr.cc.

References isc::dhcp::Memfile_LeaseMgr::appendSuffix(), isc::asiolink::ProcessSpawn::ASYNC, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_SETUP, isc::dhcp::Memfile_LeaseMgr::FILE_FINISH, isc::dhcp::Memfile_LeaseMgr::FILE_INPUT, isc::dhcp::Memfile_LeaseMgr::FILE_OUTPUT, isc::dhcp::Memfile_LeaseMgr::FILE_PID, isc::dhcp::Memfile_LeaseMgr::FILE_PREVIOUS, LOG_INFO, and isc::asiolink::IntervalTimer::REPEATING.

Here is the call graph for this function:

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

- memfile_lease_mgr.cc