From: Marcin Siodelski Date: Thu, 19 Jul 2018 13:23:51 +0000 (+0200) Subject: [5675] Resolve the problem of no logging paused state in waiting state. X-Git-Tag: ha_phase2~41^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6275b52fced272f7ef651562a2c52f4334bc56f;p=thirdparty%2Fkea.git [5675] Resolve the problem of no logging paused state in waiting state. --- diff --git a/src/hooks/dhcp/high_availability/ha_service.cc b/src/hooks/dhcp/high_availability/ha_service.cc index 0f7a608819..288f9d762a 100644 --- a/src/hooks/dhcp/high_availability/ha_service.cc +++ b/src/hooks/dhcp/high_availability/ha_service.cc @@ -123,6 +123,9 @@ HAService::backupStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); + + // Log if the state machine is paused. + conditionalLogPausedState(); } // There is nothing to do in that state. This server simply receives @@ -138,6 +141,9 @@ HAService::normalStateHandler() { if (doOnEntry()) { query_filter_.serveDefaultScopes(); adjustNetworkState(); + + // Log if the state machine is paused. + conditionalLogPausedState(); } scheduleHeartbeat(); @@ -193,6 +199,9 @@ HAService::partnerDownStateHandler() { query_filter_.serveDefaultScopes(); } adjustNetworkState(); + + // Log if the state machine is paused. + conditionalLogPausedState(); } scheduleHeartbeat(); @@ -238,6 +247,9 @@ HAService::readyStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); + + // Log if the state machine is paused. + conditionalLogPausedState(); } scheduleHeartbeat(); @@ -300,6 +312,9 @@ HAService::syncingStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); + + // Log if the state machine is paused. + conditionalLogPausedState(); } if (isModelPaused()) { @@ -375,6 +390,9 @@ HAService::terminatedStateHandler() { // In the terminated state we don't send heartbeat. communication_state_->stopHeartbeat(); + // Log if the state machine is paused. + conditionalLogPausedState(); + LOG_ERROR(ha_logger, HA_TERMINATED); } @@ -389,6 +407,9 @@ HAService::waitingStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); + + // Log if the state machine is paused. + conditionalLogPausedState(); } // Only schedule the heartbeat for non-backup servers. @@ -511,14 +532,6 @@ HAService::verboseTransition(const unsigned state) { .arg(new_state_name); } } - - // Inform the administrator if the state machine is paused. - if (isModelPaused()) { - std::string state_name = stateToString(state); - boost::to_upper(state_name); - LOG_INFO(ha_logger, HA_STATE_MACHINE_PAUSED) - .arg(state_name); - } } bool @@ -531,6 +544,17 @@ HAService::unpause() { return (false); } +void +HAService::conditionalLogPausedState() const { + // Inform the administrator if the state machine is paused. + if (isModelPaused()) { + std::string state_name = stateToString(getCurrState()); + boost::to_upper(state_name); + LOG_INFO(ha_logger, HA_STATE_MACHINE_PAUSED) + .arg(state_name); + } +} + void HAService::serveDefaultScopes() { query_filter_.serveDefaultScopes(); diff --git a/src/hooks/dhcp/high_availability/ha_service.h b/src/hooks/dhcp/high_availability/ha_service.h index 40e842f602..58a2d6c83e 100644 --- a/src/hooks/dhcp/high_availability/ha_service.h +++ b/src/hooks/dhcp/high_availability/ha_service.h @@ -255,6 +255,16 @@ public: /// machine was not paused when this method was invoked. bool unpause(); +protected: + + /// @brief Logs if the server is paused in the current state. + /// + /// This method is internally called by the state handlers upon + /// entry to a new state. + void conditionalLogPausedState() const; + +public: + /// @brief Instructs the HA service to serve default scopes. /// /// This method is mostly useful for unit testing. The scopes need to be