Esempio n. 1
0
BSONObj createBSONMetadataDocument(const BSONObj& metadata, Date_t date) {
    BSONObjBuilder builder;
    builder.appendDate(kFTDCIdField, date);
    builder.appendNumber(kFTDCTypeField, static_cast<int>(FTDCType::kMetadata));
    builder.appendObject(kFTDCDocField, metadata.objdata(), metadata.objsize());

    return builder.obj();
}
Esempio n. 2
0
    BSONObj CurOp::infoNoauth( int attempt ) {
        BSONObjBuilder b;
        b.append("opid", _opNum);
        bool a = _active && _start;
        b.append("active", a);
        if ( _lockType )
            b.append("lockType" , _lockType > 0 ? "write" : "read"  );
        b.append("waitingForLock" , _waitingForLock );
        
        if( a ){
            b.append("secs_running", elapsedSeconds() );
        }
        
        b.append( "op" , opToString( _op ) );
        
        b.append("ns", _ns);
        
        {
            int size = querySize();
            if ( size == 0 ){
                // do nothing
            }
            else if ( size == 1 ){
                b.append( "query" , _tooBig );
            }
            else if ( attempt > 2 ){
                b.append( "query" , BSON( "err" << "can't get a clean object" ) );
                log( LL_WARNING ) << "CurOp changing too much to get reading" << endl;
                         
            }
            else {
                int before = checksum( _queryBuf , size );
                b.appendObject( "query" , _queryBuf , size );
                int after = checksum( _queryBuf , size );
                
                if ( after != before ){
                    // this means something changed
                    // going to retry
                    return infoNoauth( attempt + 1 );
                }
            }
        }

        // b.append("inLock",  ??
        stringstream clientStr;
        clientStr << _remote.toString();
        b.append("client", clientStr.str());

        if ( _client )
            b.append( "desc" , _client->desc() );
        
        if ( ! _message.empty() ){
            if ( _progressMeter.isActive() ){
                StringBuilder buf(128);
                buf << _message.toString() << " " << _progressMeter.toString();
                b.append( "msg" , buf.str() );
            }
            else {
                b.append( "msg" , _message.toString() );
            }
        }

        return b.obj();
    }