本文整理汇总了C++中ReplSetConfig::saveConfigLocally方法的典型用法代码示例。如果您正苦于以下问题:C++ ReplSetConfig::saveConfigLocally方法的具体用法?C++ ReplSetConfig::saveConfigLocally怎么用?C++ ReplSetConfig::saveConfigLocally使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReplSetConfig
的用法示例。
在下文中一共展示了ReplSetConfig::saveConfigLocally方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _loadConfigFinish
// Our own config must be the first one.
bool ReplSetImpl::_loadConfigFinish(OperationContext* txn, vector<ReplSetConfig*>& cfgs) {
int v = -1;
ReplSetConfig *highest = 0;
int myVersion = -2000;
int n = 0;
for (vector<ReplSetConfig*>::iterator i = cfgs.begin(); i != cfgs.end(); i++) {
ReplSetConfig* cfg = *i;
DEV { LOG(1) << n+1 << " config shows version " << cfg->version << rsLog; }
if (++n == 1) myVersion = cfg->version;
if (cfg->ok() && cfg->version > v) {
highest = cfg;
v = cfg->version;
}
}
verify(highest);
if (!initFromConfig(txn, *highest))
return false;
if (highest->version > myVersion && highest->version >= 0) {
log() << "replSet got config version " << highest->version
<< " from a remote, saving locally" << rsLog;
highest->saveConfigLocally(txn, BSONObj());
}
return true;
}
示例2: haveNewConfig
void ReplSet::haveNewConfig(ReplSetConfig& newConfig, bool addComment) {
bo comment;
if( addComment )
comment = BSON( "msg" << "Reconfig set" << "version" << newConfig.version );
newConfig.saveConfigLocally(comment);
try {
BSONObj oldConfForAudit = config().asBson();
BSONObj newConfForAudit = newConfig.asBson();
audit::logReplSetReconfig(ClientBasic::getCurrent(),
&oldConfForAudit,
&newConfForAudit);
if (initFromConfig(newConfig, true)) {
log() << "replSet replSetReconfig new config saved locally" << rsLog;
}
}
catch(DBException& e) {
log() << "replSet error unexpected exception in haveNewConfig() : " << e.toString() << rsLog;
_fatal();
}
catch(...) {
log() << "replSet error unexpected exception in haveNewConfig()" << rsLog;
_fatal();
}
}
示例3: haveNewConfig
void ReplSet::haveNewConfig(OperationContext* txn, ReplSetConfig& newConfig, bool addComment) {
bo comment;
if( addComment )
comment = BSON( "msg" << "Reconfig set" << "version" << newConfig.version );
newConfig.saveConfigLocally(txn, comment);
try {
BSONObj oldConfForAudit = config().asBson();
BSONObj newConfForAudit = newConfig.asBson();
audit::logReplSetReconfig(ClientBasic::getCurrent(),
&oldConfForAudit,
&newConfForAudit);
if (initFromConfig(txn, newConfig, true)) {
log() << "replSet replSetReconfig new config saved locally" << rsLog;
}
}
catch (const DBException& e) {
log() << "replSet error unexpected exception in haveNewConfig() : " << e.toString() << rsLog;
fassertFailedNoTrace(18755);
}
catch (...) {
std::terminate();
}
}
示例4: _loadConfigFinish
// Our own config must be the first one.
bool ReplSetImpl::_loadConfigFinish(vector<ReplSetConfig>& cfgs) {
int v = -1;
ReplSetConfig *highest = 0;
int myVersion = -2000;
int n = 0;
for( vector<ReplSetConfig>::iterator i = cfgs.begin(); i != cfgs.end(); i++ ) {
ReplSetConfig& cfg = *i;
if( ++n == 1 ) myVersion = cfg.version;
if( cfg.ok() && cfg.version > v ) {
highest = &cfg;
v = cfg.version;
}
}
assert( highest );
if( !initFromConfig(*highest) )
return false;
if( highest->version > myVersion && highest->version >= 0 ) {
log() << "replSet got config version " << highest->version << " from a remote, saving locally" << rsLog;
writelock lk("admin.");
highest->saveConfigLocally(BSONObj());
}
return true;
}
示例5: haveNewConfig
void ReplSet::haveNewConfig(ReplSetConfig& newConfig, bool addComment) {
bo comment;
if( addComment )
comment = BSON( "msg" << "Reconfig set" << "version" << newConfig.version );
newConfig.saveConfigLocally(comment);
try {
if (initFromConfig(newConfig, true)) {
log() << "replSet replSetReconfig new config saved locally" << rsLog;
}
}
catch(DBException& e) {
if( e.getCode() == 13497 /* removed from set */ ) {
cc().shutdown();
dbexit( EXIT_CLEAN , "removed from replica set" ); // never returns
assert(0);
}
log() << "replSet error unexpected exception in haveNewConfig() : " << e.toString() << rsLog;
_fatal();
}
catch(...) {
log() << "replSet error unexpected exception in haveNewConfig()" << rsLog;
_fatal();
}
}
示例6: haveNewConfig
void ReplSet::haveNewConfig(ReplSetConfig& newConfig, bool addComment) {
lock l(this); // convention is to lock replset before taking the db rwlock
writelock lk("");
bo comment;
if( addComment )
comment = BSON( "msg" << "Reconfig set" << "version" << newConfig.version );
newConfig.saveConfigLocally(comment);
try {
initFromConfig(newConfig, true);
log() << "replSet replSetReconfig new config saved locally" << rsLog;
}
catch(DBException& e) {
log() << "replSet error unexpected exception in haveNewConfig() : " << e.toString() << rsLog;
_fatal();
}
catch(...) {
log() << "replSet error unexpected exception in haveNewConfig()" << rsLog;
_fatal();
}
}
示例7: haveNewConfig
void ReplSet::haveNewConfig(ReplSetConfig& newConfig, bool addComment) {
bo comment;
if( addComment )
comment = BSON( "msg" << "Reconfig set" << "version" << newConfig.version );
newConfig.saveConfigLocally(comment);
try {
if (initFromConfig(newConfig, true)) {
log() << "replSet replSetReconfig new config saved locally" << rsLog;
}
}
catch(DBException& e) {
log() << "replSet error unexpected exception in haveNewConfig() : " << e.toString() << rsLog;
_fatal();
}
catch(...) {
log() << "replSet error unexpected exception in haveNewConfig()" << rsLog;
_fatal();
}
}