当前位置: 首页>>代码示例>>C++>>正文


C++ DurableMappedFile::filename方法代码示例

本文整理汇总了C++中DurableMappedFile::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ DurableMappedFile::filename方法的具体用法?C++ DurableMappedFile::filename怎么用?C++ DurableMappedFile::filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DurableMappedFile的用法示例。


在下文中一共展示了DurableMappedFile::filename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: operator

            void operator () (MongoFile *mf) {
                if( mf->isDurableMappedFile() ) {
                    DurableMappedFile *mmf = (DurableMappedFile*) mf;
                    const unsigned char *p = (const unsigned char *) mmf->getView();
                    const unsigned char *w = (const unsigned char *) mmf->view_write();

                    if (!p || !w) return; // File not fully opened yet

                    _bytes += mmf->length();

                    verify( mmf->length() == (unsigned) mmf->length() );

                    if (memcmp(p, w, (unsigned) mmf->length()) == 0)
                        return; // next file

                    unsigned low = 0xffffffff;
                    unsigned high = 0;
                    log() << "DurParanoid mismatch in " << mmf->filename() << endl;
                    int logged = 0;
                    unsigned lastMismatch = 0xffffffff;
                    for( unsigned i = 0; i < mmf->length(); i++ ) {
                        if( p[i] != w[i] ) {
                            if( lastMismatch != 0xffffffff && lastMismatch+1 != i )
                                log() << endl; // separate blocks of mismatches
                            lastMismatch= i;
                            if( ++logged < 60 ) {
                                if( logged == 1 )
                                    log() << "ofs % 628 = 0x" << hex << (i%628) << endl; // for .ns files to find offset in record
                                stringstream ss;
                                ss << "mismatch ofs:" << hex << i <<  "\tfilemap:" << setw(2) << (unsigned) w[i] << "\tprivmap:" << setw(2) << (unsigned) p[i];
                                if( p[i] > 32 && p[i] <= 126 )
                                    ss << '\t' << p[i];
                                log() << ss.str() << endl;
                            }
                            if( logged == 60 )
                                log() << "..." << endl;
                            if( i < low ) low = i;
                            if( i > high ) high = i;
                        }
                    }
                    if( low != 0xffffffff ) {
                        std::stringstream ss;
                        ss << "journal error warning views mismatch " << mmf->filename() << ' ' << (hex) << low << ".." << high << " len:" << high-low+1;
                        log() << ss.str() << endl;
                        log() << "priv loc: " << (void*)(p+low) << ' ' << endl;
                        //vector<WriteIntent>& _intents = commitJob.wi()._intents;
                        //(void) _intents; // mark as unused. Useful for inspection in debugger

                        // should we abort() here so this isn't unnoticed in some circumstances?
                        massert(13599, "Written data does not match in-memory view. Missing WriteIntent?", false);
                    }
                }
            }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:53,代码来源:dur.cpp

示例2: lkPrivateViews

__declspec(noinline) void PointerToDurableMappedFile::makeChunkWritable(size_t chunkno) {
    stdx::lock_guard<stdx::mutex> lkPrivateViews(_m);

    if (writable.get(chunkno))  // double check lock
        return;

    // remap all maps in this chunk.
    // common case is a single map, but could have more than one with smallfiles or .ns files
    size_t chunkStart = chunkno * MemoryMappedCOWBitset::ChunkSize;
    size_t chunkNext = chunkStart + MemoryMappedCOWBitset::ChunkSize;

    stdx::lock_guard<stdx::mutex> lkMapView(mapViewMutex);

    map<void*, DurableMappedFile*>::iterator i = _views.upper_bound((void*)(chunkNext - 1));
    while (1) {
        const pair<void*, DurableMappedFile*> x = *(--i);
        DurableMappedFile* mmf = x.second;
        if (mmf == 0)
            break;

        size_t viewStart = reinterpret_cast<size_t>(x.first);
        size_t viewEnd = viewStart + mmf->length();
        if (viewEnd <= chunkStart)
            break;

        size_t protectStart = std::max(viewStart, chunkStart);
        dassert(protectStart < chunkNext);

        size_t protectEnd = std::min(viewEnd, chunkNext);
        size_t protectSize = protectEnd - protectStart;
        dassert(protectSize > 0 && protectSize <= MemoryMappedCOWBitset::ChunkSize);

        DWORD oldProtection;
        bool ok = VirtualProtect(
                      reinterpret_cast<void*>(protectStart), protectSize, PAGE_WRITECOPY, &oldProtection);
        if (!ok) {
            DWORD dosError = GetLastError();

            if (dosError == ERROR_COMMITMENT_LIMIT) {
                // System has run out of memory between physical RAM & page file, tell the user
                BSONObjBuilder bb;

                ProcessInfo p;
                p.getExtraInfo(bb);

                severe() << "MongoDB has exhausted the system memory capacity.";
                severe() << "Current Memory Status: " << bb.obj();
            }

            severe() << "VirtualProtect for " << mmf->filename() << " chunk " << chunkno
                     << " failed with " << errnoWithDescription(dosError) << " (chunk size is "
                     << protectSize << ", address is " << hex << protectStart << dec << ")"
                     << " in mongo::makeChunkWritable, terminating" << endl;

            fassertFailed(16362);
        }
    }

    writable.set(chunkno);
}
开发者ID:Machyne,项目名称:mongo,代码行数:60,代码来源:durable_mapped_file.cpp

