lfc.dox 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. /**
  15. @page lfc Lease File Cleanup Component
  16. The Lease File Cleanup component (kea-lfc) is a service process that removes redundant
  17. information from the files used to provide persistent storage for the memfile data base
  18. backend.
  19. When using the memfile database backend Kea servers store persistent lease information
  20. in lease files. They add new lease information to the file by appending it to the end
  21. of the file. In a typical lease file you might find several instances of the same lease,
  22. one for each time the client acquired or renewed the lease. In order to remove this
  23. redundant information and to keep the lease files from growing without bound the
  24. Kea servers will periodically run kea-lfc. This process will read the leases from
  25. the lease files and keep only the most recent instance of each lease. When it finishes
  26. reading the leases it will write the unique leases to the output file.
  27. The design documentation for kea-lfc can be found here:
  28. <a href="http://kea.isc.org/wiki/LFCDesign"> LFC Design</a>
  29. While kea-lfc can be started externally, there is usually no need to do this as the
  30. Kea servers will run it on a periodic basis.
  31. @section lfcProcessing Processing
  32. kea-lfc operates on a set of files, using them for input and output
  33. of the lease entries and to indicate where it is in the process in case of an
  34. interruption. Currently the caller must supply names for all of the files, in
  35. the future this requirement may be relaxed with the process getting the names
  36. from either the config file or from defaults.
  37. kea-lfc is built on the isc::lfc::LFCController class. Effectively this provides
  38. a single external routine, isc::lfc::LFCController::launch, which is called with
  39. the arguments from the command line and proceeds to parse the arguments and
  40. then process the lease files.
  41. It uses isc::util::PIDFile to manipulate a PID file to mediate access to the
  42. leases. When a new process is started it will check the PID file. If the
  43. PID file exists and a process with that ID is still running already the new
  44. process will be terminated. If no other process is running the PID of the
  45. new process is written to the file.
  46. It uses the isc::dhcp::LeaseFileLoader class to first read all of the leases
  47. into either isc::dhcp::Lease6Storage or isc::dhcp::Lease4Storage containers.
  48. The leases are read in the order they were written to the file and younger leases
  49. overwrite older leases for the same address. When the process finishes reading
  50. the lease files there will be a single lease entry for each address used. At
  51. this point the process again uses the isc::dhcp::LeaseFileLoader class to write
  52. an entry for each remaining lease into the output file.
  53. Lastly kea-lfc moves the files to indicate completion (see below) and removes
  54. the extra files then exits.
  55. @section lfcFiles File Manipulation
  56. This section is intended to provide a brief overview of how kea-lfc uses its
  57. files. For a more in depth discussion of the design see
  58. <a href="http://kea.isc.org/wiki/LFCDesign"> LFC Design</a>
  59. There are four files used during the kea-lfc process: previous, input, output
  60. and finish. They are used to both hold the leases and to indicate to the Kea
  61. servers and to other instances of kea-lfc what processing has been completed.
  62. The previous file is the result of a previous run of the kea-lfc process.
  63. The input (or copy) file is created by the kea server just before invoking
  64. the kea-lfc process. The kea server will move it's current lease file to
  65. the input file and then start using a new current file.
  66. The output file is created by kea-lfc as it writes the leases to a file. When
  67. kea-lfc finishes writing all the leases to the output file it renames the output
  68. file to be the finish file. It then removes the previous and input files and
  69. renames the finish file to be the previous file.
  70. */