d2_process.h 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (C) 2013 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. #ifndef D2_PROCESS_H
  15. #define D2_PROCESS_H
  16. #include <d2/d_process.h>
  17. namespace isc {
  18. namespace d2 {
  19. /// @brief @TODO DHCP-DDNS Application Process
  20. ///
  21. /// D2Process provides the top level application logic for DHCP-driven DDNS
  22. /// update processing. It provides the asynchronous event processing required
  23. /// to receive DNS mapping change requests and carry them out.
  24. /// It implements the DProcessBase interface, which structures it such that it
  25. /// is a managed "application", controlled by a management layer.
  26. class D2Process : public DProcessBase {
  27. public:
  28. /// @brief Constructor
  29. ///
  30. /// @param name name is a text label for the process. Generally used
  31. /// in log statements, but otherwise arbitrary.
  32. /// @param io_service is the io_service used by the caller for
  33. /// asynchronous event handling.
  34. ///
  35. /// @throw DProcessBaseError is io_service is NULL.
  36. D2Process(const char* name, IOServicePtr io_service);
  37. /// @brief Will be used after instantiation to perform initialization
  38. /// unique to D2. This will likely include interactions with QueueMgr and
  39. /// UpdateMgr, to prepare for request receipt and processing.
  40. virtual void init();
  41. /// @brief Implements the process's event loop.
  42. /// The initial implementation is quite basic, surrounding calls to
  43. /// io_service->runOne() with a test of the shutdown flag.
  44. /// Once invoked, the method will continue until the process itself is
  45. /// exiting due to a request to shutdown or some anomaly forces an exit.
  46. /// @return returns 0 upon a successful, "normal" termination, non
  47. /// zero to indicate an abnormal termination.
  48. virtual int run();
  49. // @TODO need brief
  50. virtual int shutdown();
  51. // @TODO need brief
  52. /// @brief Processes the given configuration.
  53. ///
  54. /// This method may be called multiple times during the process lifetime.
  55. /// Certainly once during process startup, and possibly later if the user
  56. /// alters configuration. This method must not throw, it should catch any
  57. /// processing errors and return a success or failure answer as described
  58. /// below.
  59. ///
  60. /// @param config_set a new configuration (JSON) for the process
  61. /// @return an Element that contains the results of configuration composed
  62. /// of an integer status value (0 means successful, non-zero means failure),
  63. /// and a string explanation of the outcome.
  64. virtual isc::data::ConstElementPtr configure(isc::data::ConstElementPtr
  65. config_set);
  66. // @TODO need brief
  67. /// @brief Processes the given command.
  68. ///
  69. /// This method is called to execute any custom commands supported by the
  70. /// process. This method must not throw, it should catch any processing
  71. /// errors and return a success or failure answer as described below.
  72. ///
  73. /// @param command is a string label representing the command to execute.
  74. /// @param args is a set of arguments (if any) required for the given
  75. /// command.
  76. /// @return an Element that contains the results of command composed
  77. /// of an integer status value (0 means successful, non-zero means failure),
  78. /// and a string explanation of the outcome.
  79. virtual isc::data::ConstElementPtr command(const std::string& command,
  80. isc::data::ConstElementPtr args);
  81. // @TODO need brief
  82. virtual ~D2Process();
  83. };
  84. }; // namespace isc::d2
  85. }; // namespace isc
  86. #endif