Browse Source

[master] Merge branch 'trac5074'

Marcin Siodelski 8 years ago
parent
commit
4563925f79
51 changed files with 732 additions and 462 deletions
  1. 4 1
      configure.ac
  2. 1 0
      doc/Doxyfile
  3. 3 1
      doc/devel/mainpage.dox
  4. 9 3
      doc/guide/logging.xml
  5. 0 2
      src/bin/d2/.gitignore
  6. 3 10
      src/bin/d2/Makefile.am
  7. 1 160
      src/bin/d2/d2.dox
  8. 3 1
      src/bin/d2/d2_cfg_mgr.cc
  9. 7 7
      src/bin/d2/d2_cfg_mgr.h
  10. 3 1
      src/bin/d2/d2_config.cc
  11. 5 5
      src/bin/d2/d2_config.h
  12. 4 2
      src/bin/d2/d2_controller.cc
  13. 5 5
      src/bin/d2/d2_controller.h
  14. 2 2
      src/bin/d2/d2_log.cc
  15. 1 1
      src/bin/d2/d2_log.h
  16. 1 121
      src/bin/d2/d2_messages.mes
  17. 17 15
      src/bin/d2/d2_process.cc
  18. 3 3
      src/bin/d2/d2_process.h
  19. 3 3
      src/bin/d2/d2_queue_mgr.cc
  20. 1 0
      src/bin/d2/main.cc
  21. 3 6
      src/bin/d2/tests/Makefile.am
  22. 3 2
      src/bin/d2/tests/d2_cfg_mgr_unittests.cc
  23. 5 4
      src/bin/d2/tests/d2_controller_unittests.cc
  24. 4 4
      src/bin/d2/tests/d2_process_tests.sh.in
  25. 3 2
      src/bin/d2/tests/d2_process_unittests.cc
  26. 4 3
      src/bin/d2/tests/d2_update_mgr_unittests.cc
  27. 5 5
      src/bin/keactrl/tests/keactrl_tests.sh.in
  28. 1 1
      src/lib/Makefile.am
  29. 5 0
      src/lib/process/.gitignore
  30. 72 0
      src/lib/process/Makefile.am
  31. 4 4
      src/bin/d2/d_cfg_mgr.cc
  32. 3 3
      src/bin/d2/d_cfg_mgr.h
  33. 20 21
      src/bin/d2/d_controller.cc
  34. 5 5
      src/bin/d2/d_controller.h
  35. 19 0
      src/lib/process/d_log.cc
  36. 23 0
      src/lib/process/d_log.h
  37. 4 4
      src/bin/d2/d_process.h
  38. 6 6
      src/bin/d2/io_service_signal.cc
  39. 11 10
      src/bin/d2/io_service_signal.h
  40. 176 0
      src/lib/process/libprocess.dox
  41. 137 0
      src/lib/process/process_messages.mes
  42. 0 0
      src/lib/process/spec_config.h.pre.in
  43. 1 0
      src/lib/process/tests/.gitignore
  44. 50 0
      src/lib/process/tests/Makefile.am
  45. 4 4
      src/bin/d2/tests/d_cfg_mgr_unittests.cc
  46. 22 18
      src/bin/d2/tests/d_controller_unittests.cc
  47. 5 5
      src/bin/d2/tests/io_service_signal_unittests.cc
  48. 22 0
      src/lib/process/tests/run_unittests.cc
  49. 27 0
      src/lib/process/testutils/Makefile.am
  50. 6 6
      src/bin/d2/tests/d_test_stubs.cc
  51. 6 6
      src/bin/d2/tests/d_test_stubs.h

+ 4 - 1
configure.ac

@@ -1513,7 +1513,6 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/Makefile
                  src/Makefile
                  src/bin/Makefile
                  src/bin/Makefile
                  src/bin/d2/Makefile
                  src/bin/d2/Makefile
-                 src/bin/d2/spec_config.h.pre
                  src/bin/d2/tests/Makefile
                  src/bin/d2/tests/Makefile
                  src/bin/d2/tests/d2_process_tests.sh
                  src/bin/d2/tests/d2_process_tests.sh
                  src/bin/d2/tests/test_data_files_config.h
                  src/bin/d2/tests/test_data_files_config.h
@@ -1600,6 +1599,10 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/lib/log/tests/logger_lock_test.sh
                  src/lib/log/tests/logger_lock_test.sh
                  src/lib/log/tests/severity_test.sh
                  src/lib/log/tests/severity_test.sh
                  src/lib/log/tests/tempdir.h
                  src/lib/log/tests/tempdir.h
+                 src/lib/process/Makefile
+                 src/lib/process/spec_config.h.pre
+                 src/lib/process/tests/Makefile
+                 src/lib/process/testutils/Makefile
                  src/lib/testutils/Makefile
                  src/lib/testutils/Makefile
                  src/lib/testutils/dhcp_test_lib.sh
                  src/lib/testutils/dhcp_test_lib.sh
                  src/lib/stats/Makefile
                  src/lib/stats/Makefile

+ 1 - 0
doc/Doxyfile

@@ -784,6 +784,7 @@ INPUT                  = ../src/bin/d2 \
                          ../src/lib/log \
                          ../src/lib/log \
                          ../src/lib/log/compiler \
                          ../src/lib/log/compiler \
                          ../src/lib/log/interprocess \
                          ../src/lib/log/interprocess \
+                         ../src/lib/process \
                          ../src/lib/stats \
                          ../src/lib/stats \
                          ../src/lib/testutils \
                          ../src/lib/testutils \
                          ../src/lib/util \
                          ../src/lib/util \

+ 3 - 1
doc/devel/mainpage.dox

@@ -71,8 +71,10 @@
  *   - @subpage dhcpv6SignalBasedReconfiguration
  *   - @subpage dhcpv6SignalBasedReconfiguration
  *   - @subpage dhcpv6Other
  *   - @subpage dhcpv6Other
  *   - @subpage dhcpv4o6Dhcp6
  *   - @subpage dhcpv4o6Dhcp6
+ * - @subpage libprocess
+ *   - @subpage cpl
+ *   - @subpage cplSignals
  * - @subpage d2
  * - @subpage d2
- *   - @subpage d2CPL
  *   - @subpage d2ProcessDerivation
  *   - @subpage d2ProcessDerivation
  *   - @subpage d2ConfigMgt
  *   - @subpage d2ConfigMgt
  *   - @subpage d2NCRReceipt
  *   - @subpage d2NCRReceipt

+ 9 - 3
doc/guide/logging.xml

@@ -441,10 +441,16 @@
 
 
           <listitem>
           <listitem>
             <simpara>
             <simpara>
+              <command>kea-dhcp-ddns.dctl</command> - the logger used by the
+              kea-dhcp-ddns daemon for logging basic information about the
+              process, received signals and triggered reconfigurations.
+            </simpara>
+          </listitem>
+
+          <listitem>
+            <simpara>
               <command>kea-dhcp-ddns.dhcpddns</command> - the logger used by the
               <command>kea-dhcp-ddns.dhcpddns</command> - the logger used by the
-              kea-dhcp-ddns daemon for logging configuration and global event
-              information.  This logger does not specify logging settings for
-              libraries used by the daemon.
+              kea-dhcp-ddns daemon for logging events related to DDNS operations.
             </simpara>
             </simpara>
           </listitem>
           </listitem>
 
 

+ 0 - 2
src/bin/d2/.gitignore

@@ -2,6 +2,4 @@
 /kea-dhcp-ddns.8
 /kea-dhcp-ddns.8
 /d2_messages.cc
 /d2_messages.cc
 /d2_messages.h
 /d2_messages.h
-/spec_config.h
-/spec_config.h.pre
 /s-messages
 /s-messages

+ 3 - 10
src/bin/d2/Makefile.am

@@ -19,7 +19,7 @@ if USE_STATIC_LINK
 AM_LDFLAGS = -static
 AM_LDFLAGS = -static
 endif
 endif
 
 
-CLEANFILES  = *.gcno *.gcda spec_config.h d2_messages.h d2_messages.cc s-messages
+CLEANFILES  = *.gcno *.gcda d2_messages.h d2_messages.cc s-messages
 
 
 man_MANS = kea-dhcp-ddns.8
 man_MANS = kea-dhcp-ddns.8
 DISTCLEANFILES = $(man_MANS)
 DISTCLEANFILES = $(man_MANS)
@@ -47,25 +47,19 @@ $(man_MANS):
 
 
 endif
 endif
 
 
-spec_config.h: spec_config.h.pre
-	$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@
-
 d2_messages.h d2_messages.cc: s-messages
 d2_messages.h d2_messages.cc: s-messages
 
 
 s-messages: d2_messages.mes
 s-messages: d2_messages.mes
 	$(top_builddir)/src/lib/log/compiler/kea-msg-compiler $(top_srcdir)/src/bin/d2/d2_messages.mes
 	$(top_builddir)/src/lib/log/compiler/kea-msg-compiler $(top_srcdir)/src/bin/d2/d2_messages.mes
 	touch $@
 	touch $@
 
 
-BUILT_SOURCES = spec_config.h d2_messages.h d2_messages.cc
+BUILT_SOURCES = d2_messages.h d2_messages.cc
 
 
 # convenience archive
 # convenience archive
 
 
 noinst_LTLIBRARIES = libd2.la
 noinst_LTLIBRARIES = libd2.la
 
 
 libd2_la_SOURCES  =
 libd2_la_SOURCES  =
-libd2_la_SOURCES += d_process.h
-libd2_la_SOURCES += d_controller.cc d_controller.h
-libd2_la_SOURCES += d_cfg_mgr.cc d_cfg_mgr.h
 libd2_la_SOURCES += d2_log.cc d2_log.h
 libd2_la_SOURCES += d2_log.cc d2_log.h
 libd2_la_SOURCES += d2_process.cc d2_process.h
 libd2_la_SOURCES += d2_process.cc d2_process.h
 libd2_la_SOURCES += d2_config.cc d2_config.h
 libd2_la_SOURCES += d2_config.cc d2_config.h
@@ -75,13 +69,11 @@ libd2_la_SOURCES += d2_update_message.cc d2_update_message.h
 libd2_la_SOURCES += d2_update_mgr.cc d2_update_mgr.h
 libd2_la_SOURCES += d2_update_mgr.cc d2_update_mgr.h
 libd2_la_SOURCES += d2_zone.cc d2_zone.h
 libd2_la_SOURCES += d2_zone.cc d2_zone.h
 libd2_la_SOURCES += dns_client.cc dns_client.h
 libd2_la_SOURCES += dns_client.cc dns_client.h
-libd2_la_SOURCES += io_service_signal.cc io_service_signal.h
 libd2_la_SOURCES += labeled_value.cc labeled_value.h
 libd2_la_SOURCES += labeled_value.cc labeled_value.h
 libd2_la_SOURCES += nc_add.cc nc_add.h
 libd2_la_SOURCES += nc_add.cc nc_add.h
 libd2_la_SOURCES += nc_remove.cc nc_remove.h
 libd2_la_SOURCES += nc_remove.cc nc_remove.h
 libd2_la_SOURCES += nc_trans.cc nc_trans.h
 libd2_la_SOURCES += nc_trans.cc nc_trans.h
 libd2_la_SOURCES += state_model.cc state_model.h
 libd2_la_SOURCES += state_model.cc state_model.h
-
 libd2_la_SOURCES += d2_controller.cc d2_controller.h
 libd2_la_SOURCES += d2_controller.cc d2_controller.h
 
 
 nodist_libd2_la_SOURCES = d2_messages.h d2_messages.cc
 nodist_libd2_la_SOURCES = d2_messages.h d2_messages.cc
@@ -93,6 +85,7 @@ kea_dhcp_ddns_SOURCES  = main.cc
 
 
 kea_dhcp_ddns_LDADD  = libd2.la
 kea_dhcp_ddns_LDADD  = libd2.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
+kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la

+ 1 - 160
src/bin/d2/d2.dox

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -29,165 +29,6 @@ already, its background color will be blue and/or its details may not be shown.
 sometimes through a small chain of typedefs.  These typedefs are shown for
 sometimes through a small chain of typedefs.  These typedefs are shown for
 accuracy but are unimportant to a general discussion.
 accuracy but are unimportant to a general discussion.
 
 
