mirror of https://gitee.com/bigwinds/arangodb
assuming leadership separated in a preparation part and in a action part
This commit is contained in:
parent
f71109a969
commit
27e4b170cf
|
@ -864,13 +864,24 @@ void Agent::beginShutdown() {
|
|||
|
||||
|
||||
bool Agent::prepareLead() {
|
||||
|
||||
// Key value stores
|
||||
rebuildDBs();
|
||||
|
||||
// Reset last acknowledged
|
||||
{
|
||||
MUTEX_LOCKER(mutexLocker, _ioLock);
|
||||
for (auto const& i : _config.active()) {
|
||||
_lastAcked[i] = system_clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// Becoming leader
|
||||
bool Agent::lead() {
|
||||
// Key value stores
|
||||
rebuildDBs();
|
||||
|
||||
// Wake up run
|
||||
{
|
||||
|
@ -878,17 +889,12 @@ bool Agent::lead() {
|
|||
guard.broadcast();
|
||||
}
|
||||
|
||||
// Agency configuration
|
||||
term_t myterm;
|
||||
// Reset last acknowledged
|
||||
{
|
||||
MUTEX_LOCKER(mutexLocker, _ioLock);
|
||||
for (auto const& i : _config.active()) {
|
||||
_lastAcked[i] = system_clock::now();
|
||||
}
|
||||
myterm = _constituent.term();
|
||||
}
|
||||
|
||||
// Agency configuration
|
||||
auto agency = std::make_shared<Builder>();
|
||||
agency->openArray();
|
||||
agency->openArray();
|
||||
|
|
|
@ -176,6 +176,11 @@ void Constituent::followNoLock(term_t t) {
|
|||
/// Become leader
|
||||
void Constituent::lead(term_t term,
|
||||
std::map<std::string, bool> const& votes) {
|
||||
|
||||
|
||||
// we need to rebuild spear_head and read_db
|
||||
_agent->prepareLead();
|
||||
|
||||
{
|
||||
MUTEX_LOCKER(guard, _castLock);
|
||||
|
||||
|
@ -200,7 +205,7 @@ void Constituent::lead(term_t term,
|
|||
}
|
||||
|
||||
// give some debug output _id never is changed after
|
||||
if (!votes.empty()) {
|
||||
/* if (!votes.empty()) {
|
||||
std::stringstream ss;
|
||||
ss << _id << ": Converted to leader in term " << _term << " with votes: ";
|
||||
|
||||
|
@ -209,11 +214,7 @@ void Constituent::lead(term_t term,
|
|||
}
|
||||
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << ss.str();
|
||||
}
|
||||
|
||||
// we need to rebuild spear_head and read_db
|
||||
_agent->prepareLead();
|
||||
|
||||
}*/
|
||||
|
||||
// we need to start work as leader
|
||||
_agent->lead();
|
||||
|
|
Loading…
Reference in New Issue