diff options
-rw-r--r-- | s/d_migrate.cpp | 6 | ||||
-rw-r--r-- | tools/dump.cpp | 18 |
2 files changed, 21 insertions, 3 deletions
diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp index 81aa93dc590..8bb01879375 100644 --- a/s/d_migrate.cpp +++ b/s/d_migrate.cpp @@ -65,7 +65,11 @@ namespace mongo { ss << "step" << step; string s = ss.str(); - cc().curop()->setMessage( s.c_str() ); + CurOp * op = cc().curop(); + if ( op ) + op->setMessage( s.c_str() ); + else + log( LL_WARNING ) << "op is null in MoveTimingHelper::done" << endl; _b.appendNumber( s , _t.millis() ); _t.reset(); diff --git a/tools/dump.cpp b/tools/dump.cpp index 922481adfda..7bb38ca3b7c 100644 --- a/tools/dump.cpp +++ b/tools/dump.cpp @@ -31,6 +31,7 @@ public: Dump() : Tool( "dump" , true , "*" ){ add_options() ("out,o", po::value<string>()->default_value("dump"), "output directory") + ("query,q", po::value<string>() , "json query" ) ; } @@ -43,7 +44,13 @@ public: ProgressMeter m( conn( true ).count( coll.c_str() , BSONObj() , QueryOption_SlaveOk ) ); - auto_ptr<DBClientCursor> cursor = conn( true ).query( coll.c_str() , Query().snapshot() , 0 , 0 , 0 , QueryOption_SlaveOk | QueryOption_NoCursorTimeout ); + Query q; + if ( _query.isEmpty() ) + q.snapshot(); + else + q = _query; + + auto_ptr<DBClientCursor> cursor = conn( true ).query( coll.c_str() , q , 0 , 0 , 0 , QueryOption_SlaveOk | QueryOption_NoCursorTimeout ); while ( cursor->more() ) { BSONObj obj = cursor->next(); @@ -80,8 +87,14 @@ public: } } - + int run(){ + + { + string q = getParam("query"); + if ( q.size() ) + _query = fromjson( q ); + } path root( getParam("out") ); string db = _db; @@ -113,6 +126,7 @@ public: return 0; } + BSONObj _query; }; int main( int argc , char ** argv ) { |