diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-05-28 17:08:03 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-05-28 17:08:03 -0400 |
commit | 8b25e879afef19c9528edd1342b7b0e10c6255d2 (patch) | |
tree | 8be18313a0304f6adcd2d196fd692318fd41c6e6 | |
parent | 3b8c1a8709c51d3d6881ab311f2c90ff8ff826b5 (diff) | |
parent | 4397393a977625d0e271610b604f5b0e75404d47 (diff) | |
download | mongo-8b25e879afef19c9528edd1342b7b0e10c6255d2.tar.gz |
Merge branch 'master' of git@github.com:mongodb/mongo
-rw-r--r-- | db/clientcursor.h | 1 | ||||
-rw-r--r-- | db/cloner.cpp | 9 | ||||
-rw-r--r-- | db/cursor.h | 1 | ||||
-rw-r--r-- | db/dbhelpers.h | 1 | ||||
-rw-r--r-- | db/jsobj.h | 4 | ||||
-rw-r--r-- | db/pdfile.h | 3 | ||||
-rw-r--r-- | db/query.cpp | 1 | ||||
-rw-r--r-- | db/queryoptimizer.h | 2 | ||||
-rw-r--r-- | db/queryutil.h | 6 | ||||
-rw-r--r-- | db/repl.cpp | 6 | ||||
-rw-r--r-- | db/repl.h | 7 | ||||
-rw-r--r-- | dbtests/dbtests.h | 1 | ||||
-rw-r--r-- | shell/utils.cpp | 6 | ||||
-rw-r--r-- | util/file_allocator.h | 3 | ||||
-rw-r--r-- | util/log.h | 4 | ||||
-rw-r--r-- | util/top.h | 1 |
16 files changed, 46 insertions, 10 deletions
diff --git a/db/clientcursor.h b/db/clientcursor.h index e2b31bfa250..5e9158b0ea0 100644 --- a/db/clientcursor.h +++ b/db/clientcursor.h @@ -42,6 +42,7 @@ namespace mongo { extern BSONObj id_obj; + // utility class for de duping ids class IdSet { public: IdSet() : mySize_(), inMem_( true ) {} diff --git a/db/cloner.cpp b/db/cloner.cpp index 02d5d8a8797..c44ed32d3be 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -94,6 +94,8 @@ namespace mongo { c = conn->query( from_collection, query, 0, 0, 0, slaveOk ? Option_SlaveOk : 0 ); } assert( c.get() ); + long long n = 0; + time_t saveLast = time( 0 ); while ( 1 ) { { dbtemprelease r; @@ -108,6 +110,8 @@ namespace mongo { continue; } + ++n; + BSONObj js = tmp; if ( isindex ) { assert( strstr(from_collection, "system.indexes") ); @@ -122,6 +126,11 @@ namespace mongo { catch( UserException& e ) { log() << "warning: exception cloning object in " << from_collection << ' ' << e.what() << " obj:" << js.toString() << '\n'; } + + RARELY if ( time( 0 ) - saveLast > 60 ) { + log() << n << " objects cloned so far from collection " << from_collection << endl; + saveLast = time( 0 ); + } } } diff --git a/db/cursor.h b/db/cursor.h index 68214cd251d..84c8527171b 100644 --- a/db/cursor.h +++ b/db/cursor.h @@ -106,6 +106,7 @@ namespace mongo { virtual bool capped() const { return false; } }; + // strategy object implementing direction of traversal. class AdvanceStrategy { public: virtual ~AdvanceStrategy() {} diff --git a/db/dbhelpers.h b/db/dbhelpers.h index d52790f421b..f9ee2246098 100644 --- a/db/dbhelpers.h +++ b/db/dbhelpers.h @@ -88,6 +88,7 @@ namespace mongo { } }; + // manage a set using collection backed storage class DbSet { public: DbSet( const string &name = "", const BSONObj &key = BSONObj() ) : diff --git a/db/jsobj.h b/db/jsobj.h index f8bba08be0c..a6b1dca3f61 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -505,7 +505,7 @@ namespace mongo { if ( ifree ) _holder.reset( new Holder( data ) ); _objdata = data; - massert( "Invalid BSONObj spec size", isValid() ); + assert( "Invalid BSONObj spec size" && isValid() ); } #pragma pack(1) static struct EmptyObject { @@ -798,6 +798,7 @@ namespace mongo { */ #define BSON(x) (( BSONObjBuilder() << x ).obj()) + // Utility class to implement GT, GTE, etc as described above. class Labeler { public: struct Label { @@ -826,6 +827,7 @@ namespace mongo { extern Labeler::Label NE; extern Labeler::Label SIZE; + // Utility class to implement BSON( key << val ) as described above. class BSONObjBuilderValueStream : public boost::noncopyable { public: friend class Labeler; diff --git a/db/pdfile.h b/db/pdfile.h index 9a7938b6a0c..af15264af24 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -364,9 +364,12 @@ namespace mongo { namespace mongo { + // Heritable class to implement an operation that may be applied to all + // files in a database using _applyOpToDataFiles() class FileOp { public: virtual ~FileOp() {} + // Return true if file exists and operation successful virtual bool apply( const boost::filesystem::path &p ) = 0; virtual const char * op() const = 0; }; diff --git a/db/query.cpp b/db/query.cpp index ae61980f18f..a6710657713 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -166,6 +166,7 @@ namespace mongo { return nDeleted; } + // utility class for assembling hierarchical objects class EmbeddedBuilder { public: EmbeddedBuilder( BSONObjBuilder *b ) { diff --git a/db/queryoptimizer.h b/db/queryoptimizer.h index 2c695fa203f..b10657e54cd 100644 --- a/db/queryoptimizer.h +++ b/db/queryoptimizer.h @@ -99,6 +99,8 @@ namespace mongo { bool error_; }; + // Set of candidate query plans for a particular query. Used for running + // a QueryOp on these plans. class QueryPlanSet { public: QueryPlanSet( const char *ns, diff --git a/db/queryutil.h b/db/queryutil.h index 21bb20638fc..5c509da8397 100644 --- a/db/queryutil.h +++ b/db/queryutil.h @@ -22,6 +22,8 @@ namespace mongo { + // bounds on a field's value that may be determined from query -- used to + // determine index limits class FieldBound { public: FieldBound( const BSONElement &e = BSONObj().firstElement() ); @@ -51,6 +53,8 @@ namespace mongo { vector< BSONObj > objData_; }; + // implements query pattern matching, used to determine if a query is + // similar to an earlier query and should use the same plan class QueryPattern { public: friend class FieldBoundSet; @@ -114,6 +118,8 @@ namespace mongo { BSONObj sort_; }; + // bounds on fields' value that may be determined from query -- used to + // determine index limits class FieldBoundSet { public: FieldBoundSet( const char *ns, const BSONObj &query ); diff --git a/db/repl.cpp b/db/repl.cpp index 4a1e9535e43..eef27f69eda 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -1218,18 +1218,18 @@ namespace mongo { syncedTo = nextOpTime; save(); // note how far we are synced up to now log() << "pull: applied " << n << " operations" << endl; - log(2) << "repl: end sync_pullOpLog syncedTo: " << syncedTo.toStringLong() << '\n'; + log() << "repl: end sync_pullOpLog syncedTo: " << syncedTo.toStringLong() << endl; break; } - OCCASIONALLY if( n > 100000 || time(0) - saveLast > 5 * 60 ) { + OCCASIONALLY if( n > 100000 || time(0) - saveLast > 60 ) { // periodically note our progress, in case we are doing a lot of work and crash dblock lk; syncedTo = nextOpTime; // can't update local log ts since there are pending operations from our peer save(); log() << "pull: applied " << n << " operations" << endl; - log(2) << "repl: end sync_pullOpLog syncedTo: " << syncedTo.toStringLong() << '\n'; + log() << "repl: end sync_pullOpLog syncedTo: " << syncedTo.toStringLong() << endl; saveLast = time(0); n = 0; } diff --git a/db/repl.h b/db/repl.h index 272bdeb80b5..44bc9b1fa17 100644 --- a/db/repl.h +++ b/db/repl.h @@ -149,6 +149,7 @@ namespace mongo { void _logOp(const char *opstr, const char *ns, const char *logNs, const BSONObj& obj, BSONObj *patt, bool *b, const OpTime &ts); void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt = 0, bool *b = 0); + // class for managing a set of ids in memory class MemIds { public: MemIds() : size_() {} @@ -174,7 +175,8 @@ namespace mongo { IdSets imp_; long long size_; }; - + + // class for managing a set of ids in a db collection // All functions must be called with db mutex held class DbIds { public: @@ -198,7 +200,8 @@ namespace mongo { } DbSet impl_; }; - + + // class for tracking ids and mod ids, in memory or on disk // All functions must be called with db mutex held // Kind of sloppy class structure, for now just want to keep the in mem // version speedy. diff --git a/dbtests/dbtests.h b/dbtests/dbtests.h index ec32b0e77b7..113fb2c9077 100644 --- a/dbtests/dbtests.h +++ b/dbtests/dbtests.h @@ -21,6 +21,7 @@ using namespace mongo; +// Utility class to handle per suite cleanup class Suite : public UnitTest::Suite { public: ~Suite(); diff --git a/shell/utils.cpp b/shell/utils.cpp index ee876c62ef9..38581d420ad 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -131,6 +131,7 @@ namespace mongo { int n = int( args.firstElement().number() ); vector< int > ports; + vector< int > sockets; for( int i = 0; i < n; ++i ) { int s = socket( AF_INET, SOCK_STREAM, 0 ); assert( s ); @@ -146,9 +147,10 @@ namespace mongo { socklen_t len = sizeof( newAddress ); assert( 0 == getsockname( s, (sockaddr*)&newAddress, &len ) ); ports.push_back( ntohs( newAddress.sin_port ) ); - - assert( 0 == close( s ) ); + sockets.push_back( s ); } + for( vector< int >::const_iterator i = sockets.begin(); i != sockets.end(); ++i ) + assert( 0 == close( *i ) ); sort( ports.begin(), ports.end() ); for( unsigned i = 1; i < ports.size(); ++i ) diff --git a/util/file_allocator.h b/util/file_allocator.h index 10bb4e4e67f..7430a2444a2 100644 --- a/util/file_allocator.h +++ b/util/file_allocator.h @@ -26,7 +26,8 @@ #endif namespace mongo { - // Handles allocation of contiguous files on disk. + // Handles allocation of contiguous files on disk. Allocation may be + // requested asynchronously or synchronously. class FileAllocator { // The public functions may not be called concurrently. The allocation // functions may be called multiple times per file, but only the first diff --git a/util/log.h b/util/log.h index 96fba916ec4..5f8d7589f87 100644 --- a/util/log.h +++ b/util/log.h @@ -20,12 +20,14 @@ namespace mongo { + // Utility interface for stringifying object only when val() called. class LazyString { public: virtual ~LazyString() {} virtual string val() const = 0; }; - + + // Utility class for stringifying object only when val() called. template< class T > class LazyStringImpl : public LazyString { public: diff --git a/util/top.h b/util/top.h index f2802ca0418..15862cf37bc 100644 --- a/util/top.h +++ b/util/top.h @@ -19,6 +19,7 @@ namespace mongo { +// Records per namespace utilization of the mongod process. // No two functions of this class may be called concurrently. class Top { public: |