本文整理汇总了C++中ReplSetConfig::chainingAllowed方法的典型用法代码示例。如果您正苦于以下问题:C++ ReplSetConfig::chainingAllowed方法的具体用法?C++ ReplSetConfig::chainingAllowed怎么用?C++ ReplSetConfig::chainingAllowed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReplSetConfig
的用法示例。
在下文中一共展示了ReplSetConfig::chainingAllowed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initFromConfig
// @param reconf true if this is a reconfiguration and not an initial load of the configuration.
// @return true if ok; throws if config really bad; false if config doesn't include self
bool ReplSetImpl::initFromConfig(OperationContext* txn, ReplSetConfig& c, bool reconf) {
// NOTE: haveNewConfig() writes the new config to disk before we get here. So
// we cannot error out at this point, except fatally. Check errors earlier.
lock lk(this);
if (!getLastErrorDefault.isEmpty() || !c.getLastErrorDefaults.isEmpty()) {
getLastErrorDefault = c.getLastErrorDefaults;
}
list<ReplSetConfig::MemberCfg*> newOnes;
// additive short-cuts the new config setup. If we are just adding a
// node/nodes and nothing else is changing, this is additive. If it's
// not a reconfig, we're not adding anything
bool additive = reconf;
bool updateConfigs = false;
{
unsigned nfound = 0;
int me = 0;
for (vector<ReplSetConfig::MemberCfg>::iterator i = c.members.begin();
i != c.members.end();
i++) {
ReplSetConfig::MemberCfg& m = *i;
if (isSelf(m.h)) {
me++;
}
if (reconf) {
const Member *old = findById(m._id);
if (old) {
nfound++;
verify((int) old->id() == m._id);
if (!old->config().isSameIgnoringTags(m)) {
additive = false;
}
if (!updateConfigs && old->config() != m) {
updateConfigs = true;
}
}
else {
newOnes.push_back(&m);
}
}
}
if (me == 0) { // we're not in the config -- we must have been removed
if (state().removed()) {
// already took note of our ejection from the set
// so just sit tight and poll again
return false;
}
_members.orphanAll();
// kill off rsHealthPoll threads (because they Know Too Much about our past)
endOldHealthTasks();
// clear sync target to avoid faulty sync attempts; we must do this before we
// close sockets, since that will trigger the bgsync thread to reconnect.
BackgroundSync::get()->clearSyncTarget();
// close sockets to force clients to re-evaluate this member
MessagingPort::closeAllSockets(0);
// take note of our ejection
changeState(MemberState::RS_REMOVED);
// go into holding pattern
log() << "replSet info self not present in the repl set configuration:" << rsLog;
log() << c.toString() << rsLog;
loadConfig(txn); // redo config from scratch
return false;
}
uassert(13302, "replSet error self appears twice in the repl set configuration", me<=1);
if (state().removed()) {
// If we were removed and have now been added back in, switch state.
changeState(MemberState::RS_RECOVERING);
}
// if we found different members that the original config, reload everything
if (reconf && config().members.size() != nfound)
additive = false;
}
// If we are changing chaining rules, we don't want this to be an additive reconfig so that
// the primary can step down and the sync targets change.
// TODO: This can be removed once SERVER-5208 is fixed.
if (reconf && config().chainingAllowed() != c.chainingAllowed()) {
additive = false;
}
_cfg = new ReplSetConfig(c);
// config() is same thing but const, so we use that when we can for clarity below
dassert(&config() == _cfg);
verify(config().ok());
verify(_name.empty() || _name == config()._id);
//.........这里部分代码省略.........