diff options
author | Eric Milkie <milkie@10gen.com> | 2014-07-22 13:31:15 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2014-07-22 17:07:47 -0400 |
commit | f2e7e52e80b4f755f49981a7b87c7870401b4cd1 (patch) | |
tree | fa458030025d33e581238e2fd3a3a33b03b2bf6b | |
parent | 325aa2766225a27a46ab30bba8c8aa3c0a5c9f3a (diff) | |
download | mongo-f2e7e52e80b4f755f49981a7b87c7870401b4cd1.tar.gz |
SERVER-14624 switch to using new MemberConfig methods
-rw-r--r-- | src/mongo/db/repl/member_config.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_impl.cpp | 16 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/mongo/db/repl/member_config.cpp b/src/mongo/db/repl/member_config.cpp index 4b59c7a7b0c..563c3d41159 100644 --- a/src/mongo/db/repl/member_config.cpp +++ b/src/mongo/db/repl/member_config.cpp @@ -270,7 +270,7 @@ namespace { tags.done(); configBuilder.append("slaveDelay", _slaveDelay.total_seconds()); - configBuilder.append("votes", _isVoter? 1 : 0); + configBuilder.append("votes", getNumVotes()); return configBuilder.obj(); } diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp index 6145de301c5..6dd6ed7acba 100644 --- a/src/mongo/db/repl/topology_coordinator_impl.cpp +++ b/src/mongo/db/repl/topology_coordinator_impl.cpp @@ -431,7 +431,7 @@ namespace repl { } _lastVote.when = now; _lastVote.who = whoid; - vote = _selfConfig().isVoter() ? 1 : 0; + vote = _selfConfig().getNumVotes(); invariant( _currentConfig.getMemberAt(hopefulIndex).getId() == whoid ); log() << "replSet info voting yea for " << _currentConfig.getMemberAt(hopefulIndex).getHostAndPort().toString() @@ -578,9 +578,8 @@ namespace repl { // make sure the electable set is up-to-date if (_aMajoritySeemsToBeUp() - && !_selfConfig().isArbiter() // not an arbiter - && (_selfConfig().getPriority() > 0) // not priority 0 - && (_stepDownUntil <= now) // stepDown timer has expired + && _selfConfig().isElectable() // not an arbiter and not priority 0 + && (_stepDownUntil <= now) // stepDown timer has expired && (_memberState == MemberState::RS_SECONDARY) // we are within 10 seconds of primary && (latestOp == 0 || _lastApplied.getSecs() >= latestOp - 10)) { @@ -779,9 +778,8 @@ namespace repl { // election candidate. // If we can't elect ourselves due to config, can't become a candidate. - if (!_selfConfig().isArbiter() // not an arbiter - && (_selfConfig().getPriority() > 0) // not priority 0 - && (_stepDownUntil <= now) // stepDown timer has expired + if (_selfConfig().isElectable() // not an arbiter and not priority 0 + && (_stepDownUntil <= now) // stepDown timer has expired && (_memberState == MemberState::RS_SECONDARY)) { OCCASIONALLY log() << "replSet I don't see a primary and I can't elect myself"; return None; @@ -842,7 +840,7 @@ namespace repl { it != _hbdata.end(); ++it) { if (it->up()) { - vUp += _currentConfig.getMemberAt(it->getConfigIndex()).isVoter() ? 1 : 0; + vUp += _currentConfig.getMemberAt(it->getConfigIndex()).getNumVotes(); } } @@ -855,7 +853,7 @@ namespace repl { for (ReplicaSetConfig::MemberIterator it = _currentConfig.membersBegin(); it != _currentConfig.membersEnd(); ++it) { - vTot += it->isVoter() ? 1 : 0; + vTot += it->getNumVotes(); } if( vTot % 2 == 0 && vTot && complain++ == 0 ) log() << "replSet warning: even number of voting members in replica set config - " |