-
-@section d2CPL Controllable Process Layer (CPL)
-
-D2 is built upon an abstract set of classes referred to as the Controllable
-Process Layer or CPL.  This layer provides the essentials for a controllable,
-configurable, asynchronous process.  They are the result of an effort to
-distill the common facets of process control currently duplicated in Kea's
-DHCP servers into a reusable construct.  The classes which form this abstract
-base are shown in the following class diagram:
-
-@image html abstract_app_classes.svg  "Controllable Process Layer Classes"
-
-- isc::d2::DControllerBase - provides all of the services necessary to manage
-an application process class derived from isc::d2::DProcess. These services include:
-    - Command line argument handling
-    - Process instantiation and initialization
-    - Support for stand-alone execution
-    - Process event loop invocation and shutdown
-
-    It creates and manages an instance of isc::d2::DProcessBase.  The CPL is
-    designed for asynchronous event processing applications.  It is constructed
-    to use ASIO library for IO processing.  @c DControllerBase owns an
-    isc::asiolink::IOService instance and it passes this into the @c
-    DProcessBase constructor. It is this @c IOService that is used to drive the
-    process's event loop.  The controller is designed to provide any interfaces
-    between the process it controls and the outside world.
-
-    @c DControllerBase provides configuration for its process via a JSON file
-    specified as a mandatory command line argument. The file structure is
-    expected be as follows:
-
-    { "<module-name>": {<module-config>} }
-
-    where:
-        - module-name : is a label which uniquely identifies the
-        configuration data for the (i.e. the controlled process.)
-        It is the value returned by @ref
-        isc::d2::DControllerBase::getAppName()
-
-        - module-config: a set of zero or more JSON elements which comprise
-        application's configuration values.  Element syntax is governed
-        by those elements supported in isc::cc.
-
-    The file may contain an arbitrary number of other modules.
-
-    @todo Eventually, some sort of secure socket interface which supports remote
-    control operations such as configuration changes or status reporting will
-    likely be implemented.
-
-- isc::d2::DProcessBase - defines an asynchronous-event processor (i.e.
-application) which provides a uniform interface to:
-    - Instantiate and initialize a process instance
-    - "Run" the application by starting its event loop
-    - Inject events to control the process
-It owns an instance of @c DCfgMgrBase.
-
-- isc::d2::DCfgMgrBase - provides the mechanisms for managing an application's
-configuration.  This includes services for parsing sets of configuration
-values, storing the parsed information in its converted form, and retrieving
-the information on demand.  It owns an instance of @c DCfgContextBase, which
-provides a "global" context for information that is accessible before, during,
-and after parsing.
-
-- isc::d2::DCfgContextBase - implements a container for configuration
-information or "context".  It provides a single enclosure for the storage of
-configuration parameters or any other information that needs to accessible
-within a given context.
-
-The following sequence diagram shows how a configuration from file moves
-through the CPL layer:
-
-@image html config_from_file_sequence.svg "CPL Configuration From File Sequence"
-
-The CPL classes will likely move into a common library.
-
-@subsection cplSignals CPL Signal Handling
-
-CPL supports interaction with the outside world via OS signals. The default
-implementation supports the following signal driven behavior:
-- SIGHUP receipt of this signal will cause a reloading of the configuration
-file.
-- SIGINT/SIGTERM receipt of either of these signals will initiate an
-orderly shutdown.
-
-CPL applications wait for for process asynchronous IO events through
-isc::asiolink::IOService::run() or its variants.  These calls are not
-interrupted upon signal receipt as is the select() function and while
-boost::asio provides a signal mechanism it requires linking in additional
-libraries.  Therefore, CPL provides its own signal handling mechanism to
-propagate an OS signal such as SIGHUP to an IOSerivce as a ready event with a
-callback.
-
-isc::d2::DControllerBase uses two mechanisms to carry out signal handling.  It
-uses isc::util::SignalSet to catch OS signals, and isc::d2:IOSignalQueue to
-propagate them to its isc::asiolink::IOService as instances of
-isc::d2::IOSignal.
-
-This CPL signaling class hierarchy is illustrated in the following diagram:
-
-@image html cpl_signal_classes.svg "CPL Signal Classes"
-
-The mechanics of isc::d2::IOSignal are straight forward. Upon construction it
-is given the target isc::asiolink::IOService, the value of the OS signal to
-send (e.g. SIGINT, SIGHUP...), and an isc::d2::IOSignalHandler.  This handler
-should contain the logic the caller would normally execute in its OS signal
-handler. Each isc::d2::IOSignal instance has a unique identifier called its
-sequence_id.
-
-Internally, IOSignal creates a 1 ms, one-shot timer, on the given
-IOService.  When the timer expires its event handler invokes the caller's
-IOSignalHandler passing it the sequence_id of the IOSignal.
-
-Sending IOSignals is done through an isc::d2::IOSignalQueue.  This class is
-used to create the signals, house them until they are delivered, and dequeue
-them so they can be been handled.  To generate an IOSignal when an OS signal
-arrives, the process's OS signal handler need only call
-isc::d2::IOSignalQueue::pushSignal() with the appropriate values.
-
-To dequeue the IOSignal inside the caller's IOSignalHandler, one simply
-invokes isc::d2::IOSignalQueue::popSignal() passing it the sequence_id
-parameter passed to the handler.  This method returns a pointer to
-instigating IOSignal from which the value of OS signal (i.e. SIGINT,
-SIGUSR1...) can be obtained.  Note that calling popSignal() removes the
-IOSignalPtr from the queue, which should reduce its reference count to
-zero upon exiting the handler (unless a deliberate copy of it is made).
-
-A typical isc::d2::IOSignalHandler might be structured as follows:
-@code
-
-    void processSignal(IOSignalId sequence_id) {
-    // Pop the signal instance off the queue.
-    IOSignalPtr signal = io_signal_queue_->popSignal(sequence_id);
-
-    int os_signal_value = signal->getSignum();
-    :
-    // logic based on the signal value
-    :
-    }
-
-@endcode
-
-IOSignal's handler invocation code will catch, log ,and then swallow any
-exceptions thrown by an IOSignalHandler.  This is done to protect the integrity
-IOService context.
-
-CPL integrates the use of the two mechanisms by registering the method,
-isc::d2::DControllerBase::osSignalHandler(), as the
-isc::util::SignalSet::onreceipt_handler_.  This configures SignalSet's internal
-handler to invoke the method each time a signal arrives.  When invoked, this
-method will call isc::d2::IOSignalQueue::pushSignal() to create an
-isc::d2::IOSignal, passing in the OS signal received and
-isc::d2::DControllerBase::ioSignalHandler() to use as the IOSignal's
-ready event handler
-
-The following sequence diagram depicts the initialization of signal handling
-during startup and the subsequent receipt of a SIGHUP:
-
-@image html cpl_signal_sequence.svg "CPL Signal Handling Sequence"
-
 @section d2ProcessDerivation D2's CPL Derivations
 @section d2ProcessDerivation D2's CPL Derivations
 
 
 D2's core application classes are DDNS-specific derivations of the CPL as show
 D2's core application classes are DDNS-specific derivations of the CPL as show

+ 3 - 1
src/bin/d2/d2_cfg_mgr.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -12,6 +12,8 @@
 
 
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 
 
+using namespace isc::process;
+
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
 
 

+ 7 - 7
src/bin/d2/d2_cfg_mgr.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -10,8 +10,8 @@
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
 #include <cc/data.h>
 #include <cc/data.h>
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
-#include <d2/d_cfg_mgr.h>
 #include <d2/d2_config.h>
 #include <d2/d2_config.h>
+#include <process/d_cfg_mgr.h>
 
 
 #include <stdint.h>
 #include <stdint.h>
 #include <string>
 #include <string>
@@ -30,7 +30,7 @@ typedef boost::shared_ptr<D2CfgContext> D2CfgContextPtr;
 /// and any other DHCP-DDNS specific information that needs to be accessible
 /// and any other DHCP-DDNS specific information that needs to be accessible
 /// during configuration parsing as well as to the application as a whole.
 /// during configuration parsing as well as to the application as a whole.
 /// It is derived from the context base class, DCfgContextBase.
 /// It is derived from the context base class, DCfgContextBase.
