7#ifndef LEASE_FILE_LOADER_H 
    8#define LEASE_FILE_LOADER_H 
   15#include <boost/scoped_ptr.hpp> 
   16#include <boost/shared_ptr.hpp> 
   76    template<
typename LeaseObjectType, 
typename LeaseFileType,
 
   78    static void load(LeaseFileType& lease_file, StorageType& storage,
 
   79                     const uint32_t max_errors = 0,
 
   80                     const bool close_file_on_exit = 
true) {
 
   83            .arg(lease_file.getFilename());
 
   91        boost::scoped_ptr<SanityChecker> lease_checker;
 
   99        boost::shared_ptr<LeaseObjectType> lease;
 
  104            if (!lease_file.next(lease)) {
 
  106                            .arg(lease_file.getReads())
 
  107                            .arg(lease_file.getReadMsg());
 
  113                if (max_errors && (++errcnt > max_errors)) {
 
  122                              " failures " << max_errors << 
" to read a lease" 
  123                              " from the lease file " 
  124                              << lease_file.getFilename());
 
  134                    .arg(lease->toText());
 
  141                    lease_checker->checkLease(lease, 
false);
 
  148                typename StorageType::iterator lease_it =
 
  149                    storage.find(lease->addr_);
 
  152                if (lease_it == storage.end()) {
 
  153                    if (lease->valid_lft_ > 0) {
 
  154                        storage.insert(lease);
 
  160                    if (lease->valid_lft_ == 0) {
 
  161                        storage.erase(lease_it);
 
  165                        storage.replace(lease_it, lease);
 
  176        if (lease_file.needsConversion()) {
 
  178                     (lease_file.getInputSchemaState()
 
  182                     .arg(lease_file.getFilename())
 
  183                     .arg(lease_file.getSchemaVersion());
 
  186        if (close_file_on_exit) {
 
 
  217    template<
typename LeaseObjectType, 
typename LeaseFileType,
 
  218             typename StorageType>
 
  219    static void write(LeaseFileType& lease_file, 
const StorageType& storage) {
 
  226        for (
auto const& lease : storage) {
 
  228                lease_file.append(*lease);
 
 
 
This is a base class for exceptions thrown from the DNS library module.
Utility class to manage bulk of leases in the lease files.
static void write(LeaseFileType &lease_file, const StorageType &storage)
Write leases from the storage into a lease file.
static void load(LeaseFileType &lease_file, StorageType &storage, const uint32_t max_errors=0, const bool close_file_on_exit=true)
Load leases from the lease file into the specified storage.
Code used to conduct various sanity checks.
static bool leaseCheckingEnabled(bool current=true)
Indicates the specified configuration enables lease sanity checking.
Exception thrown when an error occurs during CSV file processing.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
const int DHCPSRV_DBG_TRACE_DETAIL_DATA
Additional information.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_LOAD
const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_FILE_LOAD
const isc::log::MessageID DHCPSRV_MEMFILE_NEEDS_DOWNGRADING
const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_LOAD_ROW_ERROR
const isc::log::MessageID DHCPSRV_MEMFILE_NEEDS_UPGRADING
Defines the logger used by the top-level component of kea-lfc.