| bsonelement.h | | bsonelement.h | |
| | | | |
| skipping to change at line 310 | | skipping to change at line 310 | |
| just the value. | | just the value. | |
| */ | | */ | |
| bool valuesEqual(const BSONElement& r) const { | | bool valuesEqual(const BSONElement& r) const { | |
| return woCompare( r , false ) == 0; | | return woCompare( r , false ) == 0; | |
| } | | } | |
| | | | |
| /** Returns true if elements are equal. */ | | /** Returns true if elements are equal. */ | |
| bool operator==(const BSONElement& r) const { | | bool operator==(const BSONElement& r) const { | |
| return woCompare( r , true ) == 0; | | return woCompare( r , true ) == 0; | |
| } | | } | |
|
| | | /** Returns true if elements are unequal. */ | |
| | | bool operator!=(const BSONElement& r) const { return !operator==(r) | |
| | | ; } | |
| | | | |
| /** Well ordered comparison. | | /** Well ordered comparison. | |
| @return <0: l<r. 0:l==r. >0:l>r | | @return <0: l<r. 0:l==r. >0:l>r | |
| order by type, field name, and field value. | | order by type, field name, and field value. | |
| If considerFieldName is true, pay attention to the field name. | | If considerFieldName is true, pay attention to the field name. | |
| */ | | */ | |
| int woCompare( const BSONElement &e, bool considerFieldName = true
) const; | | int woCompare( const BSONElement &e, bool considerFieldName = true
) const; | |
| | | | |
| const char * rawdata() const { return data; } | | const char * rawdata() const { return data; } | |
| | | | |
| | | | |
End of changes. 1 change blocks. |
| 0 lines changed or deleted | | 3 lines changed or added | |
|
| bsonobj.h | | bsonobj.h | |
| | | | |
| skipping to change at line 257 | | skipping to change at line 257 | |
| e.g., if pattern is { x : 1, y : 1 }, builds an object with | | e.g., if pattern is { x : 1, y : 1 }, builds an object with | |
| x and y elements of this object, if they are present. | | x and y elements of this object, if they are present. | |
| returns elements with original field names | | returns elements with original field names | |
| */ | | */ | |
| BSONObj extractFields(const BSONObj &pattern , bool fillWithNull=fa
lse) const; | | BSONObj extractFields(const BSONObj &pattern , bool fillWithNull=fa
lse) const; | |
| | | | |
| BSONObj filterFieldsUndotted(const BSONObj &filter, bool inFilter)
const; | | BSONObj filterFieldsUndotted(const BSONObj &filter, bool inFilter)
const; | |
| | | | |
| BSONElement getFieldUsingIndexNames(const char *fieldName, const BS
ONObj &indexKey) const; | | BSONElement getFieldUsingIndexNames(const char *fieldName, const BS
ONObj &indexKey) const; | |
| | | | |
|
| | | /** arrays are bson objects with numeric and increasing field names | |
| | | @return true if field names are numeric and increasing | |
| | | */ | |
| | | bool couldBeArray() const; | |
| | | | |
| /** @return the raw data of the object */ | | /** @return the raw data of the object */ | |
| const char *objdata() const { | | const char *objdata() const { | |
| return _objdata; | | return _objdata; | |
| } | | } | |
| /** @return total size of the BSON object in bytes */ | | /** @return total size of the BSON object in bytes */ | |
| int objsize() const { return *(reinterpret_cast<const int*>(objdata
())); } | | int objsize() const { return *(reinterpret_cast<const int*>(objdata
())); } | |
| | | | |
| /** performs a cursory check on the object's size only. */ | | /** performs a cursory check on the object's size only. */ | |
| bool isValid() const; | | bool isValid() const; | |
| | | | |
| | | | |
| skipping to change at line 363 | | skipping to change at line 368 | |
| passed object. */ | | passed object. */ | |
| BSONObj replaceFieldNames( const BSONObj &obj ) const; | | BSONObj replaceFieldNames( const BSONObj &obj ) const; | |
| | | | |
| /** true unless corrupt */ | | /** true unless corrupt */ | |
| bool valid() const; | | bool valid() const; | |
| | | | |
| /** @return an md5 value for this object. */ | | /** @return an md5 value for this object. */ | |
| string md5() const; | | string md5() const; | |
| | | | |
| bool operator==( const BSONObj& other ) const { return equal( other
); } | | bool operator==( const BSONObj& other ) const { return equal( other
); } | |
|
| | | bool operator!=(const BSONObj& other) const { return !operator==( o
ther); } | |
| | | | |
| enum MatchType { | | enum MatchType { | |
| Equality = 0, | | Equality = 0, | |
| LT = 0x1, | | LT = 0x1, | |
| LTE = 0x3, | | LTE = 0x3, | |
| GTE = 0x6, | | GTE = 0x6, | |
| GT = 0x4, | | GT = 0x4, | |
| opIN = 0x8, // { x : { $in : [1,2,3] } } | | opIN = 0x8, // { x : { $in : [1,2,3] } } | |
| NE = 0x9, | | NE = 0x9, | |
| opSIZE = 0x0A, | | opSIZE = 0x0A, | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 6 lines changed or added | |
|
| bsonobjbuilder.h | | bsonobjbuilder.h | |
| | | | |
| skipping to change at line 472 | | skipping to change at line 472 | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| /** Append a binary data element | | /** Append a binary data element | |
| @param fieldName name of the field | | @param fieldName name of the field | |
| @param len length of the binary data in bytes | | @param len length of the binary data in bytes | |
| @param subtype subtype information for the data. @see enum BinD
ataType in bsontypes.h. | | @param subtype subtype information for the data. @see enum BinD
ataType in bsontypes.h. | |
| Use BinDataGeneral if you don't care about the type. | | Use BinDataGeneral if you don't care about the type. | |
| @param data the byte array | | @param data the byte array | |
| */ | | */ | |
|
| BSONObjBuilder& appendBinData( const StringData& fieldName, int len
, BinDataType type, const char *data ) { | | BSONObjBuilder& appendBinData( const StringData& fieldName, int len
, BinDataType type, const void *data ) { | |
| _b.appendNum( (char) BinData ); | | _b.appendNum( (char) BinData ); | |
| _b.appendStr( fieldName ); | | _b.appendStr( fieldName ); | |
| _b.appendNum( len ); | | _b.appendNum( len ); | |
| _b.appendNum( (char) type ); | | _b.appendNum( (char) type ); | |
|
| _b.appendBuf( (void *) data, len ); | | _b.appendBuf( data, len ); | |
| return *this; | | return *this; | |
| } | | } | |
|
| BSONObjBuilder& appendBinData( const StringData& fieldName, int len | | | |
| , BinDataType type, const unsigned char *data ) { | | | |
| return appendBinData(fieldName, len, type, (const char *) data) | | | |
| ; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| Subtype 2 is deprecated. | | Subtype 2 is deprecated. | |
| Append a BSON bindata bytearray element. | | Append a BSON bindata bytearray element. | |
| @param data a byte array | | @param data a byte array | |
| @param len the length of data | | @param len the length of data | |
| */ | | */ | |
|
| BSONObjBuilder& appendBinDataArrayDeprecated( const char * fieldNam
e , const char * data , int len ) { | | BSONObjBuilder& appendBinDataArrayDeprecated( const char * fieldNam
e , const void * data , int len ) { | |
| _b.appendNum( (char) BinData ); | | _b.appendNum( (char) BinData ); | |
| _b.appendStr( fieldName ); | | _b.appendStr( fieldName ); | |
| _b.appendNum( len + 4 ); | | _b.appendNum( len + 4 ); | |
| _b.appendNum( (char)0x2 ); | | _b.appendNum( (char)0x2 ); | |
| _b.appendNum( len ); | | _b.appendNum( len ); | |
|
| _b.appendBuf( (void *) data, len ); | | _b.appendBuf( data, len ); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| /** Append to the BSON object a field of type CodeWScope. This is
a javascript code | | /** Append to the BSON object a field of type CodeWScope. This is
a javascript code | |
| fragment accompanied by some scope that goes with it. | | fragment accompanied by some scope that goes with it. | |
| */ | | */ | |
| BSONObjBuilder& appendCodeWScope( const StringData& fieldName, cons
t StringData& code, const BSONObj &scope ) { | | BSONObjBuilder& appendCodeWScope( const StringData& fieldName, cons
t StringData& code, const BSONObj &scope ) { | |
| _b.appendNum( (char) CodeWScope ); | | _b.appendNum( (char) CodeWScope ); | |
| _b.appendStr( fieldName ); | | _b.appendStr( fieldName ); | |
| _b.appendNum( ( int )( 4 + 4 + code.size() + 1 + scope.objsize(
) ) ); | | _b.appendNum( ( int )( 4 + 4 + code.size() + 1 + scope.objsize(
) ) ); | |
| | | | |
End of changes. 5 change blocks. |
| 9 lines changed or deleted | | 4 lines changed or added | |
|
| builder.h | | builder.h | |
| | | | |
| skipping to change at line 68 | | skipping to change at line 68 | |
| public: | | public: | |
| enum { SZ = 512 }; | | enum { SZ = 512 }; | |
| void* Malloc(size_t sz) { | | void* Malloc(size_t sz) { | |
| if( sz <= SZ ) return buf; | | if( sz <= SZ ) return buf; | |
| return malloc(sz); | | return malloc(sz); | |
| } | | } | |
| void* Realloc(void *p, size_t sz) { | | void* Realloc(void *p, size_t sz) { | |
| if( p == buf ) { | | if( p == buf ) { | |
| if( sz <= SZ ) return buf; | | if( sz <= SZ ) return buf; | |
| void *d = malloc(sz); | | void *d = malloc(sz); | |
|
| | | if ( d == 0 ) | |
| | | msgasserted( 15912 , "out of memory StackAllocator::Rea | |
| | | lloc" ); | |
| memcpy(d, p, SZ); | | memcpy(d, p, SZ); | |
| return d; | | return d; | |
| } | | } | |
| return realloc(p, sz); | | return realloc(p, sz); | |
| } | | } | |
| void Free(void *p) { | | void Free(void *p) { | |
| if( p != buf ) | | if( p != buf ) | |
| free(p); | | free(p); | |
| } | | } | |
| private: | | private: | |
| | | | |
| skipping to change at line 116 | | skipping to change at line 118 | |
| } | | } | |
| | | | |
| void reset() { | | void reset() { | |
| l = 0; | | l = 0; | |
| } | | } | |
| void reset( int maxSize ) { | | void reset( int maxSize ) { | |
| l = 0; | | l = 0; | |
| if ( maxSize && size > maxSize ) { | | if ( maxSize && size > maxSize ) { | |
| al.Free(data); | | al.Free(data); | |
| data = (char*)al.Malloc(maxSize); | | data = (char*)al.Malloc(maxSize); | |
|
| | | if ( data == 0 ) | |
| | | msgasserted( 15913 , "out of memory BufBuilder::reset" | |
| | | ); | |
| size = maxSize; | | size = maxSize; | |
| } | | } | |
| } | | } | |
| | | | |
| /** leave room for some stuff later | | /** leave room for some stuff later | |
| @return point to region that was skipped. pointer may change l
ater (on realloc), so for immediate use only | | @return point to region that was skipped. pointer may change l
ater (on realloc), so for immediate use only | |
| */ | | */ | |
| char* skip(int n) { return grow(n); } | | char* skip(int n) { return grow(n); } | |
| | | | |
| /* note this may be deallocated (realloced) if you keep writing. */ | | /* note this may be deallocated (realloced) if you keep writing. */ | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 6 lines changed or added | |
|
| chunk.h | | chunk.h | |
| | | | |
| skipping to change at line 293 | | skipping to change at line 293 | |
| public: | | public: | |
| typedef map<Shard,ShardChunkVersion> ShardVersionMap; | | typedef map<Shard,ShardChunkVersion> ShardVersionMap; | |
| | | | |
| ChunkManager( string ns , ShardKeyPattern pattern , bool unique ); | | ChunkManager( string ns , ShardKeyPattern pattern , bool unique ); | |
| | | | |
| string getns() const { return _ns; } | | string getns() const { return _ns; } | |
| | | | |
| int numChunks() const { return _chunkMap.size(); } | | int numChunks() const { return _chunkMap.size(); } | |
| bool hasShardKey( const BSONObj& obj ) const; | | bool hasShardKey( const BSONObj& obj ) const; | |
| | | | |
|
| void createFirstChunk( const Shard& shard ) const; // only call fro
m DBConfig::shardCollection | | void createFirstChunks( const Shard& shard ) const; // only call fr
om DBConfig::shardCollection | |
| ChunkPtr findChunk( const BSONObj& obj ) const; | | ChunkPtr findChunk( const BSONObj& obj ) const; | |
| ChunkPtr findChunkOnServer( const Shard& shard ) const; | | ChunkPtr findChunkOnServer( const Shard& shard ) const; | |
| | | | |
| const ShardKeyPattern& getShardKey() const { return _key; } | | const ShardKeyPattern& getShardKey() const { return _key; } | |
| bool isUnique() const { return _unique; } | | bool isUnique() const { return _unique; } | |
| | | | |
|
| void maybeChunkCollection() const; | | | |
| | | | |
| void getShardsForQuery( set<Shard>& shards , const BSONObj& query )
const; | | void getShardsForQuery( set<Shard>& shards , const BSONObj& query )
const; | |
| void getAllShards( set<Shard>& all ) const; | | void getAllShards( set<Shard>& all ) const; | |
| void getShardsForRange(set<Shard>& shards, const BSONObj& min, cons
t BSONObj& max) const; // [min, max) | | void getShardsForRange(set<Shard>& shards, const BSONObj& min, cons
t BSONObj& max) const; // [min, max) | |
| | | | |
| string toString() const; | | string toString() const; | |
| | | | |
| ShardChunkVersion getVersion( const Shard& shard ) const; | | ShardChunkVersion getVersion( const Shard& shard ) const; | |
| ShardChunkVersion getVersion() const; | | ShardChunkVersion getVersion() const; | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 356 | | skipping to change at line 354 | |
| | | | |
| const ShardVersionMap _shardVersions; // max version per shard | | const ShardVersionMap _shardVersions; // max version per shard | |
| | | | |
| ShardChunkVersion _version; // max version of any chunk | | ShardChunkVersion _version; // max version of any chunk | |
| | | | |
| mutable mutex _mutex; // only used with _nsLock | | mutable mutex _mutex; // only used with _nsLock | |
| mutable DistributedLock _nsLock; | | mutable DistributedLock _nsLock; | |
| | | | |
| const unsigned long long _sequenceNumber; | | const unsigned long long _sequenceNumber; | |
| | | | |
|
| | | mutable TicketHolder _splitTickets; // number of concurrent splitVe | |
| | | ctor we can do from a splitIfShould per collection | |
| | | | |
| friend class Chunk; | | friend class Chunk; | |
| friend class ChunkRangeManager; // only needed for CRM::assertValid
() | | friend class ChunkRangeManager; // only needed for CRM::assertValid
() | |
| static AtomicUInt NextSequenceNumber; | | static AtomicUInt NextSequenceNumber; | |
| }; | | }; | |
| | | | |
| // like BSONObjCmp. for use as an STL comparison functor | | // like BSONObjCmp. for use as an STL comparison functor | |
| // key-order in "order" argument must match key-order in shardkey | | // key-order in "order" argument must match key-order in shardkey | |
| class ChunkCmp { | | class ChunkCmp { | |
| public: | | public: | |
| ChunkCmp( const BSONObj &order = BSONObj() ) : _cmp( order ) {} | | ChunkCmp( const BSONObj &order = BSONObj() ) : _cmp( order ) {} | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 4 lines changed or added | |
|
| config.h | | config.h | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 117 | |
| }; | | }; | |
| | | | |
| typedef map<string,CollectionInfo> Collections; | | typedef map<string,CollectionInfo> Collections; | |
| | | | |
| public: | | public: | |
| | | | |
| DBConfig( string name ) | | DBConfig( string name ) | |
| : _name( name ) , | | : _name( name ) , | |
| _primary("config","") , | | _primary("config","") , | |
| _shardingEnabled(false), | | _shardingEnabled(false), | |
|
| _lock("DBConfig") { | | _lock("DBConfig") , | |
| | | _hitConfigServerLock( "DBConfig::_hitConfigServerLock" ) { | |
| assert( name.size() ); | | assert( name.size() ); | |
| } | | } | |
| virtual ~DBConfig() {} | | virtual ~DBConfig() {} | |
| | | | |
| string getName() { return _name; }; | | string getName() { return _name; }; | |
| | | | |
| /** | | /** | |
| * @return if anything in this db is partitioned or not | | * @return if anything in this db is partitioned or not | |
| */ | | */ | |
| bool isShardingEnabled() { | | bool isShardingEnabled() { | |
| | | | |
| skipping to change at line 197 | | skipping to change at line 198 | |
| string _name; // e.g. "alleyinsider" | | string _name; // e.g. "alleyinsider" | |
| Shard _primary; // e.g. localhost , mongo.foo.com:9999 | | Shard _primary; // e.g. localhost , mongo.foo.com:9999 | |
| bool _shardingEnabled; | | bool _shardingEnabled; | |
| | | | |
| //map<string,CollectionInfo> _sharded; // { "alleyinsider.blog.post
s" : { ts : 1 } , ... ] - all ns that are sharded | | //map<string,CollectionInfo> _sharded; // { "alleyinsider.blog.post
s" : { ts : 1 } , ... ] - all ns that are sharded | |
| //map<string,ChunkManagerPtr> _shards; // this will only have entri
es for things that have been looked at | | //map<string,ChunkManagerPtr> _shards; // this will only have entri
es for things that have been looked at | |
| | | | |
| Collections _collections; | | Collections _collections; | |
| | | | |
| mutable mongo::mutex _lock; // TODO: change to r/w lock ?? | | mutable mongo::mutex _lock; // TODO: change to r/w lock ?? | |
|
| | | mutable mongo::mutex _hitConfigServerLock; | |
| }; | | }; | |
| | | | |
| class ConfigServer : public DBConfig { | | class ConfigServer : public DBConfig { | |
| public: | | public: | |
| | | | |
| ConfigServer(); | | ConfigServer(); | |
| ~ConfigServer(); | | ~ConfigServer(); | |
| | | | |
| bool ok( bool checkConsistency = false ); | | bool ok( bool checkConsistency = false ); | |
| | | | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 3 lines changed or added | |
|
| connections.h | | connections.h | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 50 | |
| throws exception on connect error (but fine to try again later with
a new | | throws exception on connect error (but fine to try again later with
a new | |
| scopedconn object for same host). | | scopedconn object for same host). | |
| */ | | */ | |
| class ScopedConn { | | class ScopedConn { | |
| public: | | public: | |
| /** throws assertions if connect failure etc. */ | | /** throws assertions if connect failure etc. */ | |
| ScopedConn(string hostport); | | ScopedConn(string hostport); | |
| ~ScopedConn() { | | ~ScopedConn() { | |
| // conLock releases... | | // conLock releases... | |
| } | | } | |
|
| | | void reconnect() { | |
| | | conn()->port().shutdown(); | |
| | | connect(); | |
| | | } | |
| | | | |
| /* If we were to run a query and not exhaust the cursor, future use
of the connection would be problematic. | | /* If we were to run a query and not exhaust the cursor, future use
of the connection would be problematic. | |
| So here what we do is wrapper known safe methods and not allow c
ursor-style queries at all. This makes | | So here what we do is wrapper known safe methods and not allow c
ursor-style queries at all. This makes | |
| ScopedConn limited in functionality but very safe. More non-cur
sor wrappers can be added here if needed. | | ScopedConn limited in functionality but very safe. More non-cur
sor wrappers can be added here if needed. | |
| */ | | */ | |
| bool runCommand(const string &dbname, const BSONObj& cmd, BSONObj &
info, int options=0) { | | bool runCommand(const string &dbname, const BSONObj& cmd, BSONObj &
info, int options=0) { | |
| return conn()->runCommand(dbname, cmd, info, options); | | return conn()->runCommand(dbname, cmd, info, options); | |
| } | | } | |
| unsigned long long count(const string &ns) { | | unsigned long long count(const string &ns) { | |
| return conn()->count(ns); | | return conn()->count(ns); | |
| } | | } | |
| BSONObj findOne(const string &ns, const Query& q, const BSONObj *fi
eldsToReturn = 0, int queryOptions = 0) { | | BSONObj findOne(const string &ns, const Query& q, const BSONObj *fi
eldsToReturn = 0, int queryOptions = 0) { | |
| return conn()->findOne(ns, q, fieldsToReturn, queryOptions); | | return conn()->findOne(ns, q, fieldsToReturn, queryOptions); | |
| } | | } | |
|
| void setTimeout(double to) { | | | |
| conn()->setSoTimeout(to); | | | |
| } | | | |
| | | | |
| private: | | private: | |
| auto_ptr<scoped_lock> connLock; | | auto_ptr<scoped_lock> connLock; | |
| static mongo::mutex mapMutex; | | static mongo::mutex mapMutex; | |
| struct X { | | struct X { | |
| mongo::mutex z; | | mongo::mutex z; | |
| DBClientConnection cc; | | DBClientConnection cc; | |
| X() : z("X"), cc(/*reconnect*/ true, 0, /*timeout*/ 10.0) { | | X() : z("X"), cc(/*reconnect*/ true, 0, /*timeout*/ 10.0) { | |
| cc._logLevel = 2; | | cc._logLevel = 2; | |
| } | | } | |
| } *x; | | } *x; | |
| typedef map<string,ScopedConn::X*> M; | | typedef map<string,ScopedConn::X*> M; | |
| static M& _map; | | static M& _map; | |
| DBClientConnection* conn() { return &x->cc; } | | DBClientConnection* conn() { return &x->cc; } | |
|
| | | const string _hostport; | |
| | | | |
| | | // we should already be locked... | |
| | | bool connect() { | |
| | | string err; | |
| | | if (!x->cc.connect(_hostport, err)) { | |
| | | log() << "couldn't connect to " << _hostport << ": " << err << | |
| | | rsLog; | |
| | | return false; | |
| | | } | |
| | | | |
| | | // if we cannot authenticate against a member, then either its ke | |
| | | y file | |
| | | // or our key file has to change. if our key file has to change, | |
| | | we'll | |
| | | // be rebooting. if their file has to change, they'll be rebooted | |
| | | so the | |
| | | // connection created above will go dead, reconnect, and reauth. | |
| | | if (!noauth && !x->cc.auth("local", internalSecurity.user, intern | |
| | | alSecurity.pwd, err, false)) { | |
| | | log() << "could not authenticate against " << _hostport << ", " | |
| | | << err << rsLog; | |
| | | return false; | |
| | | } | |
| | | | |
| | | return true; | |
| | | } | |
| }; | | }; | |
| | | | |
|
| inline ScopedConn::ScopedConn(string hostport) { | | inline ScopedConn::ScopedConn(string hostport) : _hostport(hostport) { | |
| bool first = false; | | bool first = false; | |
| { | | { | |
| scoped_lock lk(mapMutex); | | scoped_lock lk(mapMutex); | |
|
| x = _map[hostport]; | | x = _map[_hostport]; | |
| if( x == 0 ) { | | if( x == 0 ) { | |
|
| x = _map[hostport] = new X(); | | x = _map[_hostport] = new X(); | |
| first = true; | | first = true; | |
| connLock.reset( new scoped_lock(x->z) ); | | connLock.reset( new scoped_lock(x->z) ); | |
| } | | } | |
| } | | } | |
| if( !first ) { | | if( !first ) { | |
| connLock.reset( new scoped_lock(x->z) ); | | connLock.reset( new scoped_lock(x->z) ); | |
| return; | | return; | |
| } | | } | |
| | | | |
|
| // we already locked above... | | connect(); | |
| string err; | | | |
| if (!x->cc.connect(hostport, err)) { | | | |
| log() << "couldn't connect to " << hostport << ": " << err << r | | | |
| sLog; | | | |
| return; | | | |
| } | | | |
| | | | |
| if (!noauth && !x->cc.auth("local", internalSecurity.user, internal | | | |
| Security.pwd, err, false)) { | | | |
| log() << "could not authenticate against " << conn()->toString( | | | |
| ) << ", " << err << rsLog; | | | |
| return; | | | |
| } | | | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
End of changes. 7 change blocks. |
| 20 lines changed or deleted | | 35 lines changed or added | |
|
| connpool.h | | connpool.h | |
| | | | |
| skipping to change at line 92 | | skipping to change at line 92 | |
| ConnectionString::ConnectionType _type; | | ConnectionString::ConnectionType _type; | |
| | | | |
| static unsigned _maxPerHost; | | static unsigned _maxPerHost; | |
| }; | | }; | |
| | | | |
| class DBConnectionHook { | | class DBConnectionHook { | |
| public: | | public: | |
| virtual ~DBConnectionHook() {} | | virtual ~DBConnectionHook() {} | |
| virtual void onCreate( DBClientBase * conn ) {} | | virtual void onCreate( DBClientBase * conn ) {} | |
| virtual void onHandedOut( DBClientBase * conn ) {} | | virtual void onHandedOut( DBClientBase * conn ) {} | |
|
| virtual void onDestory( DBClientBase * conn ) {} | | virtual void onDestroy( DBClientBase * conn ) {} | |
| }; | | }; | |
| | | | |
| /** Database connection pool. | | /** Database connection pool. | |
| | | | |
| Generally, use ScopedDbConnection and do not call these directly. | | Generally, use ScopedDbConnection and do not call these directly. | |
| | | | |
| This class, so far, is suitable for use with unauthenticated connec
tions. | | This class, so far, is suitable for use with unauthenticated connec
tions. | |
| Support for authenticated connections requires some adjustements: p
lease | | Support for authenticated connections requires some adjustements: p
lease | |
| request... | | request... | |
| | | | |
| | | | |
| skipping to change at line 122 | | skipping to change at line 122 | |
| public: | | public: | |
| | | | |
| DBConnectionPool(); | | DBConnectionPool(); | |
| ~DBConnectionPool(); | | ~DBConnectionPool(); | |
| | | | |
| /** right now just controls some asserts. defaults to "dbconnectio
npool" */ | | /** right now just controls some asserts. defaults to "dbconnectio
npool" */ | |
| void setName( const string& name ) { _name = name; } | | void setName( const string& name ) { _name = name; } | |
| | | | |
| void onCreate( DBClientBase * conn ); | | void onCreate( DBClientBase * conn ); | |
| void onHandedOut( DBClientBase * conn ); | | void onHandedOut( DBClientBase * conn ); | |
|
| void onDestory( DBClientBase * conn ); | | void onDestroy( DBClientBase * conn ); | |
| | | | |
| void flush(); | | void flush(); | |
| | | | |
| DBClientBase *get(const string& host, double socketTimeout = 0); | | DBClientBase *get(const string& host, double socketTimeout = 0); | |
| DBClientBase *get(const ConnectionString& host, double socketTimeou
t = 0); | | DBClientBase *get(const ConnectionString& host, double socketTimeou
t = 0); | |
| | | | |
| void release(const string& host, DBClientBase *c); | | void release(const string& host, DBClientBase *c); | |
| | | | |
| void addHook( DBConnectionHook * hook ); // we take ownership | | void addHook( DBConnectionHook * hook ); // we take ownership | |
| void appendInfo( BSONObjBuilder& b ); | | void appendInfo( BSONObjBuilder& b ); | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| dbclient.h | | dbclient.h | |
| | | | |
| skipping to change at line 722 | | skipping to change at line 722 | |
| /** @return the collection name portion of an ns string */ | | /** @return the collection name portion of an ns string */ | |
| string nsGetCollection( const string &ns ) { | | string nsGetCollection( const string &ns ) { | |
| string::size_type pos = ns.find( "." ); | | string::size_type pos = ns.find( "." ); | |
| if ( pos == string::npos ) | | if ( pos == string::npos ) | |
| return ""; | | return ""; | |
| | | | |
| return ns.substr( pos + 1 ); | | return ns.substr( pos + 1 ); | |
| } | | } | |
| | | | |
| protected: | | protected: | |
|
| | | /** if the result of a command is ok*/ | |
| bool isOk(const BSONObj&); | | bool isOk(const BSONObj&); | |
| | | | |
|
| | | /** if the element contains a not master error */ | |
| | | bool isNotMasterErrorString( const BSONElement& e ); | |
| | | | |
| BSONObj _countCmd(const string &ns, const BSONObj& query, int optio
ns, int limit, int skip ); | | BSONObj _countCmd(const string &ns, const BSONObj& query, int optio
ns, int limit, int skip ); | |
| | | | |
| enum QueryOptions availableOptions(); | | enum QueryOptions availableOptions(); | |
| | | | |
| private: | | private: | |
| enum QueryOptions _cachedAvailableOptions; | | enum QueryOptions _cachedAvailableOptions; | |
| bool _haveCachedAvailableOptions; | | bool _haveCachedAvailableOptions; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 893 | | skipping to change at line 897 | |
| | | | |
| /** Uses QueryOption_Exhaust | | /** Uses QueryOption_Exhaust | |
| Exhaust mode sends back all data queries as fast as possible, w
ith no back-and-for for OP_GETMORE. If you are certain | | Exhaust mode sends back all data queries as fast as possible, w
ith no back-and-for for OP_GETMORE. If you are certain | |
| you will exhaust the query, it could be useful. | | you will exhaust the query, it could be useful. | |
| | | | |
| Use DBClientCursorBatchIterator version if you want to do items
in large blocks, perhaps to avoid granular locking and such. | | Use DBClientCursorBatchIterator version if you want to do items
in large blocks, perhaps to avoid granular locking and such. | |
| */ | | */ | |
| unsigned long long query( boost::function<void(const BSONObj&)> f,
const string& ns, Query query, const BSONObj *fieldsToReturn = 0, int query
Options = 0); | | unsigned long long query( boost::function<void(const BSONObj&)> f,
const string& ns, Query query, const BSONObj *fieldsToReturn = 0, int query
Options = 0); | |
| unsigned long long query( boost::function<void(DBClientCursorBatchI
terator&)> f, const string& ns, Query query, const BSONObj *fieldsToReturn
= 0, int queryOptions = 0); | | unsigned long long query( boost::function<void(DBClientCursorBatchI
terator&)> f, const string& ns, Query query, const BSONObj *fieldsToReturn
= 0, int queryOptions = 0); | |
| | | | |
|
| | | virtual bool runCommand(const string &dbname, const BSONObj& cmd, B | |
| | | SONObj &info, int options=0); | |
| | | | |
| /** | | /** | |
| @return true if this connection is currently in a failed state.
When autoreconnect is on, | | @return true if this connection is currently in a failed state.
When autoreconnect is on, | |
| a connection will transition back to an ok state after r
econnecting. | | a connection will transition back to an ok state after r
econnecting. | |
| */ | | */ | |
| bool isFailed() const { return _failed; } | | bool isFailed() const { return _failed; } | |
| | | | |
| MessagingPort& port() { assert(p); return *p; } | | MessagingPort& port() { assert(p); return *p; } | |
| | | | |
| string toStringLong() const { | | string toStringLong() const { | |
| stringstream ss; | | stringstream ss; | |
| | | | |
End of changes. 3 change blocks. |
| 0 lines changed or deleted | | 7 lines changed or added | |
|
| engine.h | | engine.h | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 135 | |
| right now its just global - slightly inefficient, but a lot simple
r | | right now its just global - slightly inefficient, but a lot simple
r | |
| */ | | */ | |
| static void storedFuncMod(); | | static void storedFuncMod(); | |
| | | | |
| static int getNumScopes() { | | static int getNumScopes() { | |
| return _numScopes; | | return _numScopes; | |
| } | | } | |
| | | | |
| static void validateObjectIdString( const string &str ); | | static void validateObjectIdString( const string &str ); | |
| | | | |
|
| | | /** increments the number of times a scope was used */ | |
| | | void incTimeUsed() { ++_numTimeUsed; } | |
| | | /** gets the number of times a scope was used */ | |
| | | int getTimeUsed() { return _numTimeUsed; } | |
| | | | |
| protected: | | protected: | |
| | | | |
| virtual ScriptingFunction _createFunction( const char * code ) = 0; | | virtual ScriptingFunction _createFunction( const char * code ) = 0; | |
| | | | |
| string _localDBName; | | string _localDBName; | |
| long long _loadedVersion; | | long long _loadedVersion; | |
| set<string> _storedNames; | | set<string> _storedNames; | |
| static long long _lastVersion; | | static long long _lastVersion; | |
| map<string,ScriptingFunction> _cachedFunctions; | | map<string,ScriptingFunction> _cachedFunctions; | |
|
| | | int _numTimeUsed; | |
| | | | |
| static int _numScopes; | | static int _numScopes; | |
| }; | | }; | |
| | | | |
| void installGlobalUtils( Scope& scope ); | | void installGlobalUtils( Scope& scope ); | |
| | | | |
| class DBClientWithCommands; | | class DBClientWithCommands; | |
| | | | |
| class ScriptEngine : boost::noncopyable { | | class ScriptEngine : boost::noncopyable { | |
| public: | | public: | |
| | | | |
| skipping to change at line 171 | | skipping to change at line 177 | |
| installGlobalUtils( *s ); | | installGlobalUtils( *s ); | |
| return s; | | return s; | |
| } | | } | |
| | | | |
| virtual void runTest() = 0; | | virtual void runTest() = 0; | |
| | | | |
| virtual bool utf8Ok() const = 0; | | virtual bool utf8Ok() const = 0; | |
| | | | |
| static void setup(); | | static void setup(); | |
| | | | |
|
| | | /** gets a scope from the pool or a new one if pool is empty | |
| | | * @param pool An identifier for the pool, usually the db name | |
| | | * @return the scope */ | |
| auto_ptr<Scope> getPooledScope( const string& pool ); | | auto_ptr<Scope> getPooledScope( const string& pool ); | |
|
| | | | |
| | | /** call this method to release some JS resources when a thread is | |
| | | done */ | |
| void threadDone(); | | void threadDone(); | |
| | | | |
| struct Unlocker { virtual ~Unlocker() {} }; | | struct Unlocker { virtual ~Unlocker() {} }; | |
| virtual auto_ptr<Unlocker> newThreadUnlocker() { return auto_ptr< U
nlocker >( new Unlocker ); } | | virtual auto_ptr<Unlocker> newThreadUnlocker() { return auto_ptr< U
nlocker >( new Unlocker ); } | |
| | | | |
| void setScopeInitCallback( void ( *func )( Scope & ) ) { _scopeInit
Callback = func; } | | void setScopeInitCallback( void ( *func )( Scope & ) ) { _scopeInit
Callback = func; } | |
| static void setConnectCallback( void ( *func )( DBClientWithCommand
s& ) ) { _connectCallback = func; } | | static void setConnectCallback( void ( *func )( DBClientWithCommand
s& ) ) { _connectCallback = func; } | |
| static void runConnectCallback( DBClientWithCommands &c ) { | | static void runConnectCallback( DBClientWithCommands &c ) { | |
| if ( _connectCallback ) | | if ( _connectCallback ) | |
| _connectCallback( c ); | | _connectCallback( c ); | |
| | | | |
End of changes. 4 change blocks. |
| 0 lines changed or deleted | | 12 lines changed or added | |
|
| oplog.h | | oplog.h | |
| | | | |
| skipping to change at line 132 | | skipping to change at line 132 | |
| bool firstDocMatchesOrEmpty() const; | | bool firstDocMatchesOrEmpty() const; | |
| }; | | }; | |
| | | | |
| void pretouchOperation(const BSONObj& op); | | void pretouchOperation(const BSONObj& op); | |
| void pretouchN(vector<BSONObj>&, unsigned a, unsigned b); | | void pretouchN(vector<BSONObj>&, unsigned a, unsigned b); | |
| | | | |
| /** | | /** | |
| * take an op and apply locally | | * take an op and apply locally | |
| * used for applying from an oplog | | * used for applying from an oplog | |
| * @param fromRepl really from replication or for testing/internal/comm
and/etc... | | * @param fromRepl really from replication or for testing/internal/comm
and/etc... | |
|
| | | * Returns if the op was an update that could not be applied (true on f
ailure) | |
| */ | | */ | |
| bool applyOperation_inlock(const BSONObj& op , bool fromRepl = true ); | | bool applyOperation_inlock(const BSONObj& op , bool fromRepl = true ); | |
|
| | | | |
| | | /** | |
| | | * If applyOperation_inlock should be called again after an update fail | |
| | | s. | |
| | | */ | |
| | | bool shouldRetry(const BSONObj& op , const string& hn); | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 7 lines changed or added | |
|
| repl.h | | repl.h | |
| | | | |
| skipping to change at line 129 | | skipping to change at line 129 | |
| * If 'db' is a new database and its name would conflict with that
of | | * If 'db' is a new database and its name would conflict with that
of | |
| * an existing database, synchronize these database names with the | | * an existing database, synchronize these database names with the | |
| * master. | | * master. | |
| * @return true iff an op with the specified ns may be applied. | | * @return true iff an op with the specified ns may be applied. | |
| */ | | */ | |
| bool handleDuplicateDbName( const BSONObj &op, const char *ns, cons
t char *db ); | | bool handleDuplicateDbName( const BSONObj &op, const char *ns, cons
t char *db ); | |
| | | | |
| public: | | public: | |
| OplogReader oplogReader; | | OplogReader oplogReader; | |
| | | | |
|
| static void applyOperation(const BSONObj& op); | | void applyOperation(const BSONObj& op); | |
| string hostName; // ip addr or hostname plus optionally, ":<port
>" | | string hostName; // ip addr or hostname plus optionally, ":<port
>" | |
| string _sourceName; // a logical source name. | | string _sourceName; // a logical source name. | |
| string sourceName() const { return _sourceName.empty() ? "main" : _
sourceName; } | | string sourceName() const { return _sourceName.empty() ? "main" : _
sourceName; } | |
| string only; // only a certain db. note that in the sources collect
ion, this may not be changed once you start replicating. | | string only; // only a certain db. note that in the sources collect
ion, this may not be changed once you start replicating. | |
| | | | |
| /* the last time point we have already synced up to (in the remote/
master's oplog). */ | | /* the last time point we have already synced up to (in the remote/
master's oplog). */ | |
| OpTime syncedTo; | | OpTime syncedTo; | |
| | | | |
| int nClonedThisPass; | | int nClonedThisPass; | |
| | | | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| rs.h | | rs.h | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 96 | |
| int _primary; | | int _primary; | |
| | | | |
| /** @param two - if true two primaries were seen. this can happen
transiently, in addition to our | | /** @param two - if true two primaries were seen. this can happen
transiently, in addition to our | |
| polling being only occasional. in this case null
is returned, but the caller should | | polling being only occasional. in this case null
is returned, but the caller should | |
| not assume primary itself in that situation. | | not assume primary itself in that situation. | |
| */ | | */ | |
| const Member* findOtherPrimary(bool& two); | | const Member* findOtherPrimary(bool& two); | |
| | | | |
| void noteARemoteIsPrimary(const Member *); | | void noteARemoteIsPrimary(const Member *); | |
| void checkElectableSet(); | | void checkElectableSet(); | |
|
| | | void checkAuth(); | |
| virtual void starting(); | | virtual void starting(); | |
| public: | | public: | |
| Manager(ReplSetImpl *rs); | | Manager(ReplSetImpl *rs); | |
| virtual ~Manager(); | | virtual ~Manager(); | |
| void msgReceivedNewConfig(BSONObj); | | void msgReceivedNewConfig(BSONObj); | |
| void msgCheckNewState(); | | void msgCheckNewState(); | |
| }; | | }; | |
| | | | |
| class GhostSync : public task::Server { | | class GhostSync : public task::Server { | |
| struct GhostSlave { | | struct GhostSlave { | |
| | | | |
| skipping to change at line 351 | | skipping to change at line 352 | |
| void assumePrimary(); | | void assumePrimary(); | |
| void loadLastOpTimeWritten(bool quiet=false); | | void loadLastOpTimeWritten(bool quiet=false); | |
| void changeState(MemberState s); | | void changeState(MemberState s); | |
| | | | |
| /** | | /** | |
| * Find the closest member (using ping time) with a higher latest o
ptime. | | * Find the closest member (using ping time) with a higher latest o
ptime. | |
| */ | | */ | |
| const Member* getMemberToSyncTo(); | | const Member* getMemberToSyncTo(); | |
| Member* _currentSyncTarget; | | Member* _currentSyncTarget; | |
| | | | |
|
| | | bool _blockSync; | |
| | | void blockSync(bool block); | |
| | | | |
| // set of electable members' _ids | | // set of electable members' _ids | |
| set<unsigned> _electableSet; | | set<unsigned> _electableSet; | |
| protected: | | protected: | |
| // "heartbeat message" | | // "heartbeat message" | |
| // sent in requestHeartbeat respond in field "hbm" | | // sent in requestHeartbeat respond in field "hbm" | |
| char _hbmsg[256]; // we change this unlocked, thus not an stl::stri
ng | | char _hbmsg[256]; // we change this unlocked, thus not an stl::stri
ng | |
| time_t _hbmsgTime; // when it was logged | | time_t _hbmsgTime; // when it was logged | |
| public: | | public: | |
| void sethbmsg(string s, int logLevel = 0); | | void sethbmsg(string s, int logLevel = 0); | |
| | | | |
| | | | |
| skipping to change at line 580 | | skipping to change at line 584 | |
| virtual bool logTheOp() { return false; } | | virtual bool logTheOp() { return false; } | |
| virtual LockType locktype() const { return NONE; } | | virtual LockType locktype() const { return NONE; } | |
| virtual void help( stringstream &help ) const { help << "internal";
} | | virtual void help( stringstream &help ) const { help << "internal";
} | |
| | | | |
| /** | | /** | |
| * Some replica set commands call this and then call check(). This
is | | * Some replica set commands call this and then call check(). This
is | |
| * intentional, as they might do things before theReplSet is initia
lized | | * intentional, as they might do things before theReplSet is initia
lized | |
| * that still need to be checked for auth. | | * that still need to be checked for auth. | |
| */ | | */ | |
| bool checkAuth(string& errmsg, BSONObjBuilder& result) { | | bool checkAuth(string& errmsg, BSONObjBuilder& result) { | |
|
| if( !noauth && adminOnly() ) { | | if( !noauth ) { | |
| AuthenticationInfo *ai = cc().getAuthenticationInfo(); | | AuthenticationInfo *ai = cc().getAuthenticationInfo(); | |
| if (!ai->isAuthorizedForLock("admin", locktype())) { | | if (!ai->isAuthorizedForLock("admin", locktype())) { | |
| errmsg = "replSet command unauthorized"; | | errmsg = "replSet command unauthorized"; | |
| return false; | | return false; | |
| } | | } | |
| } | | } | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| bool check(string& errmsg, BSONObjBuilder& result) { | | bool check(string& errmsg, BSONObjBuilder& result) { | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 5 lines changed or added | |
|
| rs_member.h | | rs_member.h | |
| | | | |
| skipping to change at line 71 | | skipping to change at line 71 | |
| | | | |
| bool operator==(const MemberState& r) const { return s == r.s; } | | bool operator==(const MemberState& r) const { return s == r.s; } | |
| bool operator!=(const MemberState& r) const { return s != r.s; } | | bool operator!=(const MemberState& r) const { return s != r.s; } | |
| }; | | }; | |
| | | | |
| /* this is supposed to be just basic information on a member, | | /* this is supposed to be just basic information on a member, | |
| and copy constructable. */ | | and copy constructable. */ | |
| class HeartbeatInfo { | | class HeartbeatInfo { | |
| unsigned _id; | | unsigned _id; | |
| public: | | public: | |
|
| HeartbeatInfo() : _id(0xffffffff),hbstate(MemberState::RS_UNKNOWN), | | HeartbeatInfo() : _id(0xffffffff), hbstate(MemberState::RS_UNKNOWN) | |
| health(-1.0),downSince(0),skew(INT_MIN) { } | | , health(-1.0), | |
| | | downSince(0), skew(INT_MIN), authIssue(false) { } | |
| HeartbeatInfo(unsigned id); | | HeartbeatInfo(unsigned id); | |
| unsigned id() const { return _id; } | | unsigned id() const { return _id; } | |
| MemberState hbstate; | | MemberState hbstate; | |
| double health; | | double health; | |
| time_t upSince; | | time_t upSince; | |
| long long downSince; | | long long downSince; | |
| time_t lastHeartbeat; | | time_t lastHeartbeat; | |
| DiagStr lastHeartbeatMsg; | | DiagStr lastHeartbeatMsg; | |
| OpTime opTime; | | OpTime opTime; | |
| int skew; | | int skew; | |
|
| | | bool authIssue; | |
| unsigned int ping; // milliseconds | | unsigned int ping; // milliseconds | |
| static unsigned int numPings; | | static unsigned int numPings; | |
| | | | |
| bool up() const { return health > 0; } | | bool up() const { return health > 0; } | |
| | | | |
| /** health is set to -1 on startup. that means we haven't even che
cked yet. 0 means we checked and it failed. */ | | /** health is set to -1 on startup. that means we haven't even che
cked yet. 0 means we checked and it failed. */ | |
| bool maybeUp() const { return health != 0; } | | bool maybeUp() const { return health != 0; } | |
| | | | |
| long long timeDown() const; // ms | | long long timeDown() const; // ms | |
| | | | |
| /* true if changed in a way of interest to the repl set manager. */ | | /* true if changed in a way of interest to the repl set manager. */ | |
| bool changed(const HeartbeatInfo& old) const; | | bool changed(const HeartbeatInfo& old) const; | |
| }; | | }; | |
| | | | |
|
| inline HeartbeatInfo::HeartbeatInfo(unsigned id) : _id(id) { | | inline HeartbeatInfo::HeartbeatInfo(unsigned id) : _id(id), authIssue(f
alse) { | |
| hbstate = MemberState::RS_UNKNOWN; | | hbstate = MemberState::RS_UNKNOWN; | |
| health = -1.0; | | health = -1.0; | |
| downSince = 0; | | downSince = 0; | |
| lastHeartbeat = upSince = 0; | | lastHeartbeat = upSince = 0; | |
| skew = INT_MIN; | | skew = INT_MIN; | |
| } | | } | |
| | | | |
| inline bool HeartbeatInfo::changed(const HeartbeatInfo& old) const { | | inline bool HeartbeatInfo::changed(const HeartbeatInfo& old) const { | |
| return health != old.health || | | return health != old.health || | |
| hbstate != old.hbstate; | | hbstate != old.hbstate; | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 5 lines changed or added | |
|
| shard.h | | shard.h | |
| | | | |
| skipping to change at line 215 | | skipping to change at line 215 | |
| | | | |
| private: | | private: | |
| Shard _shard; | | Shard _shard; | |
| long long _mapped; | | long long _mapped; | |
| bool _hasOpsQueued; // true if 'writebacks' are pending | | bool _hasOpsQueued; // true if 'writebacks' are pending | |
| double _writeLock; | | double _writeLock; | |
| }; | | }; | |
| | | | |
| class ShardConnection : public AScopedConnection { | | class ShardConnection : public AScopedConnection { | |
| public: | | public: | |
|
| ShardConnection( const Shard * s , const string& ns, bool ignoreDir | | ShardConnection( const Shard * s , const string& ns ); | |
| ect = false ); | | ShardConnection( const Shard& s , const string& ns ); | |
| ShardConnection( const Shard& s , const string& ns, bool ignoreDire | | ShardConnection( const string& addr , const string& ns ); | |
| ct = false ); | | | |
| ShardConnection( const string& addr , const string& ns, bool ignore | | | |
| Direct = false ); | | | |
| | | | |
| ~ShardConnection(); | | ~ShardConnection(); | |
| | | | |
| void done(); | | void done(); | |
| void kill(); | | void kill(); | |
| | | | |
| DBClientBase& conn() { | | DBClientBase& conn() { | |
| _finishInit(); | | _finishInit(); | |
| assert( _conn ); | | assert( _conn ); | |
| return *_conn; | | return *_conn; | |
| | | | |
| skipping to change at line 269 | | skipping to change at line 269 | |
| | | | |
| /** | | /** | |
| this just passes through excpet it checks for stale configs | | this just passes through excpet it checks for stale configs | |
| */ | | */ | |
| bool runCommand( const string& db , const BSONObj& cmd , BSONObj& r
es ); | | bool runCommand( const string& db , const BSONObj& cmd , BSONObj& r
es ); | |
| | | | |
| /** checks all of my thread local connections for the version of th
is ns */ | | /** checks all of my thread local connections for the version of th
is ns */ | |
| static void checkMyConnectionVersions( const string & ns ); | | static void checkMyConnectionVersions( const string & ns ); | |
| | | | |
| private: | | private: | |
|
| void _init( bool ignoreDirect = false ); | | void _init(); | |
| void _finishInit(); | | void _finishInit(); | |
| | | | |
| bool _finishedInit; | | bool _finishedInit; | |
| | | | |
| string _addr; | | string _addr; | |
| string _ns; | | string _ns; | |
| DBClientBase* _conn; | | DBClientBase* _conn; | |
| bool _setVersion; | | bool _setVersion; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 291 | | skipping to change at line 291 | |
| | | | |
| class ShardingConnectionHook : public DBConnectionHook { | | class ShardingConnectionHook : public DBConnectionHook { | |
| public: | | public: | |
| | | | |
| ShardingConnectionHook( bool shardedConnections ) | | ShardingConnectionHook( bool shardedConnections ) | |
| : _shardedConnections( shardedConnections ) { | | : _shardedConnections( shardedConnections ) { | |
| } | | } | |
| | | | |
| virtual void onCreate( DBClientBase * conn ); | | virtual void onCreate( DBClientBase * conn ); | |
| virtual void onHandedOut( DBClientBase * conn ); | | virtual void onHandedOut( DBClientBase * conn ); | |
|
| virtual void onDestory( DBClientBase * conn ); | | virtual void onDestroy( DBClientBase * conn ); | |
| | | | |
| bool _shardedConnections; | | bool _shardedConnections; | |
| }; | | }; | |
| } | | } | |
| | | | |
End of changes. 3 change blocks. |
| 8 lines changed or deleted | | 5 lines changed or added | |
|
| stringdata.h | | stringdata.h | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 64 | |
| | | | |
| // Construct a StringData explicitly, for the case of a literal who
se size is | | // Construct a StringData explicitly, for the case of a literal who
se size is | |
| // known at compile time. | | // known at compile time. | |
| struct LiteralTag {}; | | struct LiteralTag {}; | |
| template<size_t N> | | template<size_t N> | |
| StringData( const char (&val)[N], LiteralTag ) | | StringData( const char (&val)[N], LiteralTag ) | |
| : _data(&val[0]), _size(N-1) {} | | : _data(&val[0]), _size(N-1) {} | |
| | | | |
| // accessors | | // accessors | |
| const char* data() const { return _data; } | | const char* data() const { return _data; } | |
|
| const unsigned size() const { return _size; } | | unsigned size() const { return _size; } | |
| | | | |
| private: | | private: | |
| const char* const _data; // is always null terminated | | const char* const _data; // is always null terminated | |
| const unsigned _size; // 'size' does not include the null termi
nator | | const unsigned _size; // 'size' does not include the null termi
nator | |
| }; | | }; | |
| | | | |
| } // namespace mongo | | } // namespace mongo | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|