BIND 10 master, updated. 5aec5fb20b0486574226f89bd877267cb9116921 [master] Merge branch 'trac2978'

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jun 11 17:01:51 UTC 2013


The branch, master has been updated
       via  5aec5fb20b0486574226f89bd877267cb9116921 (commit)
       via  567853b380a1365f0e3fe16a79062ee710f2e167 (commit)
       via  4ee45a9b6fe66798c2aa22ecfc6b9522b9ba8d37 (commit)
      from  ab5994c2e41c297aab91789dc18896beeca96063 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5aec5fb20b0486574226f89bd877267cb9116921
Merge: ab5994c 567853b
Author: Thomas Markwalder <tmark at isc.org>
Date:   Tue Jun 11 13:00:08 2013 -0400

    [master] Merge branch 'trac2978'

-----------------------------------------------------------------------

Summary of changes:
 src/bin/d2/d2_controller.cc                 |   14 ++-
 src/bin/d2/d2_controller.h                  |   28 ++++--
 src/bin/d2/d2_log.cc                        |    6 +-
 src/bin/d2/d2_log.h                         |   11 +--
 src/bin/d2/d2_messages.mes                  |  143 ++++++++++++++-------------
 src/bin/d2/d2_process.cc                    |   16 +--
 src/bin/d2/d_controller.cc                  |   86 ++++++++--------
 src/bin/d2/d_controller.h                   |   46 ++++++---
 src/bin/d2/d_process.h                      |   19 ++--
 src/bin/d2/tests/d2_controller_unittests.cc |    7 +-
 src/bin/d2/tests/d2_test.py                 |    2 +-
 src/bin/d2/tests/d_controller_unittests.cc  |    7 +-
 src/bin/d2/tests/d_test_stubs.cc            |   27 ++---
 src/bin/d2/tests/d_test_stubs.h             |   23 ++++-
 14 files changed, 233 insertions(+), 202 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/d2/d2_controller.cc b/src/bin/d2/d2_controller.cc
