コード例 #1
0
ファイル: extent_manager.cpp プロジェクト: Axv2/mongo
    Extent* ExtentManager::_createExtentInFile( int fileNo, DataFile* f,
                                                const char* ns, int size, bool newCapped,
                                                bool enforceQuota ) {

        size = ExtentManager::quantizeExtentSize( size );

        if ( enforceQuota ) {
            if ( fileIndexExceedsQuota( ns, fileNo - 1 ) ) {
                if ( cc().hasWrittenThisPass() ) {
                    warning() << "quota exceeded, but can't assert "
                              << " going over quota for: " << ns << " " << fileNo << endl;
                }
                else {
                    _quotaExceeded();
                }
            }
        }

        massert( 10358, "bad new extent size", size >= Extent::minSize() && size <= Extent::maxSize() );

        DiskLoc loc = f->allocExtentArea( size );
        loc.assertOk();

        Extent *e = getExtent( loc, false );
        verify( e );

        DiskLoc emptyLoc = getDur().writing(e)->init(ns, size, fileNo, loc.getOfs(), newCapped);

        addNewExtentToNamespace(ns, e, loc, emptyLoc, newCapped);

        LOG(1) << "ExtentManager: creating new extent for: " << ns << " in file: " << fileNo
               << " size: " << size << endl;

        return e;
    }
コード例 #2
0
    DiskLoc MmapV1ExtentManager::_createExtentInFile( TransactionExperiment* txn,
                                                int fileNo,
                                                DataFile* f,
                                                int size,
                                                int maxFileNoForQuota ) {

        size = MmapV1ExtentManager::quantizeExtentSize( size );

        if ( maxFileNoForQuota > 0 && fileNo - 1 >= maxFileNoForQuota ) {
            if ( cc().hasWrittenSinceCheckpoint() ) {
                warning() << "quota exceeded, but can't assert" << endl;
            }
            else {
                _quotaExceeded();
            }
        }

        massert( 10358, "bad new extent size", size >= minSize() && size <= maxSize() );

        DiskLoc loc = f->allocExtentArea( txn, size );
        loc.assertOk();

        Extent *e = getExtent( loc, false );
        verify( e );

        *txn->writing(&e->magic) = Extent::extentSignature;
        *txn->writing(&e->myLoc) = loc;
        *txn->writing(&e->length) = size;

        return loc;
    }
コード例 #3
0
ファイル: extent_manager.cpp プロジェクト: ZhouYii/mongo
    DiskLoc ExtentManager::_createExtentInFile( int fileNo, DataFile* f,
                                                int size, int maxFileNoForQuota ) {

        size = ExtentManager::quantizeExtentSize( size );

        if ( maxFileNoForQuota > 0 && fileNo - 1 >= maxFileNoForQuota ) {
            if ( cc().hasWrittenThisPass() ) {
                warning() << "quota exceeded, but can't assert" << endl;
            }
            else {
                _quotaExceeded();
            }
        }

        massert( 10358, "bad new extent size", size >= Extent::minSize() && size <= Extent::maxSize() );

        DiskLoc loc = f->allocExtentArea( size );
        loc.assertOk();

        Extent *e = getExtent( loc, false );
        verify( e );

        getDur().writing(e)->init("", size, fileNo, loc.getOfs(), false);

        return loc;
    }
コード例 #4
0
DiskLoc MmapV1ExtentManager::_createExtentInFile(
    OperationContext* txn, int fileNo, DataFile* f, int size, bool enforceQuota) {
    _checkQuota(enforceQuota, fileNo - 1);

    massert(10358, "bad new extent size", size >= minSize() && size <= maxSize());

    DiskLoc loc = f->allocExtentArea(txn, size);
    loc.assertOk();

    Extent* e = getExtent(loc, false);
    verify(e);

    *txn->recoveryUnit()->writing(&e->magic) = Extent::extentSignature;
    *txn->recoveryUnit()->writing(&e->myLoc) = loc;
    *txn->recoveryUnit()->writing(&e->length) = size;

    return loc;
}
コード例 #5
0
ファイル: cloner.cpp プロジェクト: idning/mongo
        void operator()( DBClientCursorBatchIterator &i ) {
            Lock::GlobalWrite lk;
            if ( context ) {
                context->relocked();
            }

            while( i.moreInCurrentBatch() ) {
                if ( n % 128 == 127 /*yield some*/ ) {
                    time_t now = time(0);
                    if( now - lastLog >= 60 ) { 
                        // report progress
                        if( lastLog )
                            log() << "clone " << to_collection << ' ' << n << endl;
                        lastLog = now;
                    }
                    mayInterrupt( _mayBeInterrupted );
                    dbtempreleaseif t( _mayYield );
                }

                BSONObj tmp = i.nextSafe();

                /* assure object is valid.  note this will slow us down a little. */
                if ( !tmp.valid() ) {
                    stringstream ss;
                    ss << "Cloner: skipping corrupt object from " << from_collection;
                    BSONElement e = tmp.firstElement();
                    try {
                        e.validate();
                        ss << " firstElement: " << e;
                    }
                    catch( ... ) {
                        ss << " firstElement corrupt";
                    }
                    out() << ss.str() << endl;
                    continue;
                }

                ++n;

                BSONObj js = tmp;
                if ( isindex ) {
                    verify(nsToCollectionSubstring(from_collection) == "system.indexes");
                    js = fixindex(tmp);
                    storedForLater->push_back( js.getOwned() );
                    continue;
                }

                try {
                    DiskLoc loc = theDataFileMgr.insertWithObjMod(to_collection, js);
                    loc.assertOk();
                    if ( logForRepl )
                        logOp("i", to_collection, js);

                    getDur().commitIfNeeded();
                }
                catch( UserException& e ) {
                    error() << "error: exception cloning object in " << from_collection << ' ' << e.what() << " obj:" << js.toString() << '\n';
                    throw;
                }

                RARELY if ( time( 0 ) - saveLast > 60 ) {
                    log() << n << " objects cloned so far from collection " << from_collection << endl;
                    saveLast = time( 0 );
                }
            }
        }