-class D2CfgContext : public DCfgContextBase {
+class D2CfgContext : public process::DCfgContextBase {
 public:
 public:
     /// @brief Constructor
     /// @brief Constructor
     D2CfgContext();
     D2CfgContext();
@@ -41,8 +41,8 @@ public:
     /// @brief Creates a clone of this context object.
     /// @brief Creates a clone of this context object.
     ///
     ///
     /// @return returns a pointer to the new clone.
     /// @return returns a pointer to the new clone.
-    virtual DCfgContextBasePtr clone() {
-        return (DCfgContextBasePtr(new D2CfgContext(*this)));
+    virtual process::DCfgContextBasePtr clone() {
+        return (process::DCfgContextBasePtr(new D2CfgContext(*this)));
     }
     }
 
 
     /// @brief Fetches a reference to the D2Params
     /// @brief Fetches a reference to the D2Params
@@ -103,7 +103,7 @@ typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
 /// configuration.  This includes services for parsing sets of configuration
 /// configuration.  This includes services for parsing sets of configuration
 /// values, storing the parsed information in its converted form,
 /// values, storing the parsed information in its converted form,
 /// and retrieving the information on demand.
 /// and retrieving the information on demand.
-class D2CfgMgr : public DCfgMgrBase {
+class D2CfgMgr : public process::DCfgMgrBase {
 public:
 public:
     /// @brief Reverse zone suffix added to IPv4 addresses for reverse lookups
     /// @brief Reverse zone suffix added to IPv4 addresses for reverse lookups
     /// @todo This should be configurable.
     /// @todo This should be configurable.
@@ -294,7 +294,7 @@ protected:
     /// error.
     /// error.
     ///
     ///
     /// @return Returns a DCfgContextBasePtr to the new context instance.
     /// @return Returns a DCfgContextBasePtr to the new context instance.
-    virtual DCfgContextBasePtr createNewContext();
+    virtual process::DCfgContextBasePtr createNewContext();
 };
 };
 
 
 /// @brief Defines a shared pointer to D2CfgMgr.
 /// @brief Defines a shared pointer to D2CfgMgr.

+ 3 - 1
src/bin/d2/d2_config.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -20,6 +20,8 @@
 #include <sstream>
 #include <sstream>
 #include <string>
 #include <string>
 
 
+using namespace isc::process;
+
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
 
 

+ 5 - 5
src/bin/d2/d2_config.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9,10 +9,10 @@
 
 
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
 #include <cc/data.h>
 #include <cc/data.h>
-#include <d2/d_cfg_mgr.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dns/tsig.h>
 #include <dns/tsig.h>
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
+#include <process/d_cfg_mgr.h>
 
 
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 
 
@@ -701,7 +701,7 @@ typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
 ///
 ///
 /// This class implements a concrete version of the base class by supplying a
 /// This class implements a concrete version of the base class by supplying a
 /// "clone" method.
 /// "clone" method.
-class DScalarContext : public DCfgContextBase {
+class DScalarContext : public process::DCfgContextBase {
 public:
 public:
 
 
     /// @brief Constructor
     /// @brief Constructor
@@ -715,8 +715,8 @@ public:
     /// @brief Creates a clone of a DStubContext.
     /// @brief Creates a clone of a DStubContext.
     ///
     ///
     /// @return returns a pointer to the new clone.
     /// @return returns a pointer to the new clone.
-    virtual DCfgContextBasePtr clone() {
-        return (DCfgContextBasePtr(new DScalarContext(*this)));
+    virtual process::DCfgContextBasePtr clone() {
+        return (process::DCfgContextBasePtr(new DScalarContext(*this)));
     }
     }
 
 
 protected:
 protected:

+ 4 - 2
src/bin/d2/d2_controller.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,10 +8,12 @@
 
 
 #include <d2/d2_controller.h>
 #include <d2/d2_controller.h>
 #include <d2/d2_process.h>
 #include <d2/d2_process.h>
-#include <d2/spec_config.h>
+#include <process/spec_config.h>
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 
 
+using namespace isc::process;
+
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
 
 

+ 5 - 5
src/bin/d2/d2_controller.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,7 +7,7 @@
 #ifndef D2_CONTROLLER_H
 #ifndef D2_CONTROLLER_H
 #define D2_CONTROLLER_H
 #define D2_CONTROLLER_H
 
 
-#include <d2/d_controller.h>
+#include <process/d_controller.h>
 
 
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
@@ -22,14 +22,14 @@ namespace d2 {
 /// DControllerBase a templated class but the labor savings versus the
 /// DControllerBase a templated class but the labor savings versus the
 /// potential number of virtual methods which may be overridden didn't seem
 /// potential number of virtual methods which may be overridden didn't seem
 /// worth the clutter at this point.
 /// worth the clutter at this point.
-class D2Controller : public DControllerBase {
+class D2Controller : public process::DControllerBase {
 public:
 public:
     /// @brief Static singleton instance method. This method returns the
     /// @brief Static singleton instance method. This method returns the
     /// base class singleton instance member.  It instantiates the singleton
     /// base class singleton instance member.  It instantiates the singleton
     /// and sets the base class instance member upon first invocation.
     /// and sets the base class instance member upon first invocation.
     ///
     ///
     /// @return returns the pointer reference to the singleton instance.
     /// @return returns the pointer reference to the singleton instance.
-    static DControllerBasePtr& instance();
+    static process::DControllerBasePtr& instance();
 
 
     /// @brief Destructor.
     /// @brief Destructor.
     virtual ~D2Controller();
     virtual ~D2Controller();
@@ -51,7 +51,7 @@ private:
     /// Note the caller is responsible for destructing the process. This
     /// Note the caller is responsible for destructing the process. This
     /// is handled by the base class, which wraps this pointer with a smart
     /// is handled by the base class, which wraps this pointer with a smart
     /// pointer.
     /// pointer.
-    virtual DProcessBase* createProcess();
+    virtual process::DProcessBase* createProcess();
 
 
     /// @brief Constructor is declared private to maintain the integrity of
     /// @brief Constructor is declared private to maintain the integrity of
     /// the singleton instance.
     /// the singleton instance.

+ 2 - 2
src/bin/d2/d2_log.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -12,7 +12,7 @@ namespace isc {
 namespace d2 {
 namespace d2 {
 
 
 /// @brief Defines the logger used within D2.
 /// @brief Defines the logger used within D2.
-isc::log::Logger dctl_logger("dhcpddns");
+isc::log::Logger d2_logger("dhcpddns");
 isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2");
 isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2");
 isc::log::Logger d2_to_dns_logger("d2-to-dns");
 isc::log::Logger d2_to_dns_logger("d2-to-dns");
 
 

+ 1 - 1
src/bin/d2/d2_log.h

@@ -15,7 +15,7 @@ namespace isc {
 namespace d2 {
 namespace d2 {
 
 
 /// Define the loggers for the "d2" logging.
 /// Define the loggers for the "d2" logging.
-extern isc::log::Logger dctl_logger;
+extern isc::log::Logger d2_logger;
 extern isc::log::Logger dhcp_to_d2_logger;
 extern isc::log::Logger dhcp_to_d2_logger;
 extern isc::log::Logger d2_to_dns_logger;
 extern isc::log::Logger d2_to_dns_logger;
 
 

+ 1 - 121
src/bin/d2/d2_messages.mes

@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 #
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -6,83 +6,6 @@
 
 
 $NAMESPACE isc::d2
 $NAMESPACE isc::d2
 
 
-% DCTL_CCSESSION_ENDING %1 ending control channel session
-This debug message is issued just before the controller attempts
-to disconnect from its session with the Kea control channel.
-
-% DCTL_CCSESSION_STARTING %1 starting control channel session, specfile: %2
-This debug message is issued just before the controller attempts
-to establish a session with the Kea control channel.
-
-% DCTL_COMMAND_RECEIVED %1 received command: %2, arguments: %3
-A debug message listing the command (and possible arguments) received
-from the Kea control system by the controller.
-
-% DCTL_CONFIG_COMPLETE server has completed configuration: %1
-This is an informational message announcing the successful processing of a
-new configuration. It is output during server startup, and when an updated
-configuration is committed by the administrator.  Additional information
-may be provided.
-
-% DCTL_CONFIG_FILE_LOAD_FAIL %1 reason: %2
-This fatal error message indicates that the application attempted to load its
-initial configuration from file and has failed. The service will exit.
-
-% DCTL_CONFIG_LOAD_FAIL %1 configuration failed to load: %2
-This critical error message indicates that the initial application
-configuration has failed. The service will start, but will not
-process requests until the configuration has been corrected.
-
-% DCTL_CONFIG_START parsing new configuration: %1
-A debug message indicating that the application process has received an
-updated configuration and has passed it to its configuration manager
-for parsing.
-
-% DCTL_CONFIG_STUB %1 configuration stub handler called
-This debug message is issued when the dummy handler for configuration
-events is called.  This only happens during initial startup.
-
-% DCTL_CONFIG_UPDATE %1 updated configuration received: %2
-A debug message indicating that the controller has received an
-updated configuration from the Kea configuration system.
-
-% DCTL_INIT_PROCESS %1 initializing the application
-This debug message is issued just before the controller attempts
-to create and initialize its application instance.
-
-% DCTL_INIT_PROCESS_FAIL %1 application initialization failed: %2
-This error message is issued if the controller could not initialize the
-application and will exit.
-
-% DCTL_NOT_RUNNING %1 application instance is not running
-A warning message is issued when an attempt is made to shut down the
-application when it is not running.
-
-% DCTL_PARSER_FAIL : %1
-On receipt of a new configuration, the server failed to create a parser to
-decode the contents of the named configuration element, or the creation
-succeeded but the parsing actions and committal of changes failed.
-The reason for the failure is given in the message.
-
-% DCTL_PROCESS_FAILED %1 application execution failed: %2
-The controller has encountered a fatal error while running the
-application and is terminating. The reason for the failure is
-included in the message.
-
-% DCTL_RUN_PROCESS %1 starting application event loop
-This debug message is issued just before the controller invokes
-the application run method.
-
-% DCTL_SESSION_FAIL %1 controller failed to establish Kea session: %1
-The controller has failed to establish communication with the rest of
-Kea and will exit.
-
-% DCTL_STANDALONE %1 skipping message queue, running standalone
-This is a debug message indicating that the controller is running in the
-application in standalone mode. This means it will not connected to the Kea
-message queue. Standalone mode is only useful during program development,
-and should not be used in a production environment.
-
 % DHCP_DDNS_ADD_FAILED DHCP_DDNS Request ID %1: Transaction outcome %2
 % DHCP_DDNS_ADD_FAILED DHCP_DDNS Request ID %1: Transaction outcome %2
 This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
 This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
 entry additions have failed.  The precise reason for the failure should be
 entry additions have failed.  The precise reason for the failure should be
@@ -106,16 +29,6 @@ the DHCP_DDNS process name, the second contains the PID and PID file.
 This is a debug message that indicates that the application has DHCP_DDNS
 This is a debug message that indicates that the application has DHCP_DDNS
 requests in the queue but is working as many concurrent requests as allowed.
 requests in the queue but is working as many concurrent requests as allowed.
 
 
-% DHCP_DDNS_CFG_FILE_RELOAD_ERROR configuration reload failed: %1, reverting to current configuration.
-This is an error message indicating that the application attempted to reload
-its configuration from file and encountered an error.  This is likely due to
-invalid content in the configuration file.  The application should continue
-to operate under its current configuration.
-
-% DHCP_DDNS_CFG_FILE_RELOAD_SIGNAL_RECVD OS signal %1 received, reloading configuration from file: %2
-This is an informational message indicating the application has received a signal
-instructing it to reload its configuration from file.
-
 % DHCP_DDNS_CLEARED_FOR_SHUTDOWN application has met shutdown criteria for shutdown type: %1
 % DHCP_DDNS_CLEARED_FOR_SHUTDOWN application has met shutdown criteria for shutdown type: %1
 This is a debug message issued when the application has been instructed
 This is a debug message issued when the application has been instructed
 to shutdown and has met the required criteria to exit.
 to shutdown and has met the required criteria to exit.
@@ -280,15 +193,6 @@ no configured DDNS domains in the DHCP_DDNS configuration.  Either the DHCP_DDNS
 configuration needs to be updated or the source of the FQDN itself should be
 configuration needs to be updated or the source of the FQDN itself should be
 investigated.
 investigated.
 
 
-% DHCP_DDNS_PID_FILE_ERROR %1 could not create a PID file: %2
-This is an error message that occurs when DHCP_DDNS is unable to create
-its PID file.  The log message should contain details sufficient to
-determine the underlying cause.  The most likely culprits are that
-some portion of the pathname does not exist or a permissions issue. The
-default path is determined by --localstatedir configure parameter but
-may be overridden by setting environment variable, KEA_PIDFILE_DIR.  The
-first argument is the DHCP_DDNS process name.
-
 % DHCP_DDNS_PROCESS_INIT application init invoked
 % DHCP_DDNS_PROCESS_INIT application init invoked
 This is a debug message issued when the DHCP-DDNS application enters
 This is a debug message issued when the DHCP-DDNS application enters
 its initialization method.
 its initialization method.
@@ -448,33 +352,15 @@ reverse update will not performed.
 This is a debug message issued when the DHCP-DDNS server exits its
 This is a debug message issued when the DHCP-DDNS server exits its
 event lo
 event lo
 
 
-% DHCP_DDNS_SHUTDOWN DHCP-DDNS has shut down
-This is an informational message indicating that the DHCP-DDNS service
-has shut down.
-
 % DHCP_DDNS_SHUTDOWN_COMMAND application received shutdown command with args: %1
 % DHCP_DDNS_SHUTDOWN_COMMAND application received shutdown command with args: %1
 This is a debug message issued when the application has been instructed
 This is a debug message issued when the application has been instructed
 to shut down by the controller.
 to shut down by the controller.
 
 
-% DHCP_DDNS_SHUTDOWN_SIGNAL_RECVD OS signal %1 received, starting shutdown
-This is a debug message indicating the application has received a signal
-instructing it to shutdown.
-
-% DHCP_DDNS_SIGNAL_ERROR signal handler for signal %1, threw an unexpected exception: %2
-This is an error message indicating that the application encountered an unexpected
-error after receiving a signal.  This is a programmatic error and should be
-reported.  While The application will likely continue to operating, it may be
-unable to respond correctly to signals.
-
 % DHCP_DDNS_STARTED Kea DHCP-DDNS server version %1 started
 % DHCP_DDNS_STARTED Kea DHCP-DDNS server version %1 started
 This informational message indicates that the DHCP-DDNS server has
 This informational message indicates that the DHCP-DDNS server has
 processed all configuration information and is ready to begin processing.
 processed all configuration information and is ready to begin processing.
 The version is also printed.
 The version is also printed.
 
 
-% DHCP_DDNS_STARTING DHCP-DDNS starting, pid: %1, version: %2
-This is an informational message issued when controller for the
-service first starts. Version is also reported.
-
 % DHCP_DDNS_STARTING_TRANSACTION Request ID %1:
 % DHCP_DDNS_STARTING_TRANSACTION Request ID %1:
 This is a debug message issued when DHCP-DDNS has begun a transaction for
 This is a debug message issued when DHCP-DDNS has begun a transaction for
 a given request.
 a given request.
@@ -491,12 +377,6 @@ message but the attempt to send it suffered an unexpected error. This is most
 likely a programmatic error, rather than a communications issue. Some or all
 likely a programmatic error, rather than a communications issue. Some or all
 of the DNS updates requested as part of this request did not succeed.
 of the DNS updates requested as part of this request did not succeed.
 
 
-% DHCP_DDNS_UNSUPPORTED_SIGNAL ignoring reception of unsupported signal: %1
-This is a debug message indicating that the application received an
-unsupported signal.  This is a programming error indicating that the
-application has registered to receive the signal but no associated
-processing logic has been added.
-
 % DHCP_DDNS_UPDATE_REQUEST_SENT Request ID %1: %2 to server: %3
 % DHCP_DDNS_UPDATE_REQUEST_SENT Request ID %1: %2 to server: %3
 This is a debug message issued when DHCP_DDNS sends a DNS request to a DNS
 This is a debug message issued when DHCP_DDNS sends a DNS request to a DNS
 server.
 server.

+ 17 - 15
src/bin/d2/d2_process.cc

@@ -11,6 +11,8 @@
 #include <d2/d2_cfg_mgr.h>
 #include <d2/d2_cfg_mgr.h>
 #include <d2/d2_process.h>
 #include <d2/d2_process.h>
 
 
+using namespace isc::process;
+
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
 
 
@@ -42,7 +44,7 @@ D2Process::init() {
 
 
 void
 void
 D2Process::run() {
 D2Process::run() {
-    LOG_INFO(dctl_logger, DHCP_DDNS_STARTED).arg(VERSION);
+    LOG_INFO(d2_logger, DHCP_DDNS_STARTED).arg(VERSION);
     // Loop forever until we are allowed to shutdown.
     // Loop forever until we are allowed to shutdown.
     while (!canShutdown()) {
     while (!canShutdown()) {
         try {
         try {
@@ -68,7 +70,7 @@ D2Process::run() {
                           "Primary IO service stopped unexpectedly");
                           "Primary IO service stopped unexpectedly");
             }
             }
         } catch (const std::exception& ex) {
         } catch (const std::exception& ex) {
-            LOG_FATAL(dctl_logger, DHCP_DDNS_FAILED).arg(ex.what());
+            LOG_FATAL(d2_logger, DHCP_DDNS_FAILED).arg(ex.what());
             isc_throw (DProcessBaseError,
             isc_throw (DProcessBaseError,
                        "Process run method failed: " << ex.what());
                        "Process run method failed: " << ex.what());
         }
         }
@@ -78,7 +80,7 @@ D2Process::run() {
     // this might be the place to do it, once there is a persistence mgr.
     // this might be the place to do it, once there is a persistence mgr.
     // This may also be better in checkQueueStatus.
     // This may also be better in checkQueueStatus.
 
 
-    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DHCP_DDNS_RUN_EXIT);
+    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, DHCP_DDNS_RUN_EXIT);
 
 
 };
 };
 
 
@@ -145,7 +147,7 @@ D2Process::canShutdown() const {
         }
         }
 
 
         if (all_clear) {
         if (all_clear) {
-            LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT,
+            LOG_DEBUG(d2_logger, DBGLVL_START_SHUT,
                      DHCP_DDNS_CLEARED_FOR_SHUTDOWN)
                      DHCP_DDNS_CLEARED_FOR_SHUTDOWN)
                      .arg(getShutdownTypeStr(shutdown_type_));
                      .arg(getShutdownTypeStr(shutdown_type_));
         }
         }
@@ -156,7 +158,7 @@ D2Process::canShutdown() const {
 
 
 isc::data::ConstElementPtr
 isc::data::ConstElementPtr
 D2Process::shutdown(isc::data::ConstElementPtr args) {
 D2Process::shutdown(isc::data::ConstElementPtr args) {
-    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DHCP_DDNS_SHUTDOWN_COMMAND)
+    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, DHCP_DDNS_SHUTDOWN_COMMAND)
               .arg(args ? args->str() : "(no arguments)");
               .arg(args ? args->str() : "(no arguments)");
 
 
     // Default shutdown type is normal.
     // Default shutdown type is normal.
@@ -190,7 +192,7 @@ D2Process::shutdown(isc::data::ConstElementPtr args) {
 
 
 isc::data::ConstElementPtr
 isc::data::ConstElementPtr
 D2Process::configure(isc::data::ConstElementPtr config_set) {
 D2Process::configure(isc::data::ConstElementPtr config_set) {
-    LOG_DEBUG(dctl_logger, DBGLVL_TRACE_BASIC,
+    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC,
               DHCP_DDNS_CONFIGURE).arg(config_set->str());
               DHCP_DDNS_CONFIGURE).arg(config_set->str());
 
 
     int rcode = 0;
     int rcode = 0;
@@ -235,7 +237,7 @@ D2Process::checkQueueStatus() {
             // canceling active listening which may generate an IO event, so
             // canceling active listening which may generate an IO event, so
             // instigate the stop and get out.
             // instigate the stop and get out.
             try {
             try {
-                LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT,
+                LOG_DEBUG(d2_logger, DBGLVL_START_SHUT,
                           DHCP_DDNS_QUEUE_MGR_STOPPING)
                           DHCP_DDNS_QUEUE_MGR_STOPPING)
                          .arg(reconf_queue_flag_ ? "reconfiguration"
                          .arg(reconf_queue_flag_ ? "reconfiguration"
                                                  : "shutdown");
                                                  : "shutdown");
@@ -243,7 +245,7 @@ D2Process::checkQueueStatus() {
             } catch (const isc::Exception& ex) {
             } catch (const isc::Exception& ex) {
                 // It is very unlikey that we would experience an error
                 // It is very unlikey that we would experience an error
                 // here, but theoretically possible.
                 // here, but theoretically possible.
-                LOG_ERROR(dctl_logger, DHCP_DDNS_QUEUE_MGR_STOP_ERROR)
+                LOG_ERROR(d2_logger, DHCP_DDNS_QUEUE_MGR_STOP_ERROR)
                           .arg(ex.what());
                           .arg(ex.what());
             }
             }
         }
         }
@@ -256,12 +258,12 @@ D2Process::checkQueueStatus() {
             size_t threshold = (((queue_mgr_->getMaxQueueSize()
             size_t threshold = (((queue_mgr_->getMaxQueueSize()
                                 * QUEUE_RESTART_PERCENT)) / 100);
                                 * QUEUE_RESTART_PERCENT)) / 100);
             if (queue_mgr_->getQueueSize() <= threshold) {
             if (queue_mgr_->getQueueSize() <= threshold) {
-                LOG_INFO (dctl_logger, DHCP_DDNS_QUEUE_MGR_RESUMING)
+                LOG_INFO (d2_logger, DHCP_DDNS_QUEUE_MGR_RESUMING)
                           .arg(threshold).arg(queue_mgr_->getMaxQueueSize());
                           .arg(threshold).arg(queue_mgr_->getMaxQueueSize());
                 try {
                 try {
                     queue_mgr_->startListening();
                     queue_mgr_->startListening();
                 } catch (const isc::Exception& ex) {
                 } catch (const isc::Exception& ex) {
-                    LOG_ERROR(dctl_logger, DHCP_DDNS_QUEUE_MGR_RESUME_ERROR)
+                    LOG_ERROR(d2_logger, DHCP_DDNS_QUEUE_MGR_RESUME_ERROR)
                               .arg(ex.what());
                               .arg(ex.what());
                 }
                 }
             }
             }
@@ -278,7 +280,7 @@ D2Process::checkQueueStatus() {
         // to keep from endlessly retrying over and over, with little time
         // to keep from endlessly retrying over and over, with little time
         // in between.
         // in between.
         if (!shouldShutdown()) {
         if (!shouldShutdown()) {
-            LOG_INFO (dctl_logger, DHCP_DDNS_QUEUE_MGR_RECOVERING);
+            LOG_INFO (d2_logger, DHCP_DDNS_QUEUE_MGR_RECOVERING);
             reconfigureQueueMgr();
             reconfigureQueueMgr();
         }
         }
         break;
         break;
@@ -295,7 +297,7 @@ D2Process::checkQueueStatus() {
         // we can do the reconfigure. In other words, we aren't RUNNING or
         // we can do the reconfigure. In other words, we aren't RUNNING or
         // STOPPING.
         // STOPPING.
         if (reconf_queue_flag_) {
         if (reconf_queue_flag_) {
-            LOG_DEBUG(dctl_logger, DBGLVL_TRACE_BASIC,
+            LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC,
                       DHCP_DDNS_QUEUE_MGR_RECONFIGURING);
                       DHCP_DDNS_QUEUE_MGR_RECONFIGURING);
             reconfigureQueueMgr();
             reconfigureQueueMgr();
         }
         }
@@ -326,7 +328,7 @@ D2Process::reconfigureQueueMgr() {
         /// @todo Remove this once we provide a secure mechanism.
         /// @todo Remove this once we provide a secure mechanism.
         std::string ip_address =  d2_params->getIpAddress().toText();
         std::string ip_address =  d2_params->getIpAddress().toText();
         if (ip_address != "127.0.0.1" && ip_address != "::1") {
         if (ip_address != "127.0.0.1" && ip_address != "::1") {
-            LOG_WARN(dctl_logger, DHCP_DDNS_NOT_ON_LOOPBACK).arg(ip_address);
+            LOG_WARN(d2_logger, DHCP_DDNS_NOT_ON_LOOPBACK).arg(ip_address);
         }
         }
 
 
         // Instantiate the listener.
         // Instantiate the listener.
@@ -350,7 +352,7 @@ D2Process::reconfigureQueueMgr() {
         // Queue manager failed to initialize and therefore not listening.
         // Queue manager failed to initialize and therefore not listening.
         // This is most likely due to an unavailable IP address or port,
         // This is most likely due to an unavailable IP address or port,
         // which is a configuration issue.
         // which is a configuration issue.
-        LOG_ERROR(dctl_logger, DHCP_DDNS_QUEUE_MGR_START_ERROR).arg(ex.what());
+        LOG_ERROR(d2_logger, DHCP_DDNS_QUEUE_MGR_START_ERROR).arg(ex.what());
     }
     }
 }
 }
 
 
@@ -360,7 +362,7 @@ D2Process::command(const std::string& command,
     // @todo This is the initial implementation.  If and when D2 is extended
     // @todo This is the initial implementation.  If and when D2 is extended
     // to support its own commands, this implementation must change. Otherwise
     // to support its own commands, this implementation must change. Otherwise
     // it should reject all commands as it does now.
     // it should reject all commands as it does now.
-    LOG_DEBUG(dctl_logger, DBGLVL_TRACE_BASIC, DHCP_DDNS_COMMAND)
+    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC, DHCP_DDNS_COMMAND)
         .arg(command).arg(args ? args->str() : "(no args)");
         .arg(command).arg(args ? args->str() : "(no args)");
 
 
     return (isc::config::createAnswer(COMMAND_INVALID, "Unrecognized command: "
     return (isc::config::createAnswer(COMMAND_INVALID, "Unrecognized command: "

+ 3 - 3
src/bin/d2/d2_process.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,9 +7,9 @@
 #ifndef D2_PROCESS_H
 #ifndef D2_PROCESS_H
 #define D2_PROCESS_H
 #define D2_PROCESS_H
 
 
-#include <d2/d_process.h>
 #include <d2/d2_queue_mgr.h>
 #include <d2/d2_queue_mgr.h>
 #include <d2/d2_update_mgr.h>
 #include <d2/d2_update_mgr.h>
+#include <process/d_process.h>
 
 
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
@@ -21,7 +21,7 @@ namespace d2 {
 /// to receive DNS mapping change requests and carry them out.
 /// to receive DNS mapping change requests and carry them out.
 /// It implements the DProcessBase interface, which structures it such that it
 /// It implements the DProcessBase interface, which structures it such that it
 /// is a managed "application", controlled by a management layer.
 /// is a managed "application", controlled by a management layer.
-class D2Process : public DProcessBase {
+class D2Process : public process::DProcessBase {
 public:
 public:
 
 
     /// @brief Defines the shutdown types supported by D2Process
     /// @brief Defines the shutdown types supported by D2Process

+ 3 - 3
src/bin/d2/d2_queue_mgr.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -137,7 +137,7 @@ D2QueueMgr::startListening() {
                   << ex.what());
                   << ex.what());
     }
     }
 
 
-    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DHCP_DDNS_QUEUE_MGR_STARTED);
+    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, DHCP_DDNS_QUEUE_MGR_STARTED);
 }
 }
 
 
 void
 void
@@ -172,7 +172,7 @@ D2QueueMgr::stopListening(const State target_stop_state) {
 void
 void
 D2QueueMgr::updateStopState() {
 D2QueueMgr::updateStopState() {
     mgr_state_ = target_stop_state_;
     mgr_state_ = target_stop_state_;
-    LOG_DEBUG(dctl_logger, DBGLVL_TRACE_BASIC, DHCP_DDNS_QUEUE_MGR_STOPPED);
+    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC, DHCP_DDNS_QUEUE_MGR_STOPPED);
 }
 }
 
 
 
 

+ 1 - 0
src/bin/d2/main.cc

@@ -14,6 +14,7 @@
 #include <iostream>
 #include <iostream>
 
 
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::process;
 using namespace std;
 using namespace std;
 
 
 /// This file contains entry point (main() function) for standard DHCP-DDNS
 /// This file contains entry point (main() function) for standard DHCP-DDNS

+ 3 - 6
src/bin/d2/tests/Makefile.am

@@ -42,26 +42,21 @@ if HAVE_GTEST
 
 
 TESTS += d2_unittests
 TESTS += d2_unittests
 
 
-d2_unittests_SOURCES = d_test_stubs.cc d_test_stubs.h
-d2_unittests_SOURCES += d2_unittests.cc
+d2_unittests_SOURCES  = d2_unittests.cc
 d2_unittests_SOURCES += d2_process_unittests.cc
 d2_unittests_SOURCES += d2_process_unittests.cc
-d2_unittests_SOURCES += d_cfg_mgr_unittests.cc
 d2_unittests_SOURCES += d2_cfg_mgr_unittests.cc
 d2_unittests_SOURCES += d2_cfg_mgr_unittests.cc
 d2_unittests_SOURCES += d2_queue_mgr_unittests.cc
 d2_unittests_SOURCES += d2_queue_mgr_unittests.cc
 d2_unittests_SOURCES += d2_update_message_unittests.cc
 d2_unittests_SOURCES += d2_update_message_unittests.cc
 d2_unittests_SOURCES += d2_update_mgr_unittests.cc
 d2_unittests_SOURCES += d2_update_mgr_unittests.cc
 d2_unittests_SOURCES += d2_zone_unittests.cc
 d2_unittests_SOURCES += d2_zone_unittests.cc
 d2_unittests_SOURCES += dns_client_unittests.cc
 d2_unittests_SOURCES += dns_client_unittests.cc
-d2_unittests_SOURCES += io_service_signal_unittests.cc
 d2_unittests_SOURCES += labeled_value_unittests.cc
 d2_unittests_SOURCES += labeled_value_unittests.cc
 d2_unittests_SOURCES += nc_add_unittests.cc
 d2_unittests_SOURCES += nc_add_unittests.cc
 d2_unittests_SOURCES += nc_remove_unittests.cc
 d2_unittests_SOURCES += nc_remove_unittests.cc
 d2_unittests_SOURCES += nc_test_utils.cc nc_test_utils.h
 d2_unittests_SOURCES += nc_test_utils.cc nc_test_utils.h
 d2_unittests_SOURCES += nc_trans_unittests.cc
 d2_unittests_SOURCES += nc_trans_unittests.cc
 d2_unittests_SOURCES += state_model_unittests.cc
 d2_unittests_SOURCES += state_model_unittests.cc
-
 d2_unittests_SOURCES += d2_controller_unittests.cc
 d2_unittests_SOURCES += d2_controller_unittests.cc
-d2_unittests_SOURCES += d_controller_unittests.cc
 
 
 d2_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 d2_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 d2_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
 d2_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
@@ -77,7 +72,9 @@ endif
 d2_unittests_LDFLAGS += $(GTEST_LDFLAGS)
 d2_unittests_LDFLAGS += $(GTEST_LDFLAGS)
 
 
 d2_unittests_LDADD = $(top_builddir)/src/bin/d2/libd2.la
 d2_unittests_LDADD = $(top_builddir)/src/bin/d2/libd2.la
+d2_unittests_LDADD += $(top_builddir)/src/lib/process/testutils/libprocesstest.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
+d2_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
 d2_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la

+ 3 - 2
src/bin/d2/tests/d2_cfg_mgr_unittests.cc

@@ -9,10 +9,10 @@
 #include <config/module_spec.h>
 #include <config/module_spec.h>
 #include <d2/d2_config.h>
 #include <d2/d2_config.h>
 #include <d2/d2_cfg_mgr.h>
 #include <d2/d2_cfg_mgr.h>
-#include <d_test_stubs.h>
+#include <dhcpsrv/testutils/config_result_check.h>
+#include <process/testutils/d_test_stubs.h>
 #include <test_data_files_config.h>
 #include <test_data_files_config.h>
 #include <util/encode/base64.h>
 #include <util/encode/base64.h>
-#include <dhcpsrv/testutils/config_result_check.h>
 
 
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/scoped_ptr.hpp>
@@ -21,6 +21,7 @@
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::process;
 
 
 namespace {
 namespace {
 
 

+ 5 - 4
src/bin/d2/tests/d2_controller_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,10 +7,10 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
-#include <d_test_stubs.h>
 #include <d2/d2_controller.h>
 #include <d2/d2_controller.h>
 #include <d2/d2_process.h>
 #include <d2/d2_process.h>
-#include <d2/spec_config.h>
+#include <process/spec_config.h>
+#include <process/testutils/d_test_stubs.h>
 
 
 #include <boost/pointer_cast.hpp>
 #include <boost/pointer_cast.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -18,6 +18,7 @@
 
 
 #include <sstream>
 #include <sstream>
 
 
+using namespace isc::process;
 using namespace boost::posix_time;
 using namespace boost::posix_time;
 
 
 namespace isc {
 namespace isc {
@@ -232,7 +233,7 @@ TEST_F(D2ControllerTest, invalidConfigReload) {
 
 
     // Context is still available post launch.
     // Context is still available post launch.
     // Check to see that our configuration matches the original per
     // Check to see that our configuration matches the original per
-    // valid_d2_config (see d_test_stubs.cc)
+    // valid_d2_config (see src/lib/process/testutils/d_test_stubs.cc)
     D2CfgMgrPtr d2_cfg_mgr = getD2CfgMgr();
     D2CfgMgrPtr d2_cfg_mgr = getD2CfgMgr();
     D2ParamsPtr d2_params = d2_cfg_mgr->getD2Params();
     D2ParamsPtr d2_params = d2_cfg_mgr->getD2Params();
     ASSERT_TRUE(d2_params);
     ASSERT_TRUE(d2_params);

+ 4 - 4
src/bin/d2/tests/d2_process_tests.sh.in

@@ -115,7 +115,7 @@ dynamic_reconfiguration_test() {
     send_signal 1 ${bin}
     send_signal 1 ${bin}
 
 
     # Wait up to 10s for the D2Controller to log reload signal received.
     # Wait up to 10s for the D2Controller to log reload signal received.
-    wait_for_message 10 "DHCP_DDNS_CFG_FILE_RELOAD_SIGNAL_RECVD"  1
+    wait_for_message 10 "DCTL_CFG_FILE_RELOAD_SIGNAL_RECVD"  1
     if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
     if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
         printf "ERROR: D2 did report the reload signal receipt.\n"
         printf "ERROR: D2 did report the reload signal receipt.\n"
         clean_exit 1
         clean_exit 1
@@ -124,7 +124,7 @@ dynamic_reconfiguration_test() {
     # After receiving SIGHUP the server should try to reconfigure itself.
     # After receiving SIGHUP the server should try to reconfigure itself.
     # The configuration provided is invalid so it should result in
     # The configuration provided is invalid so it should result in
     # reconfiguration failure but the server should still be running.
     # reconfiguration failure but the server should still be running.
-    wait_for_message 10 "DHCP_DDNS_CFG_FILE_RELOAD_ERROR" 1
+    wait_for_message 10 "DCTL_CFG_FILE_RELOAD_ERROR" 1
     if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
     if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
         printf "ERROR: D2 did not report reload error.\n"
         printf "ERROR: D2 did not report reload error.\n"
         clean_exit 1
         clean_exit 1
@@ -213,7 +213,7 @@ shutdown_test() {
     send_signal ${signum} ${bin}
     send_signal ${signum} ${bin}
 
 
     # Now wait for process to log that it is exiting.
     # Now wait for process to log that it is exiting.
-    wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
+    wait_for_message 10 "DCTL_SHUTDOWN" 1
     if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
     if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
         printf "ERROR: DHCP-DDNS did not log shutdown.\n"
         printf "ERROR: DHCP-DDNS did not log shutdown.\n"
         clean_exit 1
         clean_exit 1
@@ -227,7 +227,7 @@ shutdown_test() {
     test_finish 0
     test_finish 0
 }
 }
 
 
-server_pid_file_test "${CONFIG}" DHCP_DDNS_ALREADY_RUNNING
+server_pid_file_test "${CONFIG}" DCTL_ALREADY_RUNNING
 dynamic_reconfiguration_test
 dynamic_reconfiguration_test
 shutdown_test "dhcp-ddns.sigterm_test" 15
 shutdown_test "dhcp-ddns.sigterm_test" 15
 shutdown_test "dhcp-ddns.sigint_test" 2
 shutdown_test "dhcp-ddns.sigint_test" 2

+ 3 - 2
src/bin/d2/tests/d2_process_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -10,7 +10,7 @@
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
 #include <d2/d2_process.h>
 #include <d2/d2_process.h>
 #include <dhcp_ddns/ncr_io.h>
 #include <dhcp_ddns/ncr_io.h>
-#include <d_test_stubs.h>
+#include <process/testutils/d_test_stubs.h>
 
 
 #include <boost/bind.hpp>
 #include <boost/bind.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -22,6 +22,7 @@ using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::config;
 using namespace isc::config;
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::process;
 using namespace boost::posix_time;
 using namespace boost::posix_time;
 
 
 namespace {
 namespace {

+ 4 - 3
src/bin/d2/tests/d2_update_mgr_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,9 +8,9 @@
 
 
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
 #include <d2/d2_update_mgr.h>
 #include <d2/d2_update_mgr.h>
-#include <util/time_utilities.h>
-#include <d_test_stubs.h>
 #include <nc_test_utils.h>
 #include <nc_test_utils.h>
+#include <process/testutils/d_test_stubs.h>
+#include <util/time_utilities.h>
 
 
 #include <boost/function.hpp>
 #include <boost/function.hpp>
 #include <boost/bind.hpp>
 #include <boost/bind.hpp>
@@ -23,6 +23,7 @@ using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::dhcp_ddns;
 using namespace isc::dhcp_ddns;
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::process;
 
 
 namespace {
 namespace {
 
 

+ 5 - 5
src/bin/keactrl/tests/keactrl_tests.sh.in

@@ -211,7 +211,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
 
     # Wait up to 10s for the D2 server to stop.
     # Wait up to 10s for the D2 server to stop.
-    wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
+    wait_for_message 10 "DCTL_SHUTDOWN" 1
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to shutdown. \
         "Timeout waiting for ${d2_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
@@ -315,7 +315,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
 
     # Wait up to 10s for the D2 server to stop.
     # Wait up to 10s for the D2 server to stop.
-    wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
+    wait_for_message 10 "DCTL_SHUTDOWN" 1
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to shutdown. \
         "Timeout waiting for ${d2_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
@@ -627,7 +627,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
 
     # Wait up to 10s for the D2 server to stop.
     # Wait up to 10s for the D2 server to stop.
-    wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
+    wait_for_message 10 "DCTL_SHUTDOWN" 1
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to shutdown. \
         "Timeout waiting for ${d2_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
@@ -781,7 +781,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
 
     # Wait up to 10s for the d2 server to stop.
     # Wait up to 10s for the d2 server to stop.
-    wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
+    wait_for_message 10 "DCTL_SHUTDOWN" 1
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to shutdown. \
         "Timeout waiting for ${d2_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
@@ -920,7 +920,7 @@ Expected wait_for_message return %d, returned %d."
     assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
     assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
 
 
     # Wait up to 10s for the D2 server to stop.
     # Wait up to 10s for the D2 server to stop.
-    wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
+    wait_for_message 10 "DCTL_SHUTDOWN" 1
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to shutdown. \
         "Timeout waiting for ${d2_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."

+ 1 - 1
src/lib/Makefile.am

@@ -1,3 +1,3 @@
 # The following build order must be maintained.
 # The following build order must be maintained.
 SUBDIRS = exceptions util log cryptolink dns cc hooks asiolink testutils dhcp config \
 SUBDIRS = exceptions util log cryptolink dns cc hooks asiolink testutils dhcp config \
-	      stats asiodns dhcp_ddns eval dhcpsrv cfgrpt
+	      stats asiodns dhcp_ddns eval dhcpsrv cfgrpt process

+ 5 - 0
src/lib/process/.gitignore

@@ -0,0 +1,5 @@
+/process_messages.cc
+/process_messages.h
+/spec_config.h
+/spec_config.h.pre
+/s-messages

+ 72 - 0
src/lib/process/Makefile.am

@@ -0,0 +1,72 @@
+SUBDIRS = . testutils tests
+
+AM_CPPFLAGS  = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+
+if HAVE_MYSQL
+AM_CPPFLAGS += $(MYSQL_CPPFLAGS)
+endif
+if HAVE_PGSQL
+AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
+endif
+if HAVE_CQL
+AM_CPPFLAGS += $(CQL_CPPFLAGS)
+endif
+
+AM_CXXFLAGS  = $(KEA_CXXFLAGS)
+
+# Define rule to build logging source files from message file
+process_messages.h process_messages.cc: s-messages
+
+s-messages: process_messages.mes
+	$(top_builddir)/src/lib/log/compiler/kea-msg-compiler $(top_srcdir)/src/lib/process/process_messages.mes
+	touch $@
+
+spec_config.h: spec_config.h.pre
+	$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@
+
+# Tell automake that the message files are built as part of the build process
+# (so that they are built before the main library is built).
+BUILT_SOURCES = spec_config.h process_messages.h process_messages.cc
+
+# Ensure that the message file is included in the distribution
+EXTRA_DIST = process_messages.mes libprocess.dox
+
+# Get rid of generated message files on a clean
+CLEANFILES = *.gcno *.gcda spec_config.h process_messages.h process_messages.cc s-messages
+
+lib_LTLIBRARIES = libkea-process.la
+libkea_process_la_SOURCES  = d_cfg_mgr.cc d_cfg_mgr.h
+libkea_process_la_SOURCES += d_controller.cc d_controller.h
+libkea_process_la_SOURCES += d_log.cc d_log.h
+libkea_process_la_SOURCES += d_process.h
+libkea_process_la_SOURCES += io_service_signal.cc io_service_signal.h
+
+nodist_libkea_process_la_SOURCES = process_messages.cc process_messages.h
+
+libkea_process_la_CXXFLAGS = $(AM_CXXFLAGS)
+libkea_process_la_CPPFLAGS = $(AM_CPPFLAGS)
+libkea_process_la_LDFLAGS  = $(AM_LDFLAGS)
+libkea_process_la_LDFLAGS += -no-undefined -version-info 1:0:0
+
+libkea_process_la_LIBADD  =
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libkea_process_la_LIBADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) $(BOOST_LIBS)
+
+# Specify the headers for copying into the installation directory tree.
+libkea_process_includedir = $(pkgincludedir)/process
+libkea_process_include_HEADERS = \
+	d_log.h \
+	d_cfg_mgr.h \
+	d_controller.h \
+	d_process.h \
+	io_service_signal.h

+ 4 - 4
src/bin/d2/d_cfg_mgr.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,10 +7,10 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
-#include <d2/d2_log.h>
 #include <dhcp/libdhcp++.h>
 #include <dhcp/libdhcp++.h>
-#include <d2/d_cfg_mgr.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
+#include <process/d_log.h>
+#include <process/d_cfg_mgr.h>
 #include <util/encode/hex.h>
 #include <util/encode/hex.h>
 #include <util/strutil.h>
 #include <util/strutil.h>
 
 
@@ -30,7 +30,7 @@ using namespace isc::data;
 using namespace isc::asiolink;
 using namespace isc::asiolink;
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 // *********************** DCfgContextBase  *************************
 // *********************** DCfgContextBase  *************************
 
 

+ 3 - 3
src/bin/d2/d_cfg_mgr.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -22,7 +22,7 @@
 #endif
 #endif
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Defines a map of ConstElementPtrs keyed by name
 /// @brief Defines a map of ConstElementPtrs keyed by name
 typedef std::map<std::string, isc::data::ConstElementPtr> ElementMap;
 typedef std::map<std::string, isc::data::ConstElementPtr> ElementMap;
@@ -403,7 +403,7 @@ private:
 typedef boost::shared_ptr<DCfgMgrBase> DCfgMgrBasePtr;
 typedef boost::shared_ptr<DCfgMgrBase> DCfgMgrBasePtr;
 
 
 
 
-}; // end of isc::d2 namespace
+}; // end of isc::process namespace
 }; // end of isc namespace
 }; // end of isc namespace
 
 
 #endif // D_CFG_MGR_H
 #endif // D_CFG_MGR_H

+ 20 - 21
src/bin/d2/d_controller.cc

@@ -5,15 +5,15 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
 #include <config.h>
 #include <config.h>
-#include <d2/d2_log.h>
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
-#include <d2/d_controller.h>
-#include <exceptions/exceptions.h>
-#include <log/logger_support.h>
-#include <dhcpsrv/cfgmgr.h>
+#include <cfgrpt/config_report.h>
 #include <cryptolink/cryptolink.h>
 #include <cryptolink/cryptolink.h>
+#include <dhcpsrv/cfgmgr.h>
+#include <exceptions/exceptions.h>
 #include <log/logger.h>
 #include <log/logger.h>
-#include <cfgrpt/config_report.h>
+#include <log/logger_support.h>
+#include <process/d_log.h>
+#include <process/d_controller.h>
 
 
 #ifdef HAVE_MYSQL
 #ifdef HAVE_MYSQL
 #include <dhcpsrv/mysql_lease_mgr.h>
 #include <dhcpsrv/mysql_lease_mgr.h>
@@ -30,7 +30,7 @@
 #include <unistd.h>
 #include <unistd.h>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 DControllerBasePtr DControllerBase::controller_;
 DControllerBasePtr DControllerBase::controller_;
 
 
@@ -87,19 +87,18 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) {
     try {
     try {
         createPIDFile();
         createPIDFile();
     } catch (const dhcp::DaemonPIDExists& ex) {
     } catch (const dhcp::DaemonPIDExists& ex) {
-        LOG_FATAL(dctl_logger, DHCP_DDNS_ALREADY_RUNNING)
+        LOG_FATAL(dctl_logger, DCTL_ALREADY_RUNNING)
                   .arg(bin_name_).arg(ex.what());
                   .arg(bin_name_).arg(ex.what());
         isc_throw (LaunchError, "Launch Failed: " << ex.what());
         isc_throw (LaunchError, "Launch Failed: " << ex.what());
     } catch (const std::exception& ex) {
     } catch (const std::exception& ex) {
-        LOG_FATAL(dctl_logger, DHCP_DDNS_PID_FILE_ERROR)
+        LOG_FATAL(dctl_logger, DCTL_PID_FILE_ERROR)
                   .arg(app_name_).arg(ex.what());
                   .arg(app_name_).arg(ex.what());
         isc_throw (LaunchError, "Launch failed: " << ex.what());
         isc_throw (LaunchError, "Launch failed: " << ex.what());
     }
     }
 
 
-    // Log the starting of the service.  Although this is the controller
-    // module, use a "DHCP_DDNS_" prefix to the module (to conform to the
-    // principle of least astonishment).
-    LOG_INFO(dctl_logger, DHCP_DDNS_STARTING).arg(getpid()).arg(VERSION);
+    // Log the starting of the service.
+    LOG_INFO(dctl_logger, DCTL_STARTING)
+        .arg(app_name_).arg(getpid()).arg(VERSION);
     try {
     try {
         // Step 2 is to create and initialize the application process object.
         // Step 2 is to create and initialize the application process object.
         initProcess();
         initProcess();
@@ -136,9 +135,9 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) {
                    "Application process event loop failed: " << ex.what());
                    "Application process event loop failed: " << ex.what());
     }
     }
 
 
-    // All done, so bail out.  Log the event (using a DHCP_DDNS_ prefix
-    // for the same reason as used for DHCP_DDNS_STARTING).
-    LOG_INFO(dctl_logger, DHCP_DDNS_SHUTDOWN);
+    // All done, so bail out.
+    LOG_INFO(dctl_logger, DCTL_SHUTDOWN)
+        .arg(app_name_).arg(getpid()).arg(VERSION);
 }
 }
 
 
 void
 void
@@ -414,14 +413,14 @@ DControllerBase::processSignal(int signum) {
     switch (signum) {
     switch (signum) {
         case SIGHUP:
         case SIGHUP:
         {
         {
-            LOG_INFO(dctl_logger, DHCP_DDNS_CFG_FILE_RELOAD_SIGNAL_RECVD)
+            LOG_INFO(dctl_logger, DCTL_CFG_FILE_RELOAD_SIGNAL_RECVD)
                      .arg(signum).arg(getConfigFile());
                      .arg(signum).arg(getConfigFile());
             int rcode;
             int rcode;
             isc::data::ConstElementPtr comment = isc::config::
             isc::data::ConstElementPtr comment = isc::config::
                                                  parseAnswer(rcode,
                                                  parseAnswer(rcode,
                                                              configFromFile());
                                                              configFromFile());
             if (rcode != 0) {
             if (rcode != 0) {
-                LOG_ERROR(dctl_logger, DHCP_DDNS_CFG_FILE_RELOAD_ERROR)
+                LOG_ERROR(dctl_logger, DCTL_CFG_FILE_RELOAD_ERROR)
                           .arg(comment->stringValue());
                           .arg(comment->stringValue());
             }
             }
 
 
@@ -432,14 +431,14 @@ DControllerBase::processSignal(int signum) {
         case SIGTERM:
         case SIGTERM:
         {
         {
             LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT,
             LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT,
-                      DHCP_DDNS_SHUTDOWN_SIGNAL_RECVD).arg(signum);
+                      DCTL_SHUTDOWN_SIGNAL_RECVD).arg(signum);
             isc::data::ElementPtr arg_set;
             isc::data::ElementPtr arg_set;
             executeCommand(SHUT_DOWN_COMMAND, arg_set);
             executeCommand(SHUT_DOWN_COMMAND, arg_set);
             break;
             break;
         }
         }
 
 
         default:
         default:
-            LOG_WARN(dctl_logger, DHCP_DDNS_UNSUPPORTED_SIGNAL).arg(signum);
+            LOG_WARN(dctl_logger, DCTL_UNSUPPORTED_SIGNAL).arg(signum);
             break;
             break;
     }
     }
 }
 }
@@ -499,6 +498,6 @@ DControllerBase::getVersion(bool extended) {
     return (tmp.str());
     return (tmp.str());
 }
 }
 
 
-}; // namespace isc::d2
+}; // namespace isc::process
 
 
 }; // namespace isc
 }; // namespace isc

+ 5 - 5
src/bin/d2/d_controller.h

@@ -9,19 +9,19 @@
 
 
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
 #include <cc/data.h>
 #include <cc/data.h>
-#include <d2/d2_log.h>
-#include <d2/d_process.h>
-#include <d2/io_service_signal.h>
 #include <dhcpsrv/daemon.h>
 #include <dhcpsrv/daemon.h>
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
 #include <log/logger_support.h>
 #include <log/logger_support.h>
+#include <process/d_log.h>
+#include <process/d_process.h>
+#include <process/io_service_signal.h>
 
 
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/noncopyable.hpp>
 
 
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Exception thrown when the command line is invalid.
 /// @brief Exception thrown when the command line is invalid.
 class InvalidUsage : public isc::Exception {
 class InvalidUsage : public isc::Exception {
@@ -508,7 +508,7 @@ private:
 friend class DControllerTest;
 friend class DControllerTest;
 };
 };
 
 
-}; // namespace isc::d2
+}; // namespace isc::process
 }; // namespace isc
 }; // namespace isc
 
 
 #endif
 #endif

+ 19 - 0
src/lib/process/d_log.cc

@@ -0,0 +1,19 @@
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+/// Defines the logger used by the top-level component of kea-dhcp-ddns.
+
+#include <process/d_log.h>
+
+namespace isc {
+namespace process {
+
+/// @brief Defines the logger used within libkea-process library.
+isc::log::Logger dctl_logger("dctl");
+
+} // namespace process
+} // namespace isc
+

+ 23 - 0
src/lib/process/d_log.h

@@ -0,0 +1,23 @@
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef D_LOG_H
+#define D_LOG_H
+
+#include <log/logger_support.h>
+#include <log/macros.h>
+#include <process/process_messages.h>
+
+namespace isc {
+namespace process {
+
+/// Define the loggers used within libkea-process library.
+extern isc::log::Logger dctl_logger;
+
+} // namespace process
+} // namespace isc
+
+#endif // D_LOG_H

+ 4 - 4
src/bin/d2/d_process.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9,14 +9,14 @@
 
 
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
 #include <cc/data.h>
 #include <cc/data.h>
-#include <d2/d_cfg_mgr.h>
+#include <process/d_cfg_mgr.h>
 
 
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 
 
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Exception thrown if the process encountered an operational error.
 /// @brief Exception thrown if the process encountered an operational error.
 class DProcessBaseError : public isc::Exception {
 class DProcessBaseError : public isc::Exception {
@@ -203,7 +203,7 @@ private:
 /// @brief Defines a shared pointer to DProcessBase.
 /// @brief Defines a shared pointer to DProcessBase.
 typedef boost::shared_ptr<DProcessBase> DProcessBasePtr;
 typedef boost::shared_ptr<DProcessBase> DProcessBasePtr;
 
 
-}; // namespace isc::d2
+}; // namespace isc::process
 }; // namespace isc
 }; // namespace isc
 
 
 #endif
 #endif

+ 6 - 6
src/bin/d2/io_service_signal.cc

@@ -1,15 +1,15 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
 #include <asiolink/interval_timer.h>
 #include <asiolink/interval_timer.h>
-#include <d2/d2_log.h>
-#include <d2/io_service_signal.h>
+#include <process/d_log.h>
+#include <process/io_service_signal.h>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 IOSignal::IOSignal (asiolink::IOService& io_service, int signum,
 IOSignal::IOSignal (asiolink::IOService& io_service, int signum,
                     IOSignalHandler handler)
                     IOSignalHandler handler)
@@ -50,7 +50,7 @@ IOSignal::TimerCallback::operator()() {
         handler_(sequence_id_);
         handler_(sequence_id_);
     } catch (const std::exception& ex) {
     } catch (const std::exception& ex) {
         // We log it and swallow it so we don't undermine IOService::run.
         // We log it and swallow it so we don't undermine IOService::run.
-        LOG_ERROR(dctl_logger, DHCP_DDNS_SIGNAL_ERROR)
+        LOG_ERROR(dctl_logger, DCTL_SIGNAL_ERROR)
                   .arg(sequence_id_).arg(ex.what());
                   .arg(sequence_id_).arg(ex.what());
     }
     }
 
 
@@ -112,5 +112,5 @@ IOSignalQueue::clear() {
     signals_.clear();
     signals_.clear();
 }
 }
 
 
