void LegacyReplicationCoordinator::startReplication(TopologyCoordinator*,
                                                        ReplicationExecutor::NetworkInterface*) {
        // if we are going to be a replica set, we aren't doing other forms of replication.
        if (!replSettings.replSet.empty()) {
            if (replSettings.slave || replSettings.master) {
                log() << "***" << endl;
                log() << "ERROR: can't use --slave or --master replication options with --replSet";
                log() << "***" << endl;
            }
            newRepl();

            replSet = true;
            ReplSetSeedList *replSetSeedList = new ReplSetSeedList(replSettings.replSet);
            boost::thread t(stdx::bind(&startReplSets, replSetSeedList));
        } else {
            startMasterSlave();
        }
    }
Beispiel #2
0
void startReplication() {
    /* if we are going to be a replica set, we aren't doing other forms of replication. */
    if (!replSettings.replSet.empty()) {
        if( replSettings.slave || replSettings.master ) {
            log() << "***" << endl;
            log() << "ERROR: can't use --slave or --master replication options with --replSet";
            log() << "***" << endl;
        }
        newRepl();

        replSet = true;
        ReplSetCmdline *replSetCmdline = new ReplSetCmdline(replSettings.replSet);
        boost::thread t( stdx::bind( &startReplSets, replSetCmdline) );

        return;
    }

    startMasterSlave();
}
Beispiel #3
0
    void startReplication() {
        /* if we are going to be a replica set, we aren't doing other forms of replication. */
        if( !cmdLine._replSet.empty() ) {
            if( replSettings.slave || replSettings.master ) {
                log() << "***" << endl;
                log() << "ERROR: can't use --slave or --master replication options with --replSet" << endl;
                log() << "***" << endl;
            }
            newRepl();
            return;
        }

        oldRepl();

        /* this was just to see if anything locks for longer than it should -- we need to be careful
           not to be locked when trying to connect() or query() the other side.
           */
        //boost::thread tempt(tempThread);

        if( !replSettings.slave && !replSettings.master )
            return;

        {
            dblock lk;
            cc().getAuthenticationInfo()->authorize("admin");
        }

        if ( replSettings.slave ) {
            assert( replSettings.slave == SimpleSlave );
            log(1) << "slave=true" << endl;
            boost::thread repl_thread(replSlaveThread);
        }

        if ( replSettings.master ) {
            log(1) << "master=true" << endl;
            replSettings.master = true;
            createOplog();
            boost::thread t(replMasterThread);
        }

        while( replSettings.fastsync ) // don't allow writes until we've set up from log
            sleepmillis( 50 );
    }