Example #1
0
    /* comment MUST only be set when initiating the set by the initiator */
    void ReplSetConfig::saveConfigLocally(bo comment) {
        checkRsConfig();
        log() << "replSet info saving a newer config version to local.system.replset" << rsLog;
        {
            writelock lk("");
            Client::Context cx( rsConfigNs );
            cx.db()->flushFiles(true);

            //theReplSet->lastOpTimeWritten = ??;
            //rather than above, do a logOp()? probably
            BSONObj o = asBson();
            Helpers::putSingletonGod(rsConfigNs.c_str(), o, false/*logOp=false; local db so would work regardless...*/);
            if( !comment.isEmpty() && (!theReplSet || theReplSet->isPrimary()) )
                logOpInitiate(comment);

            cx.db()->flushFiles(true);
        }
        log() << "replSet saveConfigLocally done" << rsLog;
    }
Example #2
0
 /* comment MUST only be set when initiating the set by the initiator */
 void ReplSetConfig::saveConfigLocally(bo comment, bool onInitiate) {
     checkRsConfig();
     log() << "replSet info saving a newer config version to local.system.replset" << rsLog;
     {
         // TODO: does this really need to be a global lock?
         Lock::GlobalWrite lk;
         Client::Context cx( rsConfigNs );
         Client::Transaction transaction(DB_SERIALIZABLE);    
         if (onInitiate) {
             cc().txn().txnIntiatingRs();
         }
         BSONObj o = asBson();
         Helpers::putSingleton(rsConfigNs.c_str(), o);
         if( !comment.isEmpty() && (!theReplSet || theReplSet->isPrimary()) ) {
             OpLogHelpers::logComment(comment, &cc().txn());
         }
         transaction.commit(0);
     }
     log() << "replSet saveConfigLocally done" << rsLog;
 }
Example #3
0
    /* comment MUST only be set when initiating the set by the initiator */
    void ReplSetConfig::saveConfigLocally(bo comment) {
        checkRsConfig();

        BSONObj newConfigBSON = asBson();

        log() << "replSet info saving a newer config version to local.system.replset: "
              << newConfigBSON << rsLog;
        {
            OperationContextImpl txn;
            Client::WriteContext cx(&txn, rsConfigNs);

            //theReplSet->lastOpTimeWritten = ??;
            //rather than above, do a logOp()? probably
            Helpers::putSingletonGod(&txn,
                                     rsConfigNs.c_str(),
                                     newConfigBSON,
                                     false/*logOp=false; local db so would work regardless...*/);
            if( !comment.isEmpty() && (!theReplSet || theReplSet->isPrimary()) )
                logOpInitiate(&txn, comment);
        }
        log() << "replSet saveConfigLocally done" << rsLog;
    }