-}; // end of isc::d2 namespace
+}; // end of isc::process namespace
 }; // end of isc namespace
 }; // end of isc namespace

+ 11 - 10
src/bin/d2/io_service_signal.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -15,7 +15,7 @@
 #include <stdint.h>
 #include <stdint.h>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Exception thrown if IOSignal encounters an error.
 /// @brief Exception thrown if IOSignal encounters an error.
 class IOSignalError : public isc::Exception {
 class IOSignalError : public isc::Exception {
@@ -54,7 +54,7 @@ typedef boost::function<void(IOSignalId sequence_id)> IOSignalHandler;
 /// create the signals, house them until they are delivered, and dequeue them
 /// create the signals, house them until they are delivered, and dequeue them
 /// so they can be been handled.  To generate an IOSignal when an OS signal
 /// so they can be been handled.  To generate an IOSignal when an OS signal
 /// arrives, the process's OS signal handler simply calls @ref
 /// arrives, the process's OS signal handler simply calls @ref
-/// isc::d2::IOSignalQueue::pushSignal() with the appropriate values.
+/// isc::process::IOSignalQueue::pushSignal() with the appropriate values.
 ///
 ///
 /// @note that an IOSignalQueue requires a non-null IOServicePtr to construct.
 /// @note that an IOSignalQueue requires a non-null IOServicePtr to construct.
 /// This ensures that the IOService cannot be destroyed before any pending
 /// This ensures that the IOService cannot be destroyed before any pending
@@ -63,12 +63,13 @@ typedef boost::function<void(IOSignalId sequence_id)> IOSignalHandler;
 /// one service, each service must have its own queue.
 /// one service, each service must have its own queue.
 ///
 ///
 /// To dequeue the IOSignal inside the caller's IOSignalHandler, one simply
 /// To dequeue the IOSignal inside the caller's IOSignalHandler, one simply
-/// invokes @ref isc::d2::IOSignalQueue::popSignal() passing it the sequence_id
-/// parameter passed to the handler.  This method returns a pointer to
-/// instigating IOSignal from which the value of OS signal (i.e. SIGINT,
-/// SIGUSR1...) can be obtained.  Note that calling popSignal() removes the
-/// IOSignalPtr from the queue, which should reduce its reference count to
-/// zero upon exiting the handler (unless a delibrate copy of it is made).
+/// invokes @ref isc::process::IOSignalQueue::popSignal() passing it the
+/// sequence_id parameter passed to the handler.  This method returns a
+/// pointer to instigating IOSignal from which the value of OS signal (i.e.
+/// SIGINT, SIGUSR1...) can be obtained.  Note that calling popSignal()
+/// removes the IOSignalPtr from the queue, which should reduce its
+/// reference count to zero upon exiting the handler (unless a delibrate
+/// copy of it is made).
 ///
 ///
 /// A typical IOSignalHandler might be structured as follows:
 /// A typical IOSignalHandler might be structured as follows:
 /// @code
 /// @code
@@ -252,7 +253,7 @@ private:
 typedef boost::shared_ptr<IOSignalQueue> IOSignalQueuePtr;
 typedef boost::shared_ptr<IOSignalQueue> IOSignalQueuePtr;
 
 
 
 
-}; // end of isc::d2 namespace
+}; // end of isc::process namespace
 }; // end of isc namespace
 }; // end of isc namespace
 
 
 #endif // IO_SERVICE_SIGNAL_H
 #endif // IO_SERVICE_SIGNAL_H