index 0cf71b3..2206207 100644
--- a/src/bin/d2/d2_controller.cc
+++ b/src/bin/d2/d2_controller.cc
@@ -21,11 +21,19 @@
 namespace isc {
 namespace d2 {
 
+/// @brief Defines the application name, this is passed into base class
+/// and appears in log statements.
+const char* D2Controller::d2_app_name_ = "DHCP-DDNS";
+
+/// @brief Defines the executable name. This is passed into the base class
+/// by convention this should match the BIND10 module name.
+const char* D2Controller::d2_bin_name_ = "b10-dhcp-ddns";
+
 DControllerBasePtr&
 D2Controller::instance() {
     // If the instance hasn't been created yet, create it.  Note this method
     // must use the base class singleton instance methods.  The base class
-    // must have access to the singleton in order to use it within BIND10 
+    // must have access to the singleton in order to use it within BIND10
     // static function callbacks.
     if (!getController()) {
         DControllerBasePtr controller_ptr(new D2Controller());
@@ -38,11 +46,11 @@ D2Controller::instance() {
 DProcessBase* D2Controller::createProcess() {
     // Instantiate and return an instance of the D2 application process. Note
     // that the process is passed the controller's io_service.
-    return (new D2Process(getName().c_str(), getIOService()));
+    return (new D2Process(getAppName().c_str(), getIOService()));
 }
 
 D2Controller::D2Controller()
-    : DControllerBase(D2_MODULE_NAME) {
+    : DControllerBase(d2_app_name_, d2_bin_name_) {
     // set the BIND10 spec file either from the environment or
     // use the production value.
     if (getenv("B10_FROM_BUILD")) {
diff --git a/src/bin/d2/d2_controller.h b/src/bin/d2/d2_controller.h
index 46a24ef..5ee15b1 100644
--- a/src/bin/d2/d2_controller.h
+++ b/src/bin/d2/d2_controller.h
@@ -21,20 +21,20 @@ namespace isc {
 namespace d2 {
 
 /// @brief Process Controller for D2 Process
-/// This class is the DHCP-DDNS specific derivation of DControllerBase. It 
-/// creates and manages an instance of the DHCP-DDNS application process, 
-/// D2Process.  
+/// This class is the DHCP-DDNS specific derivation of DControllerBase. It
+/// creates and manages an instance of the DHCP-DDNS application process,
+/// D2Process.
 /// @TODO Currently, this class provides only the minimum required specialized
-/// behavior to run the DHCP-DDNS service. It may very well expand as the 
-/// service implementation evolves.  Some thought was given to making 
+/// behavior to run the DHCP-DDNS service. It may very well expand as the
+/// service implementation evolves.  Some thought was given to making
 /// DControllerBase a templated class but the labor savings versus the
 /// 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 {
 public:
     /// @brief Static singleton instance method. This method returns the
-    /// base class singleton instance member.  It instantiates the singleton 
-    /// and sets the base class instance member upon first invocation. 
+    /// base class singleton instance member.  It instantiates the singleton
+    /// and sets the base class instance member upon first invocation.
     ///
     /// @return returns the pointer reference to the singleton instance.
     static DControllerBasePtr& instance();
@@ -42,11 +42,19 @@ public:
     /// @brief Destructor.
     virtual ~D2Controller();
 
+    /// @brief Defines the application name, this is passed into base class
+    /// and appears in log statements.
+    static const char* d2_app_name_;
+
+    /// @brief Defines the executable name. This is passed into the base class
+    /// by convention this should match the BIND10 module name.
+    static const char* d2_bin_name_;
+
 private:
-    /// @brief Creates an instance of the DHCP-DDNS specific application 
+    /// @brief Creates an instance of the DHCP-DDNS specific application
     /// process.  This method is invoked during the process initialization
     /// step of the controller launch.
-    ///  
+    ///
     /// @return returns a DProcessBase* to the application process created.
     /// Note the caller is responsible for destructing the process. This
     /// is handled by the base class, which wraps this pointer with a smart
diff --git a/src/bin/d2/d2_log.cc b/src/bin/d2/d2_log.cc
index 96803d8..c938c2c 100644
--- a/src/bin/d2/d2_log.cc
+++ b/src/bin/d2/d2_log.cc
@@ -19,12 +19,8 @@
 namespace isc {
 namespace d2 {
 
-/// @brief Defines the service name which is used in the controller constructor
-/// and ultimately defines the BIND10 module name.
-const char* const D2_MODULE_NAME = "b10-dhpc-ddns";
-
 /// @brief Defines the logger used within D2.
-isc::log::Logger d2_logger(D2_MODULE_NAME);
+isc::log::Logger dctl_logger("dhcpddns");
 
 } // namespace d2
 } // namespace isc
diff --git a/src/bin/d2/d2_log.h b/src/bin/d2/d2_log.h
index bb95a2b..b91fc15 100644
--- a/src/bin/d2/d2_log.h
+++ b/src/bin/d2/d2_log.h
@@ -22,15 +22,8 @@
 namespace isc {
 namespace d2 {
 
-/// @brief Defines the executable name, ultimately this is the BIND10 module 
-/// name.
-extern const char* const D2_MODULE_NAME;
-
-/// Define the logger for the "d2" module part of b10-d2.  We could define
-/// a logger in each file, but we would want to define a common name to avoid
-/// spelling mistakes, so it is just one small step from there to define a
-/// module-common logger.
-extern isc::log::Logger d2_logger;
+/// Define the logger for the "d2" logging.
+extern isc::log::Logger dctl_logger;
 
 
 } // namespace d2
diff --git a/src/bin/d2/d2_messages.mes b/src/bin/d2/d2_messages.mes
index 82430a5..27778dc 100644
--- a/src/bin/d2/d2_messages.mes
+++ b/src/bin/d2/d2_messages.mes
@@ -14,95 +14,100 @@
 
 $NAMESPACE isc::d2
 
-% D2CTL_STARTING DHCP-DDNS controller starting, pid: %1
-This is an informational message issued when controller for DHCP-DDNS
-service first starts.
+% 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 BIND10 control channel.
 
-% D2CTL_STOPPING DHCP-DDNS controller is exiting
-This is an informational message issued when the controller is exiting
-following a shut down (normal or otherwise) of the DDHCP-DDNS process.
+% 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 BIND10 control channel.
 
-% D2PRC_SHUTDOWN DHCP-DDNS process is performing a normal shut down
-This is a debug message issued when the service process has been instructed
-to shut down by the controller.
+% DCTL_COMMAND_RECEIVED %1 received command %2, arguments: %3
+A debug message listing the command (and possible arguments) received
+from the BIND10 control system by the controller.
 
-% D2PRC_PROCESS_INIT DHCP-DDNS application init invoked
-This is a debug message issued when the D2 process enters its
-init method. 
+% 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.
 
-% D2PRC_RUN_ENTER process has entered the event loop 
-This is a debug message issued when the D2 process enters its
-run method. 
+% 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.
 
-% D2PRC_RUN_EXIT process is exiting the event loop
-This is a debug message issued when the D2 process exits the
-in event loop. 
+% DCTL_CONFIG_UPDATE %1 updated configuration received: %2
+A debug message indicating that the controller has received an
+updated configuration from the BIND10 configuration system.
 
-% D2PRC_FAILED process experienced a fatal error: %1
-This is a debug message issued when the D2 process encounters an
-unrecoverable error from within the event loop.
+% DCTL_DISCONNECT_FAIL %1 controller failed to end session with BIND10: %2
+This message indicates that while shutting down, the Dhcp-Ddns controller
+encountered an error terminating communication with the BIND10. The service
+will still exit.  While theoretically possible, this situation is rather
+unlikely.
 
-% D2PRC_CONFIGURE new configuration received: %1
-This is a debug message issued when the D2 process configure method
-has been invoked.
+% DCTL_INIT_PROCESS %1 initializing the application
+This debug message is issued just before the controller attempts
+to create and initialize its application instance.
 
-% D2PRC_COMMAND command directive received, command: %1 - args: %2
-This is a debug message issued when the D2 process command method
-has been invoked.
+% 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.
 
-% D2CTL_INIT_PROCESS initializing application proces 
-This debug message is issued just before the controller attempts
-to create and initialize its process instance.
+% DCTL_NOT_RUNNING %1 application instance is not running
+A warning message is issued when an attempt is made to shut down the
+the application when it is not running.
 
-% D2CTL_SESSION_FAIL failed to establish BIND 10 session: %1
-The controller has failed to establish communication with the rest of BIND
-10 and will exit. 
+% 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.
 
-% D2CTL_DISCONNECT_FAIL failed to disconnect from BIND 10 session: %1
-This message indicates that while shutting down, the DHCP-DDNS controller 
-encountered an error terminating communication with the BIND10. The service 
-will still exit.  While theoretically possible, this situation is rather 
-unlikely. 
+% DCTL_RUN_PROCESS %1 starting application event loop
+This debug message is issued just before the controller invokes
+the application run method.
 
-% D2CTL_STANDALONE skipping message queue, running standalone
+% DCTL_SESSION_FAIL %1 controller failed to establish BIND10 session: %1
+The controller has failed to establish communication with the rest of BIND
+10 and will exit.
+
+% DCTL_STANDALONE %1 skipping message queue, running standalone
 This is a debug message indicating that the controller is running in the
-process in standalone mode. This means it will not connected to the BIND10 
-message queue. Standalone mode is only useful during program development, 
+application in standalone mode. This means it will not connected to the BIND10
+message queue. Standalone mode is only useful during program development,
 and should not be used in a production environment.
 
-% D2CTL_RUN_PROCESS starting application proces event loop 
-This debug message is issued just before the controller invokes 
-the application process run method.
+% DCTL_STARTING %1 controller starting, pid: %2
+This is an informational message issued when controller for the
+service first starts.
 
-% D2CTL_FAILED process failed: %1
-The controller has encountered a fatal error and is terminating.
-The reason for the failure is included in the message.
+% DCTL_STOPPING %1 controller is exiting
+This is an informational message issued when the controller is exiting
+following a shut down (normal or otherwise) of the service.
 
-% D2CTL_CCSESSION_STARTING starting control channel session, specfile: %1
-This debug message is issued just before the controller attempts
-to establish a session with the BIND 10 control channel.
+% DHCP_DDNS_COMMAND command directive received, command: %1 - args: %2
+This is a debug message issued when the Dhcp-Ddns application command method
+has been invoked.
 
-% D2CTL_CCSESSION_ENDING ending control channel session
-This debug message is issued just before the controller attempts
-to disconnect from its session with the BIND 10 control channel.
+% DHCP_DDNS_CONFIGURE configuration update received: %1
+This is a debug message issued when the Dhcp-Ddns application configure method
+has been invoked.
 
-% D2CTL_CONFIG_STUB configuration stub handler called 
-This debug message is issued when the dummy handler for configuration
-events is called.  This only happens during intial startup.
+% DHCP_DDNS_FAILED application experienced a fatal error: %1
+This is a debug message issued when the Dhcp-Ddns application encounters an
+unrecoverable error from within the event loop.
 
-% D2CTL_CONFIG_LOAD_FAIL failed to load configuration: %1
-This critical error message indicates that the initial process 
-configuration has failed. The service will start, but will not
-process requests until the configuration has been corrected.
+% DHCP_DDNS_PROCESS_INIT application init invoked
+This is a debug message issued when the Dhcp-Ddns application enters
+its init method.
 
-% D2CTL_COMMAND_RECEIVED received command %1, arguments: %2
-A debug message listing the command (and possible arguments) received
-from the BIND 10 control system by the controller.
+% DHCP_DDNS_RUN_ENTER application has entered the event loop
+This is a debug message issued when the Dhcp-Ddns application enters
+its run method.
 
-% D2CTL_NOT_RUNNING The application process instance is not running
-A warning message is issued when an attempt is made to shut down the
-the process when it is not running.
+% DHCP_DDNS_RUN_EXIT application is exiting the event loop
+This is a debug message issued when the Dhcp-Ddns exits the
+in event loop.
 
-% D2CTL_CONFIG_UPDATE updated configuration received: %1
-A debug message indicating that the controller has received an
-updated configuration from the BIND 10 configuration system.
+% DHCP_DDNS_SHUTDOWN application is performing a normal shut down
+This is a debug message issued when the application has been instructed
+to shut down by the controller.
diff --git a/src/bin/d2/d2_process.cc b/src/bin/d2/d2_process.cc
index 64eea72..130bcc1 100644
--- a/src/bin/d2/d2_process.cc
+++ b/src/bin/d2/d2_process.cc
@@ -37,24 +37,24 @@ D2Process::run() {
     // To use run(), the "managing" layer must issue an io_service::stop
     // or the call to run will continue to block, and shutdown will not
     // occur.
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_RUN_ENTER);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DHCP_DDNS_RUN_ENTER);
     IOServicePtr& io_service = getIoService();
     while (!shouldShutdown()) {
         try {
             io_service->run_one();
         } catch (const std::exception& ex) {
-            LOG_FATAL(d2_logger, D2PRC_FAILED).arg(ex.what());
+            LOG_FATAL(dctl_logger, DHCP_DDNS_FAILED).arg(ex.what());
             isc_throw (DProcessBaseError,
                        "Process run method failed: " << ex.what());
         }
     }
 
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_RUN_EXIT);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DHCP_DDNS_RUN_EXIT);
 };
 
 void
 D2Process::shutdown() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_SHUTDOWN);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DHCP_DDNS_SHUTDOWN);
     setShutdownFlag(true);
 }
 
@@ -64,8 +64,8 @@ D2Process::configure(isc::data::ConstElementPtr config_set) {
     // any content in config_set as valid.  This is sufficient to
     // allow participation as a BIND10 module, while D2 configuration support
     // is being developed.
-    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC,
-              D2PRC_CONFIGURE).arg(config_set->str());
+    LOG_DEBUG(dctl_logger, DBGLVL_TRACE_BASIC,
+              DHCP_DDNS_CONFIGURE).arg(config_set->str());
 
     return (isc::config::createAnswer(0, "Configuration accepted."));
 }
@@ -75,8 +75,8 @@ D2Process::command(const std::string& command, isc::data::ConstElementPtr args){
     // @TODO This is the initial implementation.  If and when D2 is extended
     // to support its own commands, this implementation must change. Otherwise
     // it should reject all commands as it does now.
-    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC,
-              D2PRC_COMMAND).arg(command).arg(args->str());
+    LOG_DEBUG(dctl_logger, DBGLVL_TRACE_BASIC,
+              DHCP_DDNS_COMMAND).arg(command).arg(args->str());
 
     return (isc::config::createAnswer(COMMAND_INVALID, "Unrecognized command: "
                                       + command));
diff --git a/src/bin/d2/d_controller.cc b/src/bin/d2/d_controller.cc
index 2487f2d..b32fc45 100644
--- a/src/bin/d2/d_controller.cc
+++ b/src/bin/d2/d_controller.cc
@@ -26,11 +26,13 @@ namespace d2 {
 DControllerBasePtr DControllerBase::controller_;
 
 // Note that the constructor instantiates the controller's primary IOService.
-DControllerBase::DControllerBase(const char* name)
-    : name_(name), stand_alone_(false), verbose_(false),
-    spec_file_name_(""), io_service_(new isc::asiolink::IOService()){
+DControllerBase::DControllerBase(const char* app_name, const char* bin_name)
+    : app_name_(app_name), bin_name_(bin_name), stand_alone_(false),
+      verbose_(false), spec_file_name_(""),
+      io_service_(new isc::asiolink::IOService()){
 }
 
+
 void
 DControllerBase::setController(const DControllerBasePtr& controller) {
     if (controller_) {
@@ -55,30 +57,33 @@ DControllerBase::launch(int argc, char* argv[]) {
 
     // Now that we know what the mode flags are, we can init logging.
     // If standalone is enabled, do not buffer initial log messages
-    isc::log::initLogger(name_,
+    isc::log::initLogger(bin_name_,
                          ((verbose_ && stand_alone_)
                           ? isc::log::DEBUG : isc::log::INFO),
                          isc::log::MAX_DEBUG_LEVEL, NULL, !stand_alone_);
 
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_STARTING).arg(getpid());
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_STARTING)
+              .arg(app_name_).arg(getpid());
     try {
         // Step 2 is to create and initialize the application process object.
         initProcess();
     } catch (const std::exception& ex) {
-        LOG_FATAL(d2_logger, D2CTL_INIT_PROCESS).arg(ex.what());
-        isc_throw (ProcessInitError, 
+        LOG_FATAL(dctl_logger, DCTL_INIT_PROCESS_FAIL)
+                  .arg(app_name_).arg(ex.what());
+        isc_throw (ProcessInitError,
                    "Application Process initialization failed: " << ex.what());
     }
 
     // Next we connect if we are running integrated.
     if (stand_alone_) {
-        LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_STANDALONE);
+        LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_STANDALONE)
+                  .arg(app_name_);
     } else {
         try {
             establishSession();
         } catch (const std::exception& ex) {
-            LOG_FATAL(d2_logger, D2CTL_SESSION_FAIL).arg(ex.what());
-            isc_throw (SessionStartError, 
+            LOG_FATAL(dctl_logger, DCTL_SESSION_FAIL).arg(ex.what());
+            isc_throw (SessionStartError,
                        "Session start up failed: " << ex.what());
         }
     }
@@ -88,8 +93,9 @@ DControllerBase::launch(int argc, char* argv[]) {
     try {
         runProcess();
     } catch (const std::exception& ex) {
-        LOG_FATAL(d2_logger, D2CTL_FAILED).arg(ex.what());
-        isc_throw (ProcessRunError, 
+        LOG_FATAL(dctl_logger, DCTL_PROCESS_FAILED)
+                  .arg(app_name_).arg(ex.what());
+        isc_throw (ProcessRunError,
                    "Application process event loop failed: " << ex.what());
     }
 
@@ -98,13 +104,14 @@ DControllerBase::launch(int argc, char* argv[]) {
         try {
             disconnectSession();
         } catch (const std::exception& ex) {
-            LOG_ERROR(d2_logger, D2CTL_DISCONNECT_FAIL).arg(ex.what());
+            LOG_ERROR(dctl_logger, DCTL_DISCONNECT_FAIL)
+                      .arg(app_name_).arg(ex.what());
             isc_throw (SessionEndError, "Session end failed: " << ex.what());
         }
     }
 
     // All done, so bail out.
-    LOG_INFO(d2_logger, D2CTL_STOPPING);
+    LOG_INFO(dctl_logger, DCTL_STOPPING).arg(app_name_);
 }
 
 
@@ -132,7 +139,7 @@ DControllerBase::parseArgs(int argc, char* argv[])
 
         case '?': {
             // We hit an invalid option.
-            isc_throw(InvalidUsage, "unsupported option: [" 
+            isc_throw(InvalidUsage, "unsupported option: ["
                       << static_cast<char>(optopt) << "] "
                       << (!optarg ? "" : optarg));
 
@@ -143,7 +150,7 @@ DControllerBase::parseArgs(int argc, char* argv[])
             // We hit a valid custom option
             if (!customOption(ch, optarg)) {
                 // This would be a programmatic error.
-                isc_throw(InvalidUsage, " Option listed but implemented?: [" 
+                isc_throw(InvalidUsage, " Option listed but implemented?: ["
                           << static_cast<char>(ch) << "] "
                           << (!optarg ? "" : optarg));
             }
@@ -166,7 +173,7 @@ DControllerBase::customOption(int /* option */, char* /*optarg*/)
 
 void
 DControllerBase::initProcess() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_INIT_PROCESS);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_INIT_PROCESS).arg(app_name_);
 
     // Invoke virtual method to instantiate the application process.
     try {
@@ -188,8 +195,8 @@ DControllerBase::initProcess() {
 
 void
 DControllerBase::establishSession() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_CCSESSION_STARTING)
-              .arg(spec_file_name_);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_CCSESSION_STARTING)
+              .arg(app_name_).arg(spec_file_name_);
 
     // Create the BIND10 command control session with the our IOService.
     cc_session_ = SessionPtr(new isc::cc::Session(
@@ -223,7 +230,8 @@ DControllerBase::establishSession() {
     int ret = 0;
     isc::data::ConstElementPtr comment = isc::config::parseAnswer(ret, answer);
     if (ret) {
-        LOG_ERROR(d2_logger, D2CTL_CONFIG_LOAD_FAIL).arg(comment->str());
+        LOG_ERROR(dctl_logger, DCTL_CONFIG_LOAD_FAIL)
+                  .arg(app_name_).arg(comment->str());
     }
 
     // Lastly, call onConnect. This allows deriving class to execute custom
@@ -233,7 +241,7 @@ DControllerBase::establishSession() {
 
 void
 DControllerBase::runProcess() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_RUN_PROCESS);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_RUN_PROCESS).arg(app_name_);
     if (!process_) {
         // This should not be possible.
         isc_throw(DControllerBaseError, "Process not initialized");
@@ -245,7 +253,8 @@ DControllerBase::runProcess() {
 }
 
 void DControllerBase::disconnectSession() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_CCSESSION_ENDING);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_CCSESSION_ENDING)
+              .arg(app_name_);
 
     // Call virtual onDisconnect. Allows deriving class to execute custom
     // logic prior to session loss.
@@ -265,24 +274,16 @@ void DControllerBase::disconnectSession() {
 
 isc::data::ConstElementPtr
 DControllerBase::dummyConfigHandler(isc::data::ConstElementPtr) {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2CTL_CONFIG_STUB);
+    LOG_DEBUG(dctl_logger, DBGLVL_START_SHUT, DCTL_CONFIG_STUB)
+             .arg(controller_->getAppName());
     return (isc::config::createAnswer(0, "Configuration accepted."));
 }
 
 isc::data::ConstElementPtr
 DControllerBase::configHandler(isc::data::ConstElementPtr new_config) {
 
-    LOG_DEBUG(d2_logger, DBGLVL_COMMAND, D2CTL_CONFIG_UPDATE)
-            .arg(new_config->str());
-
-    if (!controller_) {
-        // This should never happen as we install the handler after we
-        // instantiate the server.
-        isc::data::ConstElementPtr answer =
-            isc::config::createAnswer(1, "Configuration rejected,"
-                                   " Controller has not been initialized.");
-        return (answer);
-    }
+    LOG_DEBUG(dctl_logger, DBGLVL_COMMAND, DCTL_CONFIG_UPDATE)
+              .arg(controller_->getAppName()).arg(new_config->str());
 
     // Invoke the instance method on the controller singleton.
     return (controller_->updateConfig(new_config));
@@ -293,17 +294,8 @@ isc::data::ConstElementPtr
 DControllerBase::commandHandler(const std::string& command,
                                 isc::data::ConstElementPtr args) {
 
-    LOG_DEBUG(d2_logger, DBGLVL_COMMAND, D2CTL_COMMAND_RECEIVED)
-              .arg(command).arg(args->str());
-
-    if (!controller_ )  {
-        // This should never happen as we install the handler after we
-        // instantiate the server.
-        isc::data::ConstElementPtr answer =
-            isc::config::createAnswer(1, "Command rejected,"
-                                   " Controller has not been initialized.");
-        return (answer);
-    }
+    LOG_DEBUG(dctl_logger, DBGLVL_COMMAND, DCTL_COMMAND_RECEIVED)
+              .arg(controller_->getAppName()).arg(command).arg(args->str());
 
     // Invoke the instance method on the controller singleton.
     return (controller_->executeCommand(command, args));
@@ -399,7 +391,7 @@ DControllerBase::shutdown() {
     } else {
         // Not really a failure, but this condition is worth noting. In reality
         // it should be pretty hard to cause this.
-        LOG_WARN(d2_logger, D2CTL_NOT_RUNNING);
+        LOG_WARN(dctl_logger, DCTL_NOT_RUNNING).arg(app_name_);
     }
 
     return (isc::config::createAnswer(0, "Shutting down."));
@@ -412,7 +404,7 @@ DControllerBase::usage(const std::string & text)
         std::cerr << "Usage error: " << text << std::endl;
     }
 
-    std::cerr << "Usage: " << name_ <<  std::endl;
+    std::cerr << "Usage: " << bin_name_ <<  std::endl;
     std::cerr << "  -v: verbose output" << std::endl;
     std::cerr << "  -s: stand-alone mode (don't connect to BIND10)"
               << std::endl;
diff --git a/src/bin/d2/d_controller.h b/src/bin/d2/d_controller.h
index 05971fd..bf7a607 100644
--- a/src/bin/d2/d_controller.h
+++ b/src/bin/d2/d_controller.h
@@ -56,7 +56,7 @@ public:
         isc::Exception(file, line, what) { };
 };
 
-/// @brief Exception thrown when the application process encounters an 
+/// @brief Exception thrown when the application process encounters an
 /// operation in its event loop (i.e. run method).
 class ProcessRunError: public isc::Exception {
 public:
@@ -104,26 +104,28 @@ typedef boost::shared_ptr<isc::config::ModuleCCSession> ModuleCCSessionPtr;
 /// creation.  In integrated mode it is responsible for establishing BIND10
 /// session(s) and passes this IOService into the session creation method(s).
 /// It also provides the callback handlers for command and configuration events
-/// received from the external framework (aka BIND10).  For example, when 
+/// received from the external framework (aka BIND10).  For example, when
 /// running in integrated mode and a user alters the configuration with the
 /// bindctl tool, BIND10 will emit a configuration message which is sensed by
 /// the controller's IOService. The IOService in turn invokes the configuration
 /// callback, DControllerBase::configHandler().  If the user issues a command
 /// such as shutdown via bindctl,  BIND10 will emit a command message, which is
-/// sensed by controller's IOService which invokes the command callback, 
+/// sensed by controller's IOService which invokes the command callback,
 /// DControllerBase::commandHandler().
 ///
 /// NOTE: Derivations must supply their own static singleton instance method(s)
 /// for creating and fetching the instance. The base class declares the instance
 /// member in order for it to be available for BIND10 callback functions. This
-/// would not be required if BIND10 supported instance method callbacks.   
+/// would not be required if BIND10 supported instance method callbacks.
 class DControllerBase : public boost::noncopyable {
 public:
     /// @brief Constructor
     ///
-    /// @param name name is a text label for the controller. Typically this
-    /// would be the BIND10 module name.
-    DControllerBase(const char* name);
+    /// @param app_name is display name of the application under control. This
+    /// name appears in log statements.
+    /// @param bin_name is the name of the application executable. Typically
+    /// this matches the BIND10 module name.
+    DControllerBase(const char* app_name, const char* bin_name);
 
     /// @brief Destructor
     virtual ~DControllerBase();
@@ -150,9 +152,9 @@ public:
     /// ProcessInitError  - Failed to create and initialize application
     /// process object.
     /// SessionStartError  - Could not connect to BIND10 (integrated mode only).
-    /// ProcessRunError - A fatal error occurred while in the application 
+    /// ProcessRunError - A fatal error occurred while in the application
     /// process event loop.
-    /// SessionEndError - Could not disconnect from BIND10 (integrated mode 
+    /// SessionEndError - Could not disconnect from BIND10 (integrated mode
     /// only).
     void launch(int argc, char* argv[]);
 
@@ -334,11 +336,18 @@ protected:
         return ("");
     }
 
-    /// @brief Supplies the controller name.
+    /// @brief Fetches the name of the application under control.
     ///
-    /// @return returns the controller name string
-    const std::string getName() const {
-        return (name_);
+    /// @return returns the controller service name string
+    const std::string getAppName() const {
+        return (app_name_);
+    }
+
+    /// @brief Fetches the name of the application executable.
+    ///
+    /// @return returns the controller logger name string
+    const std::string getBinName() const {
+        return (bin_name_);
     }
 
     /// @brief Supplies whether or not the controller is in stand alone mode.
@@ -481,9 +490,14 @@ private:
     void usage(const std::string& text);
 
 private:
-    /// @brief Text label for the controller. Typically this would be the
-    /// BIND10 module name.
-    std::string name_;
+    /// @brief Display name of the service under control. This name
+    /// appears in log statements.
+    std::string app_name_;
+
+    /// @brief Name of the service executable. By convention this matches
+    /// the BIND10 module name. It is also used to establish the logger
+    /// name.
+    std::string bin_name_;
 
     /// @brief Indicates if the controller stand alone mode is enabled. When
     /// enabled, the controller will not establish connectivity with BIND10.
diff --git a/src/bin/d2/d_process.h b/src/bin/d2/d_process.h
index 8011191..11b0a09 100644
--- a/src/bin/d2/d_process.h
+++ b/src/bin/d2/d_process.h
@@ -54,15 +54,14 @@ class DProcessBase {
 public:
     /// @brief Constructor
     ///
-    /// @param name name is a text label for the process. Generally used
+    /// @param app_name is a text label for the process. Generally used
     /// in log statements, but otherwise arbitrary.
     /// @param io_service is the io_service used by the caller for
     /// asynchronous event handling.
     ///
     /// @throw DProcessBaseError is io_service is NULL.
-    DProcessBase(const char* name, IOServicePtr io_service) : name_(name),
-        io_service_(io_service), shut_down_flag_(false) {
-
+    DProcessBase(const char* app_name, IOServicePtr io_service)
+        : app_name_(app_name), io_service_(io_service), shut_down_flag_(false) {
         if (!io_service_) {
             isc_throw (DProcessBaseError, "IO Service cannot be null");
         }
@@ -138,11 +137,11 @@ public:
         shut_down_flag_ = value;
     }
 
-    /// @brief Fetches the name of the controller.
+    /// @brief Fetches the application name.
     ///
-    /// @return returns a reference the controller's name string.
-    const std::string getName() const {
-        return (name_);
+    /// @return returns a the application name string.
+    const std::string getAppName() const {
+        return (app_name_);
     }
 
     /// @brief Fetches the controller's IOService.
@@ -153,7 +152,7 @@ public:
     }
 
     /// @brief Convenience method for stopping IOservice processing.
-    /// Invoking this will cause the process to exit any blocking 
+    /// Invoking this will cause the process to exit any blocking
     /// IOService method such as run().  No further IO events will be
     /// processed.
     void stopIOService() {
@@ -163,7 +162,7 @@ public:
 private:
     /// @brief Text label for the process. Generally used in log statements,
     /// but otherwise can be arbitrary.
-    std::string name_;
+    std::string app_name_;
 
     /// @brief The IOService to be used for asynchronous event handling.
     IOServicePtr io_service_;
diff --git a/src/bin/d2/tests/d2_controller_unittests.cc b/src/bin/d2/tests/d2_controller_unittests.cc
index 75a7f3b..a2b3374 100644
--- a/src/bin/d2/tests/d2_controller_unittests.cc
+++ b/src/bin/d2/tests/d2_controller_unittests.cc
@@ -63,8 +63,11 @@ TEST_F(D2ControllerTest, basicInstanceTesting) {
     ASSERT_TRUE(controller);
     ASSERT_NO_THROW(boost::dynamic_pointer_cast<D2Controller>(controller));
 
-    // Verify that controller's name is correct.
-    EXPECT_TRUE(checkName(D2_MODULE_NAME));
+    // Verify that controller's app name is correct.
+    EXPECT_TRUE(checkAppName(D2Controller::d2_app_name_));
+
+    // Verify that controller's bin name is correct.
+    EXPECT_TRUE(checkBinName(D2Controller::d2_bin_name_));
 
     // Verify that controller's spec file name is correct.
     EXPECT_TRUE(checkSpecFileName(D2_SPECFILE_LOCATION));
diff --git a/src/bin/d2/tests/d2_test.py b/src/bin/d2/tests/d2_test.py
index 7011cfc..7548672 100644
--- a/src/bin/d2/tests/d2_test.py
+++ b/src/bin/d2/tests/d2_test.py
@@ -162,7 +162,7 @@ class TestD2Daemon(unittest.TestCase):
         (returncode, output, error) = self.runCommand(["../b10-dhcp-ddns", 
                                                        "-s", "-v"])
         output_text = str(output) + str(error)
-        self.assertEqual(output_text.count("D2CTL_STARTING"), 1)
+        self.assertEqual(output_text.count("DCTL_STARTING"), 1)
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/src/bin/d2/tests/d_controller_unittests.cc b/src/bin/d2/tests/d_controller_unittests.cc
index 501fe13..26b0e0e 100644
--- a/src/bin/d2/tests/d_controller_unittests.cc
+++ b/src/bin/d2/tests/d_controller_unittests.cc
@@ -52,8 +52,11 @@ TEST_F(DStubControllerTest, basicInstanceTesting) {
     ASSERT_TRUE(controller);
     ASSERT_NO_THROW(boost::dynamic_pointer_cast<DStubController>(controller));
 
-    // Verify that controller's name is correct.
-    EXPECT_TRUE(checkName(D2_MODULE_NAME));
+    // Verify that controller's app name is correct.
+    EXPECT_TRUE(checkAppName(DStubController::stub_app_name_));
+
+    // Verify that controller's bin name is correct.
+    EXPECT_TRUE(checkBinName(DStubController::stub_bin_name_));
 
     // Verify that controller's spec file name is correct.
     EXPECT_TRUE(checkSpecFileName(D2_SPECFILE_LOCATION));
diff --git a/src/bin/d2/tests/d_test_stubs.cc b/src/bin/d2/tests/d_test_stubs.cc
index f348dff..33a2ff6 100644
--- a/src/bin/d2/tests/d_test_stubs.cc
+++ b/src/bin/d2/tests/d_test_stubs.cc
@@ -33,7 +33,6 @@ DStubProcess::DStubProcess(const char* name, IOServicePtr io_service)
 
 void
 DStubProcess::init() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_PROCESS_INIT);
     if (SimFailure::shouldFailOn(SimFailure::ftProcessInit)) {
         // Simulates a failure to instantiate the process.
         isc_throw(DProcessBaseError, "DStubProcess simulated init() failure");
@@ -48,24 +47,19 @@ DStubProcess::run() {
     // To use run(), the "managing" layer must issue an io_service::stop
     // or the call to run will continue to block, and shutdown will not
     // occur.
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_RUN_ENTER);
     IOServicePtr& io_service = getIoService();
     while (!shouldShutdown()) {
         try {
             io_service->run_one();
         } catch (const std::exception& ex) {
-            LOG_FATAL(d2_logger, D2PRC_FAILED).arg(ex.what());
             isc_throw (DProcessBaseError,
                 std::string("Process run method failed:") + ex.what());
         }
     }
-
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_RUN_EXIT);
 };
 
 void
 DStubProcess::shutdown() {
-    LOG_DEBUG(d2_logger, DBGLVL_START_SHUT, D2PRC_SHUTDOWN);
     if (SimFailure::shouldFailOn(SimFailure::ftProcessShutdown)) {
         // Simulates a failure during shutdown process.
         isc_throw(DProcessBaseError, "DStubProcess simulated shutdown failure");
@@ -75,10 +69,7 @@ DStubProcess::shutdown() {
 }
 
 isc::data::ConstElementPtr
-DStubProcess::configure(isc::data::ConstElementPtr config_set) {
-    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC,
-              D2PRC_CONFIGURE).arg(config_set->str());
-
+DStubProcess::configure(isc::data::ConstElementPtr /*config_set*/) {
     if (SimFailure::shouldFailOn(SimFailure::ftProcessConfigure)) {
         // Simulates a process configure failure.
         return (isc::config::createAnswer(1,
@@ -90,10 +81,7 @@ DStubProcess::configure(isc::data::ConstElementPtr config_set) {
 
 isc::data::ConstElementPtr
 DStubProcess::command(const std::string& command,
-                      isc::data::ConstElementPtr args) {
-    LOG_DEBUG(d2_logger, DBGLVL_TRACE_BASIC,
-              D2PRC_COMMAND).arg(command).arg(args->str());
-
+                      isc::data::ConstElementPtr /* args */) {
     isc::data::ConstElementPtr answer;
     if (SimFailure::shouldFailOn(SimFailure::ftProcessCommand)) {
         // Simulates a process command execution failure.
@@ -120,11 +108,16 @@ const char* DStubController::stub_ctl_command_("spiffy");
 // Define custom command line option command supported by DStubController.
 const char* DStubController::stub_option_x_ = "x";
 
+/// @brief Defines the app name used to construct the controller
+const char* DStubController::stub_app_name_ = "TestService";
+
+/// @brief Defines the bin name used to construct the controller
+const char* DStubController::stub_bin_name_ = "TestBin";
+
 DControllerBasePtr&
 DStubController::instance() {
     // If the singleton hasn't been created, do it now.
     if (!getController()) {
-        //setController(new DStubController());
         DControllerBasePtr p(new DStubController());
         setController(p);
     }
@@ -133,7 +126,7 @@ DStubController::instance() {
 }
 
 DStubController::DStubController()
-    : DControllerBase(D2_MODULE_NAME) {
+    : DControllerBase(stub_app_name_, stub_bin_name_) {
 
     if (getenv("B10_FROM_BUILD")) {
         setSpecFileName(std::string(getenv("B10_FROM_BUILD")) +
@@ -166,7 +159,7 @@ DProcessBase* DStubController::createProcess() {
     }
 
     // This should be a successful instantiation.
-    return (new DStubProcess(getName().c_str(), getIOService()));
+    return (new DStubProcess(getAppName().c_str(), getIOService()));
 }
 
 isc::data::ConstElementPtr
diff --git a/src/bin/d2/tests/d_test_stubs.h b/src/bin/d2/tests/d_test_stubs.h
index 1659e52..e634762 100644
--- a/src/bin/d2/tests/d_test_stubs.h
+++ b/src/bin/d2/tests/d_test_stubs.h
@@ -190,6 +190,12 @@ public:
     /// DStubController.
     static const char* stub_option_x_;
 
+    /// @brief Defines the app name used to construct the controller
+    static const char* stub_app_name_;
+
+    /// @brief Defines the executable name used to construct the controller
+    static const char* stub_bin_name_;
+
 protected:
     /// @brief Handles additional command line options that are supported
     /// by DStubController.  This implementation supports an option "-x".
@@ -291,13 +297,24 @@ public:
         return ((*instanceGetter_)());
     }
 
-    /// @brief Returns true if the Controller's name matches the given value.
+    /// @brief Returns true if the Controller's app name matches the
+    /// given value.
+    ///
+    /// @param should_be is the value to compare against.
+    ///
+    /// @return returns true if the values are equal.
+    bool checkAppName(const std::string& should_be) {
+        return (getController()->getAppName().compare(should_be) == 0);
+    }
+
+    /// @brief Returns true if the Controller's service name matches the
+    /// given value.
     ///
     /// @param should_be is the value to compare against.
     ///
     /// @return returns true if the values are equal.
-    bool checkName(const std::string& should_be) {
-        return (getController()->getName().compare(should_be) == 0);
+    bool checkBinName(const std::string& should_be) {
+        return (getController()->getBinName().compare(should_be) == 0);
     }
 
     /// @brief Returns true if the Controller's spec file name matches the



More information about the bind10-changes mailing list