Commit 327915bc authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5674] State machine pausing dealt with in transition.

parent a5fab941
......@@ -55,6 +55,7 @@ HAService::HAService(const IOServicePtr& io_service, const NetworkStatePtr& netw
}
startModel(HA_WAITING_ST);
state_machine_control_.notify(HA_WAITING_ST);
LOG_INFO(ha_logger, HA_SERVICE_STARTED)
.arg(HAConfig::HAModeToString(config->getHAMode()))
......@@ -115,7 +116,6 @@ HAService::backupStateHandler() {
if (doOnEntry()) {
query_filter_.serveNoScopes();
adjustNetworkState();
state_machine_control_.notify(getCurrState());
}
// There is nothing to do in that state. This server simply receives
......@@ -131,7 +131,6 @@ HAService::normalStateHandler() {
if (doOnEntry()) {
query_filter_.serveDefaultScopes();
adjustNetworkState();
state_machine_control_.notify(getCurrState());
}
scheduleHeartbeat();
......@@ -187,8 +186,6 @@ HAService::partnerDownStateHandler() {
query_filter_.serveDefaultScopes();
}
adjustNetworkState();
state_machine_control_.notify(getCurrState());
}
scheduleHeartbeat();
......@@ -234,7 +231,6 @@ HAService::readyStateHandler() {
if (doOnEntry()) {
query_filter_.serveNoScopes();
adjustNetworkState();
state_machine_control_.notify(getCurrState());
}
scheduleHeartbeat();
......@@ -297,7 +293,6 @@ HAService::syncingStateHandler() {
if (doOnEntry()) {
query_filter_.serveNoScopes();
adjustNetworkState();
state_machine_control_.notify(getCurrState());
}
if (state_machine_control_.amPaused()) {
......@@ -369,7 +364,6 @@ HAService::terminatedStateHandler() {
if (doOnEntry()) {
query_filter_.serveDefaultScopes();
adjustNetworkState();
state_machine_control_.notify(getCurrState());
// In the terminated state we don't send heartbeat.
communication_state_->stopHeartbeat();
......@@ -388,7 +382,6 @@ HAService::waitingStateHandler() {
if (doOnEntry()) {
query_filter_.serveNoScopes();
adjustNetworkState();
state_machine_control_.notify(getCurrState());
}
// Only schedule the heartbeat for non-backup servers.
......@@ -489,6 +482,7 @@ HAService::verboseTransition(const unsigned state) {
// Do the actual transition.
transition(state, getNextEvent());
state_machine_control_.notify(state);
// Inform the administrator whether or not lease updates are generated.
// Updates are never generated by a backup server so it doesn't make
......
......@@ -3559,6 +3559,8 @@ TEST_F(HAServiceStateMachineTest, stateTransitionsLoadBalancingPause) {
state_machine->getStateConfig(HA_LOAD_BALANCING_ST)->setPausing("always");
state_machine->getStateConfig(HA_PARTNER_DOWN_ST)->setPausing("always");
state_machine->getStateConfig(HA_READY_ST)->setPausing("always");
state_machine->getStateConfig(HA_SYNCING_ST)->setPausing("always");
state_machine->getStateConfig(HA_TERMINATED_ST)->setPausing("always");
state_machine->getStateConfig(HA_WAITING_ST)->setPausing("always");
startService(valid_config);
......@@ -3619,9 +3621,15 @@ TEST_F(HAServiceStateMachineTest, stateTransitionsLoadBalancingPause) {
TEST_F(HAServiceStateMachineTest, syncingTransitionsLoadBalancingPause) {
HAConfigPtr valid_config = createValidConfiguration();
// Pause state machine in syncing state.
auto state_config = valid_config->getStateMachineConfig()->getStateConfig(HA_SYNCING_ST);
state_config->setPausing("always");
auto state_machine = valid_config->getStateMachineConfig();
// Pause state machine in various states.
state_machine->getStateConfig(HA_LOAD_BALANCING_ST)->setPausing("always");
state_machine->getStateConfig(HA_PARTNER_DOWN_ST)->setPausing("always");
state_machine->getStateConfig(HA_READY_ST)->setPausing("always");
state_machine->getStateConfig(HA_SYNCING_ST)->setPausing("always");
state_machine->getStateConfig(HA_TERMINATED_ST)->setPausing("always");
state_machine->getStateConfig(HA_WAITING_ST)->setPausing("always");
startService(valid_config);
waitForEvent(HAService::HA_HEARTBEAT_COMPLETE_EVT);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment