Kea  1.9.9-git
lfc_controller.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef LFC_CONTROLLER_H
8 #define LFC_CONTROLLER_H
9 
10 #include <exceptions/exceptions.h>
11 #include <string>
12 
13 namespace isc {
14 namespace lfc {
15 
17 class InvalidUsage : public isc::Exception {
18 public:
19  InvalidUsage(const char* file, size_t line, const char* what) :
20  isc::Exception(file, line, what) { };
21 };
22 
25 class RunTimeFail : public isc::Exception {
26 public:
27  RunTimeFail(const char* file, size_t line, const char* what) :
28  isc::Exception(file, line, what) { };
29 };
30 
38 public:
41  static const char* lfc_app_name_;
42 
45  static const char* lfc_bin_name_;
46 
48  LFCController();
49 
52 
79  void launch(int argc, char* argv[], const bool test_mode);
80 
89  void parseArgs(int argc, char* argv[]);
90 
98  void fileRotate() const;
99 
101 
102 
108  int getProtocolVersion() const {
109  return (protocol_version_);
110  }
111 
115  std::string getConfigFile() const {
116  return (config_file_);
117  }
118 
122  std::string getPreviousFile() const {
123  return (previous_file_);
124  }
125 
129  std::string getCopyFile() const {
130  return (copy_file_);
131  }
132 
136  std::string getOutputFile() const {
137  return (output_file_);
138  }
139 
143  std::string getFinishFile() const {
144  return (finish_file_);
145  }
146 
150  std::string getPidFile() const {
151  return (pid_file_);
152  }
154 
155 private:
157  int protocol_version_;
159  bool verbose_;
160  std::string config_file_;
161  std::string previous_file_;
162  std::string copy_file_;
163  std::string output_file_;
164  std::string finish_file_;
165  std::string pid_file_;
166 
171  void usage(const std::string& text);
172 
177  std::string getVersion(const bool extended) const;
178 
190  template<typename LeaseObjectType, typename LeaseFileType, typename StorageType>
191  void processLeases() const;
192 
197  void startLogger(const bool test_mode) const;
198 };
199 
200 }; // namespace isc::lfc
201 }; // namespace isc
202 
203 #endif // LFC_CONTROLLER_H
~LFCController()
Destructor.
RunTimeFail(const char *file, size_t line, const char *what)
int getProtocolVersion() const
Gets the protocol version of the leases files.
Exceptions thrown when a method is unable to manipulate (remove or rename) a file.
void launch(int argc, char *argv[], const bool test_mode)
Acts as the primary entry point to start execution of the process.
std::string getCopyFile() const
Gets the copy file name.
void parseArgs(int argc, char *argv[])
Process the command line arguments.
InvalidUsage(const char *file, size_t line, const char *what)
static const char * lfc_bin_name_
Defines the executable name, by convention this should match the executable name. ...
std::string getPreviousFile() const
Gets the previous file name.
void fileRotate() const
Rotate files.
Process controller for LFC process.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
std::string getOutputFile() const
Gets the output file name.
static const char * lfc_app_name_
Defines the application name, it may be used to locate configuration data and appears in log statemen...
std::string getConfigFile() const
Gets the config file name.
Exception thrown when the command line is invalid.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
std::string getPidFile() const
Gets the pid file name.
std::string getFinishFile() const
Gets the finish file name.
LFCController()
Constructor.