Esempio n. 1
0
        bool update( const BSONObj& rid , const BSONObj config , const string& ns , OpTime last ) {
            REPLDEBUG( config << " " << rid << " " << ns << " " << last );

            Ident ident(rid, config, ns);

            scoped_lock mylk(_mutex);

            if (last > _slaves[ident]) {
                _slaves[ident] = last;
                _dirty = true;

                if (theReplSet && theReplSet->isPrimary()) {
                    if (!theReplSet->ghost->updateSlave(ident.obj["_id"].OID(), last)) {
                        return false;
                    }
                }

                if ( ! _started ) {
                    // start background thread here since we definitely need it
                    _started = true;
                    go();
                }

                _threadsWaitingForReplication.notify_all();
            }
            return true;
        }
Esempio n. 2
0
        void update( const BSONObj& rid , const BSONObj config , const string& ns , GTID gtid ) {
            REPLDEBUG( config << " " << rid << " " << ns << " " << last );

            Ident ident(rid, config, ns);

            scoped_lock mylk(_mutex);

            _slaves[ident] = gtid;

            if (theReplSet && theReplSet->isPrimary()) {
                theReplSet->ghost->updateSlave(ident.obj["_id"].OID(), gtid);
            }

            _threadsWaitingForReplication.notify_all();
        }
Esempio n. 3
0
        void update( const BSONObj& rid , const string& host , const string& ns , OpTime last ) {
            REPLDEBUG( host << " " << rid << " " << ns << " " << last );

            scoped_lock mylk(_mutex);

#ifdef _DEBUG
            MongoFileAllowWrites allowWrites;
#endif

            Ident ident(rid,host,ns);
            Info& i = _slaves[ ident ];

            if (theReplSet && theReplSet->isPrimary()) {
                theReplSet->ghost->updateSlave(ident.obj["_id"].OID(), last);
            }

            if ( i.loc ) {
                if( i.owned )
                    i.loc[0] = last;
                else
                    getDur().setNoJournal(i.loc, &last, sizeof(last));
                return;
            }

            dbMutex.assertAtLeastReadLocked();

            BSONObj res;
            if ( Helpers::findOne( NS , ident.obj , res ) ) {
                assert( res["syncedTo"].type() );
                i.owned = false;
                i.loc = (OpTime*)res["syncedTo"].value();
                getDur().setNoJournal(i.loc, &last, sizeof(last));
                return;
            }

            i.owned = true;
            i.loc = new OpTime(last);
            _dirty = true;

            if ( ! _started ) {
                // start background thread here since we definitely need it
                _started = true;
                go();
            }

        }
Esempio n. 4
0
        void update( const BSONObj& rid , const string& host , const string& ns , OpTime last ) {
            REPLDEBUG( host << " " << rid << " " << ns << " " << last );

            Ident ident(rid,host,ns);

            scoped_lock mylk(_mutex);

            _slaves[ident] = last;
            _dirty = true;

            if (theReplSet && theReplSet->isPrimary()) {
                theReplSet->ghost->updateSlave(ident.obj["_id"].OID(), last);
            }

            if ( ! _started ) {
                // start background thread here since we definitely need it
                _started = true;
                go();
            }

        }
Esempio n. 5
0
        void update( const BSONObj& rid , const string& host , const string& ns , OpTime last ){
            REPLDEBUG( host << " " << rid << " " << ns << " " << last );

            scoped_lock mylk(_mutex);
            
#ifdef _DEBUG
            MongoFileAllowWrites allowWrites;
#endif

            Ident ident(rid,host,ns);
            Info& i = _slaves[ ident ];
            if ( i.loc ){
                i.loc[0] = last;
                return;
            }
            
            dbMutex.assertAtLeastReadLocked();

            BSONObj res;
            if ( Helpers::findOne( NS , ident.obj , res ) ){
                assert( res["syncedTo"].type() );
                i.owned = false;
                i.loc = (OpTime*)res["syncedTo"].value();
                i.loc[0] = last;
                return;
            }
            
            i.owned = true;
            i.loc = new OpTime[1];
            i.loc[0] = last;
            _dirty = true;

            if ( ! _started ){
                // start background thread here since we definitely need it
                _started = true;
                go();
            }

        }