示例#1
0
    // 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
0
文件: rs.cpp 项目: MohdVara/mongo
    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
0
文件: rs.cpp 项目: FromPointer/mongo
    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
0
文件: rs.cpp 项目: sivy/mongo
    // 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
0
文件: rs.cpp 项目: web-os/mongo
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
0
文件: rs.cpp 项目: mapleoin/mongo
 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
0
文件: rs.cpp 项目: Cassie90/mongo
    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();
        }
    }