示例3: lk

    __declspec(noinline) void makeChunkWritable(size_t chunkno) { 
        scoped_lock lk(mapViewMutex);

        if( writable.get(chunkno) ) // double check lock
            return;

        // remap all maps in this chunk.  common case is a single map, but could have more than one with smallfiles or .ns files
        size_t chunkStart = chunkno * MemoryMappedFile::ChunkSize;
        size_t chunkNext = chunkStart + MemoryMappedFile::ChunkSize;

        scoped_lock lk2(privateViews._mutex());
        map<void*,DurableMappedFile*>::iterator i = privateViews.finditer_inlock((void*) (chunkNext-1));
        while( 1 ) {
            const pair<void*,DurableMappedFile*> x = *(--i);
            DurableMappedFile *mmf = x.second;
            if( mmf == 0 )
                break;

            size_t viewStart = (size_t) x.first;
            size_t viewEnd = (size_t) (viewStart + mmf->length());
            if( viewEnd <= chunkStart )
                break;

            size_t protectStart = max(viewStart, chunkStart);
            dassert(protectStart<chunkNext);

            size_t protectEnd = min(viewEnd, chunkNext);
            size_t protectSize = protectEnd - protectStart;
            dassert(protectSize>0&&protectSize<=MemoryMappedFile::ChunkSize);

            DWORD oldProtection;
            bool ok = VirtualProtect( reinterpret_cast<void*>( protectStart ),
                                      protectSize,
                                      PAGE_WRITECOPY,
                                      &oldProtection );
            if ( !ok ) {
                DWORD dosError = GetLastError();
                log() << "VirtualProtect for " << mmf->filename()
                        << " chunk " << chunkno
                        << " failed with " << errnoWithDescription( dosError )
                        << " (chunk size is " << protectSize
                        << ", address is " << hex << protectStart << dec << ")"
                        << " in mongo::makeChunkWritable, terminating"
                        << endl;
                fassertFailed( 16362 );
            }
        }

        writable.set(chunkno);
    }
开发者ID:ChrisBg,项目名称:mongo,代码行数:50,代码来源:mmap_win.cpp

示例4: note

        void CommitJob::note(void* p, int len) {
            _hasWritten = true;

            // from the point of view of the dur module, it would be fine (i think) to only
            // be read locked here.  but must be at least read locked to avoid race with
            // remapprivateview

            if( !_intentsAndDurOps._alreadyNoted.checkAndSet(p, len) ) {

                /** tips for debugging:
                        if you have an incorrect diff between data files in different folders
                        (see jstests/dur/quick.js for example),
                        turn this on and see what is logged.  if you have a copy of its output from before the
                        regression, a simple diff of these lines would tell you a lot likely.
                */
#if 0 && defined(_DEBUG)
                {
                    static int n;
                    if( ++n < 10000 ) {
                        size_t ofs;
                        DurableMappedFile *mmf = privateViews._find(w.p, ofs);
                        if( mmf ) {
                            log() << "DEBUG note write intent " << w.p << ' ' << mmf->filename() << " ofs:" << hex << ofs << " len:" << w.len << endl;
                        }
                        else {
                            log() << "DEBUG note write intent " << w.p << ' ' << w.len << " NOT FOUND IN privateViews" << endl;
                        }
                    }
                    else if( n == 10000 ) {
                        log() << "DEBUG stopping write intent logging, too much to log" << endl;
                    }
                }
#endif

                // remember intent. we will journal it in a bit
                _intentsAndDurOps.insertWriteIntent(p, len);

                {
                    // a bit over conservative in counting pagebytes used
                    static size_t lastPos; // note this doesn't reset with each commit, but that is ok we aren't being that precise
                    size_t x = ((size_t) p) & ~0xfff; // round off to page address (4KB)
                    if( x != lastPos ) { 
                        lastPos = x;
                        unsigned b = (len+4095) & ~0xfff;
                        _bytes += b;

                        if (_bytes > UncommittedBytesLimit * 3) {
                            static time_t lastComplain;
                            static unsigned nComplains;
                            // throttle logging
                            if( ++nComplains < 100 || time(0) - lastComplain >= 60 ) {
                                lastComplain = time(0);
                                warning() << "DR102 too much data written uncommitted " << _bytes/1000000.0 << "MB" << endl;
                                if( nComplains < 10 || nComplains % 10 == 0 ) {
                                    // wassert makes getLastError show an error, so we just print stack trace
                                    printStackTrace();
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:CodeHub2,项目名称:mongo,代码行数:63,代码来源:dur_commitjob.cpp


注:本文中的DurableMappedFile::filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。