+ 176 - 0
src/lib/process/libprocess.dox

@@ -0,0 +1,176 @@
+// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+/**
+ @page libprocess libkea-process - Controllable Process Layer (CPL)
+
+@section cpl Controllable Process Layer (CPL)
+During the design and development of D2 (Kea's DHCP-DDNS process), an abstract
+layer for process control, called the Controllable Process Layer or CPL, was
+created.  Kea's DHCP servers were initially developed prior to D2 and thus
+before CPL existed.
+
+Out of short term convenience and the fact that only D2 was using it, the CPL
+was initially developed as part of D2 in src/bin/d2.  In order to use CPL for
+new Kea processes, it has since been moved into its own library, libkea-process.
+The following sections describe the architecture of CPL and how it can be used to implement new daemons in Kea.
+
+The CPL provides the essentials for a controllable, configurable,
+asynchronous process.  They are the result of an effort to distill the
+common facets of process control currently duplicated in Kea's
+DHCP servers into a reusable construct.  The classes which form this abstract
+base are shown in the following class diagram:
+
+@image html abstract_app_classes.svg  "Controllable Process Layer Classes"
+
+- isc::process::DControllerBase - provides all of the services necessary to manage
+an application process class derived from isc::d2::DProcess. These services include:
+    - Command line argument handling
+    - Process instantiation and initialization
+    - Support for stand-alone execution
+    - Process event loop invocation and shutdown
+
+    It creates and manages an instance of isc::process::DProcessBase.  The CPL is
+    designed for asynchronous event processing applications.  It is constructed
+    to use ASIO library for IO processing.  @c DControllerBase owns an
+    isc::asiolink::IOService instance and it passes this into the @c
+    DProcessBase constructor. It is this @c IOService that is used to drive the
+    process's event loop.  The controller is designed to provide any interfaces
+    between the process it controls and the outside world.
+
+    @c DControllerBase provides configuration for its process via a JSON file
+    specified as a mandatory command line argument. The file structure is
+    expected be as follows:
+
+    { "<module-name>": {<module-config>} }
+
+    where:
+        - module-name : is a label which uniquely identifies the
+        configuration data for the (i.e. the controlled process.)
+        It is the value returned by @ref
+        isc::process::DControllerBase::getAppName()
+
+        - module-config: a set of zero or more JSON elements which comprise
+        application's configuration values.  Element syntax is governed
+        by those elements supported in isc::cc.
+
+    The file may contain an arbitrary number of other modules.
+
+    @todo Eventually, some sort of secure socket interface which supports remote
+    control operations such as configuration changes or status reporting will
+    likely be implemented.
+
+- isc::process::DProcessBase - defines an asynchronous-event processor (i.e.
+application) which provides a uniform interface to:
+    - Instantiate and initialize a process instance
+    - "Run" the application by starting its event loop
+    - Inject events to control the process
+It owns an instance of @c DCfgMgrBase.
+
+- isc::process::DCfgMgrBase - provides the mechanisms for managing an application's
+configuration.  This includes services for parsing sets of configuration
+values, storing the parsed information in its converted form, and retrieving
+the information on demand.  It owns an instance of @c DCfgContextBase, which
+provides a "global" context for information that is accessible before, during,
+and after parsing.
+
+- isc::process::DCfgContextBase - implements a container for configuration
+information or "context".  It provides a single enclosure for the storage of
+configuration parameters or any other information that needs to accessible
+within a given context.
+
+The following sequence diagram shows how a configuration from file moves
+through the CPL layer:
+
+@image html config_from_file_sequence.svg "CPL Configuration From File Sequence"
+
+The CPL classes will likely move into a common library.
+
+@section cplSignals CPL Signal Handling
+
+CPL supports interaction with the outside world via OS signals. The default
+implementation supports the following signal driven behavior:
+- SIGHUP receipt of this signal will cause a reloading of the configuration
+file.
+- SIGINT/SIGTERM receipt of either of these signals will initiate an
+orderly shutdown.
+
+CPL applications wait for for process asynchronous IO events through
+isc::asiolink::IOService::run() or its variants.  These calls are not
+interrupted upon signal receipt as is the select() function and while
+boost::asio provides a signal mechanism it requires linking in additional
+libraries.  Therefore, CPL provides its own signal handling mechanism to
+propagate an OS signal such as SIGHUP to an IOSerivce as a ready event with a
+callback.
+
+isc::process::DControllerBase uses two mechanisms to carry out signal handling.  It
+uses isc::util::SignalSet to catch OS signals, and isc::process::IOSignalQueue to
+propagate them to its isc::asiolink::IOService as instances of
+isc::process::IOSignal.
+
+This CPL signaling class hierarchy is illustrated in the following diagram:
+
+@image html cpl_signal_classes.svg "CPL Signal Classes"
+
+The mechanics of isc::process::IOSignal are straight forward. Upon construction it
+is given the target isc::asiolink::IOService, the value of the OS signal to
+send (e.g. SIGINT, SIGHUP...), and an isc::process::IOSignalHandler.  This handler
+should contain the logic the caller would normally execute in its OS signal
+handler. Each isc::process::IOSignal instance has a unique identifier called its
+sequence_id.
+
+Internally, IOSignal creates a 1 ms, one-shot timer, on the given
+IOService.  When the timer expires its event handler invokes the caller's
+IOSignalHandler passing it the sequence_id of the IOSignal.
+
+Sending IOSignals is done through an isc::process::IOSignalQueue.  This class is
+used to create the signals, house them until they are delivered, and dequeue
+them so they can be been handled.  To generate an IOSignal when an OS signal
+arrives, the process's OS signal handler need only call
+isc::process::IOSignalQueue::pushSignal() with the appropriate values.
+
+To dequeue the IOSignal inside the caller's IOSignalHandler, one simply
+invokes isc::process::IOSignalQueue::popSignal() passing it the sequence_id
+parameter passed to the handler.  This method returns a pointer to
+instigating IOSignal from which the value of OS signal (i.e. SIGINT,
+SIGUSR1...) can be obtained.  Note that calling popSignal() removes the
+IOSignalPtr from the queue, which should reduce its reference count to
+zero upon exiting the handler (unless a deliberate copy of it is made).
+
+A typical isc::process::IOSignalHandler might be structured as follows:
+@code
+
+    void processSignal(IOSignalId sequence_id) {
+    // Pop the signal instance off the queue.
+    IOSignalPtr signal = io_signal_queue_->popSignal(sequence_id);
+
+    int os_signal_value = signal->getSignum();
+    :
+    // logic based on the signal value
+    :
+    }
+
+@endcode
+
+IOSignal's handler invocation code will catch, log ,and then swallow any
+exceptions thrown by an IOSignalHandler.  This is done to protect the integrity
+IOService context.
+
+CPL integrates the use of the two mechanisms by registering the method,
+isc::process::DControllerBase::osSignalHandler(), as the
+isc::util::SignalSet::onreceipt_handler_.  This configures SignalSet's internal
+handler to invoke the method each time a signal arrives.  When invoked, this
+method will call isc::process::IOSignalQueue::pushSignal() to create an
+isc::process::IOSignal, passing in the OS signal received and
+isc::process::DControllerBase::ioSignalHandler() to use as the IOSignal's
+ready event handler
+
+The following sequence diagram depicts the initialization of signal handling
+during startup and the subsequent receipt of a SIGHUP:
+
+@image html cpl_signal_sequence.svg "CPL Signal Handling Sequence"
+
+*/

+ 137 - 0
src/lib/process/process_messages.mes

@@ -0,0 +1,137 @@
+# Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$NAMESPACE isc::process
+
+% DCTL_ALREADY_RUNNING %1 already running? %2
+This is an error message that occurs when a module encounters a pre-existing
+PID file which contains the PID of a running process.  This most likely
+indicates an attempt to start a second instance of a module using the
+same configuration file.  It is possible, though unlikely, that the PID file
+is a remnant left behind by a server crash or power failure and the PID
+it contains refers to a process other than Kea process.  In such an event,
+it would be necessary to manually remove the PID file.  The first argument is
+the process name, the second contains the PID and PID file.
+
+% DCTL_CCSESSION_ENDING %1 ending control channel session
+This debug message is issued just before the controller attempts
+to disconnect from its session with the Kea control channel.
+
+% DCTL_CCSESSION_STARTING %1 starting control channel session, specfile: %2
+This debug message is issued just before the controller attempts
+to establish a session with the Kea control channel.
+
+% DCTL_COMMAND_RECEIVED %1 received command: %2, arguments: %3
+A debug message listing the command (and possible arguments) received
+from the Kea control system by the controller.
+
+% DCTL_CONFIG_COMPLETE server has completed configuration: %1
+This is an informational message announcing the successful processing of a
+new configuration. It is output during server startup, and when an updated
+configuration is committed by the administrator.  Additional information
+may be provided.
+
+% DCTL_CONFIG_FILE_LOAD_FAIL %1 reason: %2
+This fatal error message indicates that the application attempted to load its
+initial configuration from file and has failed. The service will exit.
+
+% DCTL_CONFIG_LOAD_FAIL %1 configuration failed to load: %2
+This critical error message indicates that the initial application
+configuration has failed. The service will start, but will not
+process requests until the configuration has been corrected.
+
+% DCTL_CONFIG_START parsing new configuration: %1
+A debug message indicating that the application process has received an
+updated configuration and has passed it to its configuration manager
+for parsing.
+
+% DCTL_CONFIG_STUB %1 configuration stub handler called
+This debug message is issued when the dummy handler for configuration
+events is called.  This only happens during initial startup.
+
+% DCTL_CONFIG_UPDATE %1 updated configuration received: %2
+A debug message indicating that the controller has received an
+updated configuration from the Kea configuration system.
+
+% DCTL_INIT_PROCESS %1 initializing the application
+This debug message is issued just before the controller attempts
+to create and initialize its application instance.
+
+% DCTL_INIT_PROCESS_FAIL %1 application initialization failed: %2
+This error message is issued if the controller could not initialize the
+application and will exit.
+
+% DCTL_NOT_RUNNING %1 application instance is not running
+A warning message is issued when an attempt is made to shut down the
+application when it is not running.
+
+% DCTL_PARSER_FAIL : %1
+On receipt of a new configuration, the server failed to create a parser to
+decode the contents of the named configuration element, or the creation
+succeeded but the parsing actions and committal of changes failed.
+The reason for the failure is given in the message.
+
+% DCTL_PID_FILE_ERROR %1 could not create a PID file: %2
+This is an error message that occurs when the server is unable to create
+its PID file.  The log message should contain details sufficient to
+determine the underlying cause.  The most likely culprits are that
+some portion of the pathname does not exist or a permissions issue. The
+default path is determined by --localstatedir configure parameter but
+may be overridden by setting environment variable, KEA_PIDFILE_DIR.  The
+first argument is the process name.
+
+% DCTL_PROCESS_FAILED %1 application execution failed: %2
+The controller has encountered a fatal error while running the
+application and is terminating. The reason for the failure is
+included in the message.
+
+% DCTL_CFG_FILE_RELOAD_ERROR configuration reload failed: %1, reverting to current configuration.
+This is an error message indicating that the application attempted to reload
+its configuration from file and encountered an error.  This is likely due to
+invalid content in the configuration file.  The application should continue
+to operate under its current configuration.
+
+% DCTL_CFG_FILE_RELOAD_SIGNAL_RECVD OS signal %1 received, reloading configuration from file: %2
+This is an informational message indicating the application has received a signal
+instructing it to reload its configuration from file.
+
+% DCTL_RUN_PROCESS %1 starting application event loop
+This debug message is issued just before the controller invokes
+the application run method.
+
+% DCTL_SESSION_FAIL %1 controller failed to establish Kea session: %1
+The controller has failed to establish communication with the rest of
+Kea and will exit.
+
+% DCTL_SHUTDOWN %1 has shut down, pid: %2, version: %3
+This is an informational message indicating that the service has shut
+down. The argument specifies a name of the service.
+
+% DCTL_SHUTDOWN_SIGNAL_RECVD OS signal %1 received, starting shutdown
+This is a debug message indicating the application has received a signal
+instructing it to shutdown.
+
+% DCTL_SIGNAL_ERROR signal handler for signal %1, threw an unexpected exception: %2
+This is an error message indicating that the application encountered an unexpected
+error after receiving a signal.  This is a programmatic error and should be
+reported.  While The application will likely continue to operating, it may be
+unable to respond correctly to signals.
+
+% DCTL_STANDALONE %1 skipping message queue, running standalone
+This is a debug message indicating that the controller is running in the
+application in standalone mode. This means it will not connected to the Kea
+message queue. Standalone mode is only useful during program development,
+and should not be used in a production environment.
+
+% DCTL_STARTING %1 starting, pid: %2, version: %3
+This is an informational message issued when controller for the
+service first starts. Version is also reported.
+
+% DCTL_UNSUPPORTED_SIGNAL ignoring reception of unsupported signal: %1
+This is a debug message indicating that the application received an
+unsupported signal.  This is a programming error indicating that the
+application has registered to receive the signal but no associated
+processing logic has been added.

src/bin/d2/spec_config.h.pre.in → src/lib/process/spec_config.h.pre.in


+ 1 - 0
src/lib/process/tests/.gitignore

@@ -0,0 +1 @@
+/libprocess_unittests

+ 50 - 0
src/lib/process/tests/Makefile.am

@@ -0,0 +1,50 @@
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/process/tests\"
+AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
+
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS_ENVIRONMENT = \
+	$(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+TESTS =
+if HAVE_GTEST
+TESTS += libprocess_unittests
+
+libprocess_unittests_SOURCES  = d_cfg_mgr_unittests.cc
+libprocess_unittests_SOURCES += d_controller_unittests.cc
+libprocess_unittests_SOURCES += io_service_signal_unittests.cc
+libprocess_unittests_SOURCES += run_unittests.cc
+
+libprocess_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+
+libprocess_unittests_CXXFLAGS = $(AM_CXXFLAGS)
+
+libprocess_unittests_LDFLAGS  = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+
+libprocess_unittests_LDADD  = $(top_builddir)/src/lib/process/testutils/libprocesstest.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+libprocess_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libprocess_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
+libprocess_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
+endif
+
+noinst_PROGRAMS = $(TESTS)

+ 4 - 4
src/bin/d2/tests/d_cfg_mgr_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9,8 +9,8 @@
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
 #include <config/module_spec.h>
 #include <config/module_spec.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
-#include <d2/d_cfg_mgr.h>
-#include <d_test_stubs.h>
+#include <process/testutils/d_test_stubs.h>
+#include <process/d_cfg_mgr.h>
 
 
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -21,7 +21,7 @@
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::config;
 using namespace isc::config;
-using namespace isc::d2;
+using namespace isc::process;
 using namespace boost::posix_time;
 using namespace boost::posix_time;
 
 
 namespace {
 namespace {

+ 22 - 18
src/bin/d2/tests/d_controller_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,8 +7,8 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
-#include <d_test_stubs.h>
-#include <d2/spec_config.h>
+#include <process/spec_config.h>
+#include <process/testutils/d_test_stubs.h>
 
 
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <gtest/gtest.h>
 #include <gtest/gtest.h>
@@ -18,7 +18,7 @@
 using namespace boost::posix_time;
 using namespace boost::posix_time;
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Test fixture class for testing DControllerBase class. This class
 /// @brief Test fixture class for testing DControllerBase class. This class
 /// derives from DControllerTest and wraps a DStubController.  DStubController
 /// derives from DControllerTest and wraps a DStubController.  DStubController
@@ -284,14 +284,17 @@ TEST_F(DStubControllerTest, configUpdateTests) {
 /// chain of methods and to handle error conditions.
 /// chain of methods and to handle error conditions.
 /// This test verifies that:
 /// This test verifies that:
 /// 1. That an unrecognized command is detected and returns a status of
 /// 1. That an unrecognized command is detected and returns a status of
-/// d2::COMMAND_INVALID.
-/// 2. Shutdown command is recognized and returns a d2::COMMAND_SUCCESS status.
-/// 3. A valid, custom controller command is recognized a d2::COMMAND_SUCCESS
+/// process::COMMAND_INVALID.
+/// 2. Shutdown command is recognized and returns a process::COMMAND_SUCCESS
 /// status.
 /// status.
-/// 4. A valid, custom process command is recognized a d2::COMMAND_SUCCESS
+/// 3. A valid, custom controller command is recognized a
+/// process::COMMAND_SUCCESS
 /// status.
 /// status.
-/// 5. That a valid controller command that fails returns a d2::COMMAND_ERROR.
-/// 6. That a valid process command that fails returns a d2::COMMAND_ERROR.
+/// 4. A valid, custom process command is recognized a
+/// process::COMMAND_SUCCESS status.
+/// 5. That a valid controller command that fails returns a
+/// process::COMMAND_ERROR.
+/// 6. That a valid process command that fails returns a process::COMMAND_ERROR.
 TEST_F(DStubControllerTest, executeCommandTests) {
 TEST_F(DStubControllerTest, executeCommandTests) {
     int rcode = -1;
     int rcode = -1;
     isc::data::ConstElementPtr answer;
     isc::data::ConstElementPtr answer;
@@ -301,38 +304,39 @@ TEST_F(DStubControllerTest, executeCommandTests) {
     ASSERT_NO_THROW(initProcess());
     ASSERT_NO_THROW(initProcess());
     EXPECT_TRUE(checkProcess());
     EXPECT_TRUE(checkProcess());
 
 
-    // Verify that an unknown command returns an d2::COMMAND_INVALID response.
+    // Verify that an unknown command returns an process::COMMAND_INVALID
+    // response.
     std::string bogus_command("bogus");
     std::string bogus_command("bogus");
     answer = executeCommand(bogus_command, arg_set);
     answer = executeCommand(bogus_command, arg_set);
     isc::config::parseAnswer(rcode, answer);
     isc::config::parseAnswer(rcode, answer);
     EXPECT_EQ(COMMAND_INVALID, rcode);
     EXPECT_EQ(COMMAND_INVALID, rcode);
 
 
-    // Verify that shutdown command returns d2::COMMAND_SUCCESS response.
+    // Verify that shutdown command returns process::COMMAND_SUCCESS response.
     answer = executeCommand(SHUT_DOWN_COMMAND, arg_set);
     answer = executeCommand(SHUT_DOWN_COMMAND, arg_set);
     isc::config::parseAnswer(rcode, answer);
     isc::config::parseAnswer(rcode, answer);
     EXPECT_EQ(COMMAND_SUCCESS, rcode);
     EXPECT_EQ(COMMAND_SUCCESS, rcode);
 
 
     // Verify that a valid custom controller command returns
     // Verify that a valid custom controller command returns
-    // d2::COMMAND_SUCCESS response.
+    // process::COMMAND_SUCCESS response.
     answer = executeCommand(DStubController::stub_ctl_command_, arg_set);
     answer = executeCommand(DStubController::stub_ctl_command_, arg_set);
     isc::config::parseAnswer(rcode, answer);
     isc::config::parseAnswer(rcode, answer);
     EXPECT_EQ(COMMAND_SUCCESS, rcode);
     EXPECT_EQ(COMMAND_SUCCESS, rcode);
 
 
-    // Verify that a valid custom process command returns d2::COMMAND_SUCCESS
-    // response.
+    // Verify that a valid custom process command returns
+    // process::COMMAND_SUCCESS response.
     answer = executeCommand(DStubProcess::stub_proc_command_, arg_set);
     answer = executeCommand(DStubProcess::stub_proc_command_, arg_set);
     isc::config::parseAnswer(rcode, answer);
     isc::config::parseAnswer(rcode, answer);
     EXPECT_EQ(COMMAND_SUCCESS, rcode);
     EXPECT_EQ(COMMAND_SUCCESS, rcode);
 
 
     // Verify that a valid custom controller command that fails returns
     // Verify that a valid custom controller command that fails returns
-    // a d2::COMMAND_ERROR.
+    // a process::COMMAND_ERROR.
     SimFailure::set(SimFailure::ftControllerCommand);
     SimFailure::set(SimFailure::ftControllerCommand);
     answer = executeCommand(DStubController::stub_ctl_command_, arg_set);
     answer = executeCommand(DStubController::stub_ctl_command_, arg_set);
     isc::config::parseAnswer(rcode, answer);
     isc::config::parseAnswer(rcode, answer);
     EXPECT_EQ(COMMAND_ERROR, rcode);
     EXPECT_EQ(COMMAND_ERROR, rcode);
 
 
     // Verify that a valid custom process command that fails returns
     // Verify that a valid custom process command that fails returns
-    // a d2::COMMAND_ERROR.
+    // a process::COMMAND_ERROR.
     SimFailure::set(SimFailure::ftProcessCommand);
     SimFailure::set(SimFailure::ftProcessCommand);
     answer = executeCommand(DStubProcess::stub_proc_command_, arg_set);
     answer = executeCommand(DStubProcess::stub_proc_command_, arg_set);
     isc::config::parseAnswer(rcode, answer);
     isc::config::parseAnswer(rcode, answer);
@@ -456,5 +460,5 @@ TEST_F(DStubControllerTest, sigtermShutdown) {
     EXPECT_TRUE(elapsed_time.total_milliseconds() < 300);
     EXPECT_TRUE(elapsed_time.total_milliseconds() < 300);
 }
 }
 
 
-}; // end of isc::d2 namespace
+}; // end of isc::process namespace
 }; // end of isc namespace
 }; // end of isc namespace

+ 5 - 5
src/bin/d2/tests/io_service_signal_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,15 +7,15 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
-#include <d_test_stubs.h>
-#include <d2/io_service_signal.h>
+#include <process/io_service_signal.h>
+#include <process/testutils/d_test_stubs.h>
 
 
 #include <gtest/gtest.h>
 #include <gtest/gtest.h>
 
 
 #include <queue>
 #include <queue>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Test fixture for testing the use of IOSignals.
 /// @brief Test fixture for testing the use of IOSignals.
 ///
 ///
@@ -387,5 +387,5 @@ TEST_F(IOSignalTest, mixedSignals) {
     EXPECT_EQ(sigusr2_cnt, (stop_at_count_/3));
     EXPECT_EQ(sigusr2_cnt, (stop_at_count_/3));
 }
 }
 
 
-}; // end of isc::d2 namespace
+}; // end of isc::process namespace
 }; // end of isc namespace
 }; // end of isc namespace

