Raft logic fix: forcing active mode when allocation activity is detected

This commit is contained in:
Pavel Kirienko
2015-05-11 13:26:53 +03:00
parent 5af19f82c3
commit d623eee54a
5 changed files with 32 additions and 3 deletions
@@ -763,7 +763,8 @@ public:
{
return res;
}
append_entries_client_.setCallback(AppendEntriesResponseCallback(this, &RaftCore::handleAppendEntriesResponse));
append_entries_client_.setCallback(AppendEntriesResponseCallback(this,
&RaftCore::handleAppendEntriesResponse));
append_entries_client_.setRequestTimeout(update_interval_);
for (uint8_t i = 0; i < NumRequestVoteClients; i++)
@@ -773,7 +774,8 @@ public:
{
return res;
}
request_vote_clients_[i]->setCallback(RequestVoteResponseCallback(this, &RaftCore::handleRequestVoteResponse));
request_vote_clients_[i]->setCallback(RequestVoteResponseCallback(this,
&RaftCore::handleRequestVoteResponse));
request_vote_clients_[i]->setRequestTimeout(update_interval_);
}
@@ -785,6 +787,14 @@ public:
return 0;
}
/**
* Normally should be called when there's allocation activity on the bus.
*/
void forceActiveMode()
{
setActiveMode(true); // If the current state was Follower, active mode may be toggling quickly for some time
}
/**
* This function is mostly needed for testing.
*/
@@ -135,6 +135,11 @@ class Server : IAllocationRequestHandler
}
}
virtual void handleAllocationActivityDetection(const ReceivedDataStructure<Allocation>&)
{
raft_core_.forceActiveMode();
}
/*
* Methods of INodeDiscoveryHandler
*/