+ 22 - 0
src/lib/process/tests/run_unittests.cc

@@ -0,0 +1,22 @@
+// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <log/logger_support.h>
+#include <process/d_log.h>
+#include <gtest/gtest.h>
+
+int
+main(int argc, char* argv[]) {
+    ::testing::InitGoogleTest(&argc, argv);
+    isc::log::initLogger();
+
+    // Override --localstatedir value for PID files
+    setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1);
+
+    int result = RUN_ALL_TESTS();
+
+    return (result);
+}

+ 27 - 0
src/lib/process/testutils/Makefile.am

@@ -0,0 +1,27 @@
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += -DDATABASE_SCRIPTS_DIR=\"$(abs_top_srcdir)/src/share/database/scripts\"
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+CLEANFILES = *.gcno *.gcda
+
+if HAVE_GTEST
+
+noinst_LTLIBRARIES = libprocesstest.la
+
+libprocesstest_la_SOURCES  = d_test_stubs.cc d_test_stubs.h
+
+libprocesstest_la_CXXFLAGS = $(AM_CXXFLAGS)
+libprocesstest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+libprocesstest_la_LDFLAGS  = $(AM_LDFLAGS)
+
+libprocesstest_la_LIBADD   = $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+libprocesstest_la_LIBADD  += $(top_builddir)/src/lib/cc/libkea-cc.la
+libprocesstest_la_LIBADD  += $(top_builddir)/src/lib/log/libkea-log.la
+libprocesstest_la_LIBADD  += $(top_builddir)/src/lib/process/libkea-process.la
+libprocesstest_la_LIBADD  += $(LOG4CPLUS_LIBS) $(BOOST_LIBS)
+
+endif

+ 6 - 6
src/bin/d2/tests/d_test_stubs.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -6,14 +6,14 @@
 
 
 #include <config.h>
 #include <config.h>
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
-#include <d2/d2_log.h>
-#include <d2/spec_config.h>
-#include <d2/tests/d_test_stubs.h>
+#include <process/d_log.h>
+#include <process/spec_config.h>
+#include <process/testutils/d_test_stubs.h>
 
 
 using namespace boost::asio;
 using namespace boost::asio;
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 const char* valid_d2_config = "{ "
 const char* valid_d2_config = "{ "
                         "\"ip-address\" : \"127.0.0.1\" , "
                         "\"ip-address\" : \"127.0.0.1\" , "
@@ -423,5 +423,5 @@ DStubCfgMgr::createConfigParser(const std::string& element_id,
     return (parser);
     return (parser);
 }
 }
 
 
-}; // namespace isc::d2
+}; // namespace isc::process
 }; // namespace isc
 }; // namespace isc

+ 6 - 6
src/bin/d2/tests/d_test_stubs.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -12,11 +12,11 @@
 #include <cc/data.h>
 #include <cc/data.h>
 #include <cc/command_interpreter.h>
 #include <cc/command_interpreter.h>
 
 
-#include <d2/d_controller.h>
-#include <d2/d_cfg_mgr.h>
-
 #include <log/logger_support.h>
 #include <log/logger_support.h>
 
 
+#include <process/d_controller.h>
+#include <process/d_cfg_mgr.h>
+
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
 
 using namespace boost::posix_time;
 using namespace boost::posix_time;
@@ -28,7 +28,7 @@ using namespace boost::posix_time;
 #include <sstream>
 #include <sstream>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace process {
 
 
 /// @brief Provides a valid DHCP-DDNS configuration for testing basic
 /// @brief Provides a valid DHCP-DDNS configuration for testing basic
 /// parsing fundamentals.
 /// parsing fundamentals.
@@ -862,7 +862,7 @@ private:
 /// testing configuration parsing fundamentals.
 /// testing configuration parsing fundamentals.
 extern const char* valid_d2_config;
 extern const char* valid_d2_config;
 
 
-}; // namespace isc::d2
+}; // namespace isc::process
 }; // namespace isc
 }; // namespace isc
 
 
 #endif
 #endif