| clientcursor.h | | clientcursor.h | |
| | | | |
| skipping to change at line 196 | | skipping to change at line 196 | |
| | | | |
| /** | | /** | |
| * @return same as yield() | | * @return same as yield() | |
| */ | | */ | |
| bool yieldSometimes(); | | bool yieldSometimes(); | |
| | | | |
| static int yieldSuggest(); | | static int yieldSuggest(); | |
| static void staticYield( int micros ); | | static void staticYield( int micros ); | |
| | | | |
| struct YieldData { CursorId _id; bool _doingDeletes; }; | | struct YieldData { CursorId _id; bool _doingDeletes; }; | |
|
| void prepareToYield( YieldData &data ); | | bool prepareToYield( YieldData &data ); | |
| static bool recoverFromYield( const YieldData &data ); | | static bool recoverFromYield( const YieldData &data ); | |
| | | | |
| struct YieldLock : boost::noncopyable { | | struct YieldLock : boost::noncopyable { | |
| explicit YieldLock( ptr<ClientCursor> cc ) | | explicit YieldLock( ptr<ClientCursor> cc ) | |
|
| : _cc( cc ) , _id( cc->cursorid ) , _doingDeletes( cc->_doi
ngDeletes ), _canYield(cc->c->supportYields()) { | | : _canYield(cc->c->supportYields()) { | |
| if ( _canYield ){ | | if ( _canYield ){ | |
|
| cc->updateLocation(); | | cc->prepareToYield( _data ); | |
| _unlock.reset(new dbtempreleasecond()); | | _unlock.reset(new dbtempreleasecond()); | |
| } | | } | |
| } | | } | |
| ~YieldLock(){ | | ~YieldLock(){ | |
| if ( _unlock ){ | | if ( _unlock ){ | |
| log( LL_WARNING ) << "ClientCursor::YieldLock not close
d properly" << endl; | | log( LL_WARNING ) << "ClientCursor::YieldLock not close
d properly" << endl; | |
| relock(); | | relock(); | |
| } | | } | |
| } | | } | |
| | | | |
| bool stillOk(){ | | bool stillOk(){ | |
| if ( ! _canYield ) | | if ( ! _canYield ) | |
| return true; | | return true; | |
| | | | |
| relock(); | | relock(); | |
| | | | |
|
| if ( ClientCursor::find( _id , false ) == 0 ){ | | return ClientCursor::recoverFromYield( _data ); | |
| // i was deleted | | | |
| return false; | | | |
| } | | | |
| | | | |
| _cc->_doingDeletes = _doingDeletes; | | | |
| return true; | | | |
| } | | } | |
| | | | |
| void relock(){ | | void relock(){ | |
|
| if ( _canYield ) | | _unlock.reset(); | |
| _unlock.reset(); | | | |
| } | | } | |
| | | | |
| private: | | private: | |
|
| ClientCursor * _cc; | | | |
| CursorId _id; | | | |
| bool _doingDeletes; | | | |
| bool _canYield; | | bool _canYield; | |
|
| | | YieldData _data; | |
| | | | |
| scoped_ptr<dbtempreleasecond> _unlock; | | scoped_ptr<dbtempreleasecond> _unlock; | |
| | | | |
| }; | | }; | |
| | | | |
| // --- some pass through helpers for Cursor --- | | // --- some pass through helpers for Cursor --- | |
| | | | |
| BSONObj indexKeyPattern() { | | BSONObj indexKeyPattern() { | |
| return c->indexKeyPattern(); | | return c->indexKeyPattern(); | |
| } | | } | |
| | | | |
End of changes. 7 change blocks. |
| 15 lines changed or deleted | | 6 lines changed or added | |
|
| cursors.h | | cursors.h | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| | | | |
| #include "../db/jsobj.h" | | #include "../db/jsobj.h" | |
| #include "../db/dbmessage.h" | | #include "../db/dbmessage.h" | |
| #include "../client/dbclient.h" | | #include "../client/dbclient.h" | |
| #include "../client/parallel.h" | | #include "../client/parallel.h" | |
| | | | |
| #include "request.h" | | #include "request.h" | |
| | | | |
| namespace mongo { | | namespace mongo { | |
| | | | |
|
| class ShardedClientCursor { | | class ShardedClientCursor : boost::noncopyable { | |
| public: | | public: | |
| ShardedClientCursor( QueryMessage& q , ClusteredCursor * cursor ); | | ShardedClientCursor( QueryMessage& q , ClusteredCursor * cursor ); | |
| virtual ~ShardedClientCursor(); | | virtual ~ShardedClientCursor(); | |
| | | | |
|
| long long getId(){ return _id; } | | long long getId(); | |
| | | | |
| /** | | /** | |
| * @return whether there is more data left | | * @return whether there is more data left | |
| */ | | */ | |
| bool sendNextBatch( Request& r ){ return sendNextBatch( r , _ntoret
urn ); } | | bool sendNextBatch( Request& r ){ return sendNextBatch( r , _ntoret
urn ); } | |
| bool sendNextBatch( Request& r , int ntoreturn ); | | bool sendNextBatch( Request& r , int ntoreturn ); | |
| | | | |
|
| | | void accessed(); | |
| | | /** @return idle time in ms */ | |
| | | long long idleTime( long long now ); | |
| | | | |
| protected: | | protected: | |
| | | | |
| ClusteredCursor * _cursor; | | ClusteredCursor * _cursor; | |
| | | | |
| int _skip; | | int _skip; | |
| int _ntoreturn; | | int _ntoreturn; | |
| | | | |
| int _totalSent; | | int _totalSent; | |
| bool _done; | | bool _done; | |
| | | | |
| long long _id; | | long long _id; | |
|
| | | long long _lastAccessMillis; // 0 means no timeout | |
| | | | |
| }; | | }; | |
| | | | |
| typedef boost::shared_ptr<ShardedClientCursor> ShardedClientCursorPtr; | | typedef boost::shared_ptr<ShardedClientCursor> ShardedClientCursorPtr; | |
| | | | |
| class CursorCache { | | class CursorCache { | |
| public: | | public: | |
| | | | |
|
| | | static long long TIMEOUT; | |
| | | | |
| typedef map<long long,ShardedClientCursorPtr> MapSharded; | | typedef map<long long,ShardedClientCursorPtr> MapSharded; | |
| typedef map<long long,string> MapNormal; | | typedef map<long long,string> MapNormal; | |
| | | | |
| CursorCache(); | | CursorCache(); | |
| ~CursorCache(); | | ~CursorCache(); | |
| | | | |
| ShardedClientCursorPtr get( long long id ); | | ShardedClientCursorPtr get( long long id ); | |
| void store( ShardedClientCursorPtr cursor ); | | void store( ShardedClientCursorPtr cursor ); | |
| void remove( long long id ); | | void remove( long long id ); | |
| | | | |
| void storeRef( const string& server , long long id ); | | void storeRef( const string& server , long long id ); | |
| | | | |
| void gotKillCursors(Message& m ); | | void gotKillCursors(Message& m ); | |
| | | | |
| void appendInfo( BSONObjBuilder& result ); | | void appendInfo( BSONObjBuilder& result ); | |
| | | | |
|
| | | long long genId(); | |
| | | | |
| | | void doTimeouts(); | |
| | | void startTimeoutThread(); | |
| private: | | private: | |
| mutex _mutex; | | mutex _mutex; | |
|
| | | | |
| MapSharded _cursors; | | MapSharded _cursors; | |
| MapNormal _refs; | | MapNormal _refs; | |
|
| | | | |
| | | long long _shardedTotal; | |
| }; | | }; | |
| | | | |
| extern CursorCache cursorCache; | | extern CursorCache cursorCache; | |
| } | | } | |
| | | | |
End of changes. 8 change blocks. |
| 2 lines changed or deleted | | 17 lines changed or added | |
|
| dbclient.h | | dbclient.h | |
| | | | |
| skipping to change at line 125 | | skipping to change at line 125 | |
| _type = type; | | _type = type; | |
| _setName = setName; | | _setName = setName; | |
| _fillServers( s ); | | _fillServers( s ); | |
| | | | |
| switch ( _type ){ | | switch ( _type ){ | |
| case MASTER: | | case MASTER: | |
| assert( _servers.size() == 1 ); | | assert( _servers.size() == 1 ); | |
| break; | | break; | |
| case SET: | | case SET: | |
| assert( _setName.size() ); | | assert( _setName.size() ); | |
|
| assert( _servers.size() > 1 ); | | assert( _servers.size() >= 1 ); // 1 is ok since we can der
ive | |
| break; | | break; | |
| case PAIR: | | case PAIR: | |
| assert( _servers.size() == 2 ); | | assert( _servers.size() == 2 ); | |
| break; | | break; | |
| default: | | default: | |
| assert( _servers.size() > 0 ); | | assert( _servers.size() > 0 ); | |
| } | | } | |
| | | | |
| _finishInit(); | | _finishInit(); | |
| } | | } | |
| | | | |
| skipping to change at line 176 | | skipping to change at line 176 | |
| string::size_type idx; | | string::size_type idx; | |
| while ( ( idx = s.find( ',' ) ) != string::npos ){ | | while ( ( idx = s.find( ',' ) ) != string::npos ){ | |
| _servers.push_back( s.substr( 0 , idx ) ); | | _servers.push_back( s.substr( 0 , idx ) ); | |
| s = s.substr( idx + 1 ); | | s = s.substr( idx + 1 ); | |
| } | | } | |
| _servers.push_back( s ); | | _servers.push_back( s ); | |
| } | | } | |
| | | | |
| void _finishInit(){ | | void _finishInit(){ | |
| stringstream ss; | | stringstream ss; | |
|
| | | if ( _type == SET ) | |
| | | ss << _setName << "/"; | |
| for ( unsigned i=0; i<_servers.size(); i++ ){ | | for ( unsigned i=0; i<_servers.size(); i++ ){ | |
| if ( i > 0 ) | | if ( i > 0 ) | |
| ss << ","; | | ss << ","; | |
| ss << _servers[i].toString(); | | ss << _servers[i].toString(); | |
| } | | } | |
| _string = ss.str(); | | _string = ss.str(); | |
| } | | } | |
| | | | |
| ConnectionType _type; | | ConnectionType _type; | |
| vector<HostAndPort> _servers; | | vector<HostAndPort> _servers; | |
| | | | |
| skipping to change at line 849 | | skipping to change at line 851 | |
| | | | |
| virtual bool auth(const string &dbname, const string &username, con
st string &pwd, string& errmsg, bool digestPassword = true); | | virtual bool auth(const string &dbname, const string &username, con
st string &pwd, string& errmsg, bool digestPassword = true); | |
| | | | |
| virtual auto_ptr<DBClientCursor> query(const string &ns, Query quer
y=Query(), int nToReturn = 0, int nToSkip = 0, | | virtual auto_ptr<DBClientCursor> query(const string &ns, Query quer
y=Query(), int nToReturn = 0, int nToSkip = 0, | |
| const BSONObj *fieldsToRetur
n = 0, int queryOptions = 0 , int batchSize = 0 ) { | | const BSONObj *fieldsToRetur
n = 0, int queryOptions = 0 , int batchSize = 0 ) { | |
| checkConnection(); | | checkConnection(); | |
| return DBClientBase::query( ns, query, nToReturn, nToSkip, fiel
dsToReturn, queryOptions , batchSize ); | | return DBClientBase::query( ns, query, nToReturn, nToSkip, fiel
dsToReturn, queryOptions , batchSize ); | |
| } | | } | |
| | | | |
| /** uses QueryOption_Exhaust | | /** uses QueryOption_Exhaust | |
|
| | | use DBClientCursorBatchIterator if you want to do items in larg
e blocks, perhpas 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); | |
| | | | |
| /** | | /** | |
| @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 { | | bool isFailed() const { | |
| return failed; | | return failed; | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 4 lines changed or added | |
|
| grid.h | | grid.h | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| * TODO: used shard_ptr for DBConfig pointers | | * TODO: used shard_ptr for DBConfig pointers | |
| */ | | */ | |
| class Grid { | | class Grid { | |
| public: | | public: | |
| Grid() : _lock( "Grid" ) , _allowLocalShard( true ) { } | | Grid() : _lock( "Grid" ) , _allowLocalShard( true ) { } | |
| | | | |
| /** | | /** | |
| * gets the config the db. | | * gets the config the db. | |
| * will return an empty DBConfig if not in db already | | * will return an empty DBConfig if not in db already | |
| */ | | */ | |
|
| DBConfigPtr getDBConfig( string ns , bool create=true ); | | DBConfigPtr getDBConfig( string ns , bool create=true , const strin
g& shardNameHint="" ); | |
| | | | |
| /** | | /** | |
| * removes db entry. | | * removes db entry. | |
| * on next getDBConfig call will fetch from db | | * on next getDBConfig call will fetch from db | |
| */ | | */ | |
| void removeDB( string db ); | | void removeDB( string db ); | |
| | | | |
| /** | | /** | |
| * @return true if shards and config servers are allowed to use 'lo
calhost' in address | | * @return true if shards and config servers are allowed to use 'lo
calhost' in address | |
| */ | | */ | |
| | | | |
| skipping to change at line 71 | | skipping to change at line 71 | |
| * TODO - add the mongod's databases to the grid | | * TODO - add the mongod's databases to the grid | |
| * | | * | |
| * @param name is an optional string with the name of the shard. if
ommited, grid will | | * @param name is an optional string with the name of the shard. if
ommited, grid will | |
| * generate one and update the parameter. | | * generate one and update the parameter. | |
| * @param host is the complete address of the machine where the sha
rd will be | | * @param host is the complete address of the machine where the sha
rd will be | |
| * @param maxSize is the optional space quota in bytes. Zeros means
there's no limitation to | | * @param maxSize is the optional space quota in bytes. Zeros means
there's no limitation to | |
| * space usage | | * space usage | |
| * @param errMsg is the error description in case the operation fai
led. | | * @param errMsg is the error description in case the operation fai
led. | |
| * @return true if shard was successfully added. | | * @return true if shard was successfully added. | |
| */ | | */ | |
|
| bool addShard( string* name , const string& host , long long maxSiz
e , string* errMsg ); | | bool addShard( string* name , const string& host , long long maxSiz
e , string& errMsg ); | |
| | | | |
| /** | | /** | |
| * @return true if the config database knows about a host 'name' | | * @return true if the config database knows about a host 'name' | |
| */ | | */ | |
| bool knowAboutShard( const string& name ) const; | | bool knowAboutShard( const string& name ) const; | |
| | | | |
| /** | | /** | |
| * @return true if the chunk balancing functionality is enabled | | * @return true if the chunk balancing functionality is enabled | |
| */ | | */ | |
| bool shouldBalance() const; | | bool shouldBalance() const; | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| health.h | | health.h | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| | | | |
| /* throws */ | | /* throws */ | |
| bool requestHeartbeat(string setname, string fromHost, string memberFul
lName, BSONObj& result, int myConfigVersion, int& theirConfigVersion, bool
checkEmpty = false); | | bool requestHeartbeat(string setname, string fromHost, string memberFul
lName, BSONObj& result, int myConfigVersion, int& theirConfigVersion, bool
checkEmpty = false); | |
| | | | |
| struct HealthOptions { | | struct HealthOptions { | |
| HealthOptions() { | | HealthOptions() { | |
| heartbeatSleepMillis = 2000; | | heartbeatSleepMillis = 2000; | |
| heartbeatTimeoutMillis = 10000; | | heartbeatTimeoutMillis = 10000; | |
| heartbeatConnRetries = 3; | | heartbeatConnRetries = 3; | |
| } | | } | |
|
| bool isDefault() const { | | | |
| return !( heartbeatSleepMillis != 2000 || heartbeatTimeoutMilli | | bool isDefault() const { return *this == HealthOptions(); } | |
| s != 10000 || heartbeatConnRetries != 3 ); | | | |
| } | | | |
| | | | |
| // see http://www.mongodb.org/display/DOCS/Replica+Set+Internals | | // see http://www.mongodb.org/display/DOCS/Replica+Set+Internals | |
| unsigned heartbeatSleepMillis; | | unsigned heartbeatSleepMillis; | |
| unsigned heartbeatTimeoutMillis; | | unsigned heartbeatTimeoutMillis; | |
| unsigned heartbeatConnRetries ; | | unsigned heartbeatConnRetries ; | |
| | | | |
| void check() { | | void check() { | |
| uassert(13112, "bad replset heartbeat option", heartbeatSleepMi
llis >= 10); | | uassert(13112, "bad replset heartbeat option", heartbeatSleepMi
llis >= 10); | |
| uassert(13113, "bad replset heartbeat option", heartbeatTimeout
Millis >= 10); | | uassert(13113, "bad replset heartbeat option", heartbeatTimeout
Millis >= 10); | |
| } | | } | |
|
| | | | |
| | | bool operator==(const HealthOptions& r) const { | |
| | | return heartbeatSleepMillis==r.heartbeatSleepMillis && heartbea | |
| | | tTimeoutMillis==r.heartbeatTimeoutMillis && heartbeatConnRetries==heartbeat | |
| | | ConnRetries; | |
| | | } | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 4 lines changed or deleted | | 8 lines changed or added | |
|
| namespace.h | | namespace.h | |
| | | | |
| skipping to change at line 274 | | skipping to change at line 274 | |
| DiskLoc &cappedFirstDeletedInCurExtent(); | | DiskLoc &cappedFirstDeletedInCurExtent(); | |
| bool nextIsInCapExtent( const DiskLoc &dl ) const; | | bool nextIsInCapExtent( const DiskLoc &dl ) const; | |
| public: | | public: | |
| DiskLoc& cappedListOfAllDeletedRecords() { return deletedList[0]; } | | DiskLoc& cappedListOfAllDeletedRecords() { return deletedList[0]; } | |
| DiskLoc& cappedLastDelRecLastExtent() { return deletedList[1]; } | | DiskLoc& cappedLastDelRecLastExtent() { return deletedList[1]; } | |
| void cappedDumpDelInfo(); | | void cappedDumpDelInfo(); | |
| bool capLooped() const { return capped && capFirstNewRecord.isValid
(); } | | bool capLooped() const { return capped && capFirstNewRecord.isValid
(); } | |
| bool inCapExtent( const DiskLoc &dl ) const; | | bool inCapExtent( const DiskLoc &dl ) const; | |
| void cappedCheckMigrate(); | | void cappedCheckMigrate(); | |
| void cappedTruncateAfter(const char *ns, DiskLoc after, bool inclus
ive); /** remove rest of the capped collection from this point onward */ | | void cappedTruncateAfter(const char *ns, DiskLoc after, bool inclus
ive); /** remove rest of the capped collection from this point onward */ | |
|
| | | void emptyCappedCollection(const char *ns); | |
| | | | |
| int capped; | | int capped; | |
| | | | |
| int max; // max # of objects for a capped table. TODO: should this
be 64 bit? | | int max; // max # of objects for a capped table. TODO: should this
be 64 bit? | |
| double paddingFactor; // 1.0 = no padding. | | double paddingFactor; // 1.0 = no padding. | |
| int flags; | | int flags; | |
| | | | |
| DiskLoc capExtent; | | DiskLoc capExtent; | |
| DiskLoc capFirstNewRecord; | | DiskLoc capFirstNewRecord; | |
| | | | |
| | | | |
| skipping to change at line 310 | | skipping to change at line 311 | |
| */ | | */ | |
| int nIndexesBeingBuilt() const { return nIndexes + backgroundIndexB
uildInProgress; } | | int nIndexesBeingBuilt() const { return nIndexes + backgroundIndexB
uildInProgress; } | |
| | | | |
| /* NOTE: be careful with flags. are we manipulating them in read l
ocks? if so, | | /* NOTE: be careful with flags. are we manipulating them in read l
ocks? if so, | |
| this isn't thread safe. TODO | | this isn't thread safe. TODO | |
| */ | | */ | |
| enum NamespaceFlags { | | enum NamespaceFlags { | |
| Flag_HaveIdIndex = 1 << 0 // set when we have _id index (ONLY i
f ensureIdIndex was called -- 0 if that has never been called) | | Flag_HaveIdIndex = 1 << 0 // set when we have _id index (ONLY i
f ensureIdIndex was called -- 0 if that has never been called) | |
| }; | | }; | |
| | | | |
|
| IndexDetails& idx(int idxNo) { | | IndexDetails& idx(int idxNo, bool missingExpected = false ) { | |
| if( idxNo < NIndexesBase ) | | if( idxNo < NIndexesBase ) | |
| return _indexes[idxNo]; | | return _indexes[idxNo]; | |
| Extra *e = extra(); | | Extra *e = extra(); | |
|
| massert(13282, "missing Extra", e); | | if ( ! e ){ | |
| | | if ( missingExpected ) | |
| | | throw MsgAssertionException( 13283 , "Missing Extra" ); | |
| | | massert(13282, "missing Extra", e); | |
| | | } | |
| int i = idxNo - NIndexesBase; | | int i = idxNo - NIndexesBase; | |
| if( i >= NIndexesExtra ) { | | if( i >= NIndexesExtra ) { | |
| e = e->next(this); | | e = e->next(this); | |
|
| massert(13283, "missing Extra", e); | | if ( ! e ){ | |
| | | if ( missingExpected ) | |
| | | throw MsgAssertionException( 13283 , "missing extra | |
| | | " ); | |
| | | massert(13283, "missing Extra", e); | |
| | | } | |
| i -= NIndexesExtra; | | i -= NIndexesExtra; | |
| } | | } | |
| return e->details[i]; | | return e->details[i]; | |
| } | | } | |
| IndexDetails& backgroundIdx() { | | IndexDetails& backgroundIdx() { | |
| DEV assert(backgroundIndexBuildInProgress); | | DEV assert(backgroundIndexBuildInProgress); | |
| return idx(nIndexes); | | return idx(nIndexes); | |
| } | | } | |
| | | | |
| class IndexIterator { | | class IndexIterator { | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 13 lines changed or added | |
|
| oplogreader.h | | oplogreader.h | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| | | | |
| void tailCheck() { | | void tailCheck() { | |
| if( cursor.get() && cursor->isDead() ) { | | if( cursor.get() && cursor->isDead() ) { | |
| log() << "repl: old cursor isDead, will initiate a new one"
<< endl; | | log() << "repl: old cursor isDead, will initiate a new one"
<< endl; | |
| resetCursor(); | | resetCursor(); | |
| } | | } | |
| } | | } | |
| | | | |
| bool haveCursor() { return cursor.get() != 0; } | | bool haveCursor() { return cursor.get() != 0; } | |
| | | | |
|
| | | void query(const char *ns, const BSONObj& query) { | |
| | | assert( !haveCursor() ); | |
| | | cursor = _conn->query(ns, query, 0, 0, 0, QueryOption_SlaveOk); | |
| | | } | |
| | | | |
| void tailingQuery(const char *ns, const BSONObj& query) { | | void tailingQuery(const char *ns, const BSONObj& query) { | |
| assert( !haveCursor() ); | | assert( !haveCursor() ); | |
| log(2) << "repl: " << ns << ".find(" << query.toString() << ')'
<< endl; | | log(2) << "repl: " << ns << ".find(" << query.toString() << ')'
<< endl; | |
| cursor = _conn->query( ns, query, 0, 0, 0, | | cursor = _conn->query( ns, query, 0, 0, 0, | |
| QueryOption_CursorTailable | QueryOption_
SlaveOk | QueryOption_OplogReplay | | | QueryOption_CursorTailable | QueryOption_
SlaveOk | QueryOption_OplogReplay | | |
|
| | | /* TODO: slaveok maybe shouldn't use? */ | |
| QueryOption_AwaitData | | QueryOption_AwaitData | |
| ); | | ); | |
| } | | } | |
| | | | |
| void tailingQueryGTE(const char *ns, OpTime t) { | | void tailingQueryGTE(const char *ns, OpTime t) { | |
| BSONObjBuilder q; | | BSONObjBuilder q; | |
| q.appendDate("$gte", t.asDate()); | | q.appendDate("$gte", t.asDate()); | |
| BSONObjBuilder query; | | BSONObjBuilder query; | |
| query.append("ts", q.done()); | | query.append("ts", q.done()); | |
| tailingQuery(ns, query.done()); | | tailingQuery(ns, query.done()); | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 6 lines changed or added | |
|
| parallel.h | | parallel.h | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 194 | |
| * runs a query in serial across any number of servers | | * runs a query in serial across any number of servers | |
| * returns all results from 1 server, then the next, etc... | | * returns all results from 1 server, then the next, etc... | |
| */ | | */ | |
| class SerialServerClusteredCursor : public ClusteredCursor { | | class SerialServerClusteredCursor : public ClusteredCursor { | |
| public: | | public: | |
| SerialServerClusteredCursor( const set<ServerAndQuery>& servers , Q
ueryMessage& q , int sortOrder=0); | | SerialServerClusteredCursor( const set<ServerAndQuery>& servers , Q
ueryMessage& q , int sortOrder=0); | |
| virtual bool more(); | | virtual bool more(); | |
| virtual BSONObj next(); | | virtual BSONObj next(); | |
| virtual string type() const { return "SerialServer"; } | | virtual string type() const { return "SerialServer"; } | |
| | | | |
|
| private: | | protected: | |
| virtual void _explain( map< string,list<BSONObj> >& out ); | | virtual void _explain( map< string,list<BSONObj> >& out ); | |
| | | | |
| void _init(){} | | void _init(){} | |
| | | | |
| vector<ServerAndQuery> _servers; | | vector<ServerAndQuery> _servers; | |
| unsigned _serverIndex; | | unsigned _serverIndex; | |
| | | | |
| FilteringClientCursor _current; | | FilteringClientCursor _current; | |
| | | | |
| int _needToSkip; | | int _needToSkip; | |
| | | | |
| skipping to change at line 221 | | skipping to change at line 221 | |
| class ParallelSortClusteredCursor : public ClusteredCursor { | | class ParallelSortClusteredCursor : public ClusteredCursor { | |
| public: | | public: | |
| ParallelSortClusteredCursor( const set<ServerAndQuery>& servers , Q
ueryMessage& q , const BSONObj& sortKey ); | | ParallelSortClusteredCursor( const set<ServerAndQuery>& servers , Q
ueryMessage& q , const BSONObj& sortKey ); | |
| ParallelSortClusteredCursor( const set<ServerAndQuery>& servers , c
onst string& ns , | | ParallelSortClusteredCursor( const set<ServerAndQuery>& servers , c
onst string& ns , | |
| const Query& q , int options=0, const
BSONObj& fields=BSONObj() ); | | const Query& q , int options=0, const
BSONObj& fields=BSONObj() ); | |
| virtual ~ParallelSortClusteredCursor(); | | virtual ~ParallelSortClusteredCursor(); | |
| virtual bool more(); | | virtual bool more(); | |
| virtual BSONObj next(); | | virtual BSONObj next(); | |
| virtual string type() const { return "ParallelSort"; } | | virtual string type() const { return "ParallelSort"; } | |
| protected: | | protected: | |
|
| | | void _finishCons(); | |
| void _init(); | | void _init(); | |
| | | | |
| virtual void _explain( map< string,list<BSONObj> >& out ); | | virtual void _explain( map< string,list<BSONObj> >& out ); | |
| | | | |
| int _numServers; | | int _numServers; | |
| set<ServerAndQuery> _servers; | | set<ServerAndQuery> _servers; | |
| BSONObj _sortKey; | | BSONObj _sortKey; | |
| | | | |
| FilteringClientCursor * _cursors; | | FilteringClientCursor * _cursors; | |
| int _needToSkip; | | int _needToSkip; | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 2 lines changed or added | |
|
| query.h | | query.h | |
| | | | |
| skipping to change at line 99 | | skipping to change at line 99 | |
| upserted.clear(); | | upserted.clear(); | |
| | | | |
| BSONElement id = upsertedObject["_id"]; | | BSONElement id = upsertedObject["_id"]; | |
| if ( ! e && n == 1 && id.type() == jstOID ){ | | if ( ! e && n == 1 && id.type() == jstOID ){ | |
| upserted = id.OID(); | | upserted = id.OID(); | |
| } | | } | |
| } | | } | |
| | | | |
| }; | | }; | |
| | | | |
|
| | | class RemoveSaver; | |
| | | | |
| /* returns true if an existing object was updated, false if no existing
object was found. | | /* returns true if an existing object was updated, false if no existing
object was found. | |
| multi - update multiple objects - mostly useful with things like $se
t | | multi - update multiple objects - mostly useful with things like $se
t | |
| god - allow access to system namespaces | | god - allow access to system namespaces | |
| */ | | */ | |
| UpdateResult updateObjects(const char *ns, const BSONObj& updateobj, BS
ONObj pattern, bool upsert, bool multi , bool logop , OpDebug& debug ); | | UpdateResult updateObjects(const char *ns, const BSONObj& updateobj, BS
ONObj pattern, bool upsert, bool multi , bool logop , OpDebug& debug ); | |
|
| UpdateResult _updateObjects(bool god, const char *ns, const BSONObj& up | | UpdateResult _updateObjects(bool god, const char *ns, const BSONObj& up | |
| dateobj, BSONObj pattern, bool upsert, bool multi , bool logop , OpDebug& d | | dateobj, BSONObj pattern, | |
| ebug ); | | bool upsert, bool multi , bool logop , OpDe | |
| | | bug& debug , RemoveSaver * rs = 0 ); | |
| | | | |
| // If justOne is true, deletedId is set to the id of the deleted object
. | | // If justOne is true, deletedId is set to the id of the deleted object
. | |
|
| long long deleteObjects(const char *ns, BSONObj pattern, bool justOne,
bool logop = false, bool god=false); | | long long deleteObjects(const char *ns, BSONObj pattern, bool justOne,
bool logop = false, bool god=false, RemoveSaver * rs=0); | |
| | | | |
| long long runCount(const char *ns, const BSONObj& cmd, string& err); | | long long runCount(const char *ns, const BSONObj& cmd, string& err); | |
| | | | |
| const char * runQuery(Message& m, QueryMessage& q, CurOp& curop, Messag
e &result); | | const char * runQuery(Message& m, QueryMessage& q, CurOp& curop, Messag
e &result); | |
| | | | |
| /* This is for languages whose "objects" are not well ordered (JSON is
well ordered). | | /* This is for languages whose "objects" are not well ordered (JSON is
well ordered). | |
| [ { a : ... } , { b : ... } ] -> { a : ..., b : ... } | | [ { a : ... } , { b : ... } ] -> { a : ..., b : ... } | |
| */ | | */ | |
| inline BSONObj transformOrderFromArrayFormat(BSONObj order) { | | inline BSONObj transformOrderFromArrayFormat(BSONObj order) { | |
| /* note: this is slow, but that is ok as order will have very few p
ieces */ | | /* note: this is slow, but that is ok as order will have very few p
ieces */ | |
| | | | |
End of changes. 3 change blocks. |
| 4 lines changed or deleted | | 7 lines changed or added | |
|
| queryoptimizer.h | | queryoptimizer.h | |
| | | | |
| skipping to change at line 114 | | skipping to change at line 114 | |
| _matcher.reset( _oldMatcher->nextClauseMatcher( qp().indexK
ey() ) ); | | _matcher.reset( _oldMatcher->nextClauseMatcher( qp().indexK
ey() ) ); | |
| } else { | | } else { | |
| _matcher.reset( new CoveredIndexMatcher( qp().originalQuery
(), qp().indexKey(), alwaysUseRecord() ) ); | | _matcher.reset( new CoveredIndexMatcher( qp().originalQuery
(), qp().indexKey(), alwaysUseRecord() ) ); | |
| } | | } | |
| _init(); | | _init(); | |
| } | | } | |
| virtual void next() = 0; | | virtual void next() = 0; | |
| | | | |
| virtual bool mayRecordPlan() const = 0; | | virtual bool mayRecordPlan() const = 0; | |
| | | | |
|
| virtual void prepareToYield() { massert( 13335, "yield not supporte
d", false ); } | | virtual bool prepareToYield() { massert( 13335, "yield not supporte
d", false ); return false; } | |
| virtual void recoverFromYield() { massert( 13336, "yield not suppor
ted", false ); } | | virtual void recoverFromYield() { massert( 13336, "yield not suppor
ted", false ); } | |
| | | | |
| /** @return a copy of the inheriting class, which will be run with
its own | | /** @return a copy of the inheriting class, which will be run with
its own | |
| query plan. If multiple plan sets are required for an
$or query, | | query plan. If multiple plan sets are required for an
$or query, | |
| the QueryOp of the winning plan from a given set will b
e cloned | | the QueryOp of the winning plan from a given set will b
e cloned | |
| to generate QueryOps for the subsequent plan set. This
function | | to generate QueryOps for the subsequent plan set. This
function | |
| should only be called after the query op has completed
executing. | | should only be called after the query op has completed
executing. | |
| */ | | */ | |
| QueryOp *createChild() { | | QueryOp *createChild() { | |
| if( _orConstraint.get() ) { | | if( _orConstraint.get() ) { | |
| | | | |
| skipping to change at line 214 | | skipping to change at line 214 | |
| void init(); | | void init(); | |
| void addHint( IndexDetails &id ); | | void addHint( IndexDetails &id ); | |
| struct Runner { | | struct Runner { | |
| Runner( QueryPlanSet &plans, QueryOp &op ); | | Runner( QueryPlanSet &plans, QueryOp &op ); | |
| shared_ptr< QueryOp > run(); | | shared_ptr< QueryOp > run(); | |
| void mayYield( const vector< shared_ptr< QueryOp > > &ops ); | | void mayYield( const vector< shared_ptr< QueryOp > > &ops ); | |
| QueryOp &op_; | | QueryOp &op_; | |
| QueryPlanSet &plans_; | | QueryPlanSet &plans_; | |
| static void initOp( QueryOp &op ); | | static void initOp( QueryOp &op ); | |
| static void nextOp( QueryOp &op ); | | static void nextOp( QueryOp &op ); | |
|
| static void prepareToYield( QueryOp &op ); | | static bool prepareToYield( QueryOp &op ); | |
| static void recoverFromYield( QueryOp &op ); | | static void recoverFromYield( QueryOp &op ); | |
| }; | | }; | |
| const char *ns; | | const char *ns; | |
| BSONObj _originalQuery; | | BSONObj _originalQuery; | |
| auto_ptr< FieldRangeSet > fbs_; | | auto_ptr< FieldRangeSet > fbs_; | |
| PlanSet plans_; | | PlanSet plans_; | |
| bool mayRecordPlan_; | | bool mayRecordPlan_; | |
| bool usingPrerecordedPlan_; | | bool usingPrerecordedPlan_; | |
| BSONObj hint_; | | BSONObj hint_; | |
| BSONObj order_; | | BSONObj order_; | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| replpair.h | | replpair.h | |
| | | | |
| skipping to change at line 58 | | skipping to change at line 58 | |
| State_Slave = 0, | | State_Slave = 0, | |
| State_Master = 1 | | State_Master = 1 | |
| }; | | }; | |
| | | | |
| int state; | | int state; | |
| ThreadSafeString info; // commentary about our current state | | ThreadSafeString info; // commentary about our current state | |
| string arbHost; // "-" for no arbiter. "host[:port]" | | string arbHost; // "-" for no arbiter. "host[:port]" | |
| int remotePort; | | int remotePort; | |
| string remoteHost; | | string remoteHost; | |
| string remote; // host:port if port specified. | | string remote; // host:port if port specified. | |
|
| // int date; // -1 not yet set; 0=slave; 1=master | | // int date; // -1 not yet set; 0=slave; 1=master | |
| | | | |
| string getInfo() { | | string getInfo() { | |
| stringstream ss; | | stringstream ss; | |
| ss << " state: "; | | ss << " state: "; | |
| if ( state == 1 ) ss << "1 State_Master "; | | if ( state == 1 ) ss << "1 State_Master "; | |
| else if ( state == 0 ) ss << "0 State_Slave"; | | else if ( state == 0 ) ss << "0 State_Slave"; | |
| else | | else | |
| ss << "<b>" << state << "</b>"; | | ss << "<b>" << state << "</b>"; | |
| ss << '\n'; | | ss << '\n'; | |
| ss << " info: " << info << '\n'; | | ss << " info: " << info << '\n'; | |
| | | | |
| skipping to change at line 114 | | skipping to change at line 114 | |
| | | | |
| /* note we always return true for the "local" namespace. | | /* note we always return true for the "local" namespace. | |
| | | | |
| we should not allow most operations when not the master | | we should not allow most operations when not the master | |
| also we report not master if we are "dead". | | also we report not master if we are "dead". | |
| | | | |
| See also CmdIsMaster. | | See also CmdIsMaster. | |
| | | | |
| If 'client' is not specified, the current client is used. | | If 'client' is not specified, the current client is used. | |
| */ | | */ | |
|
| inline bool _isMaster( const char *client = 0 ) { | | inline bool _isMaster() { | |
| if( replSet ) { | | if( replSet ) { | |
| if( theReplSet ) | | if( theReplSet ) | |
|
| return theReplSet->isMaster(client); | | return theReplSet->isPrimary(); | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| if( ! replSettings.slave ) | | if( ! replSettings.slave ) | |
| return true; | | return true; | |
| | | | |
| if ( replAllDead ) | | if ( replAllDead ) | |
| return false; | | return false; | |
| | | | |
| if ( replPair ) { | | if ( replPair ) { | |
| | | | |
| skipping to change at line 145 | | skipping to change at line 145 | |
| return true; | | return true; | |
| } | | } | |
| } | | } | |
| | | | |
| if ( cc().isGod() ) | | if ( cc().isGod() ) | |
| return true; | | return true; | |
| | | | |
| return false; | | return false; | |
| } | | } | |
| inline bool isMaster(const char *client = 0) { | | inline bool isMaster(const char *client = 0) { | |
|
| if( _isMaster(client) ) | | if( _isMaster() ) | |
| return true; | | return true; | |
| if ( !client ) { | | if ( !client ) { | |
| Database *database = cc().database(); | | Database *database = cc().database(); | |
| assert( database ); | | assert( database ); | |
| client = database->name.c_str(); | | client = database->name.c_str(); | |
| } | | } | |
| return strcmp( client, "local" ) == 0; | | return strcmp( client, "local" ) == 0; | |
| } | | } | |
| | | | |
| inline void notMasterUnless(bool expr) { | | inline void notMasterUnless(bool expr) { | |
| uassert( 10107 , "not master" , expr ); | | uassert( 10107 , "not master" , expr ); | |
| } | | } | |
| | | | |
| /* we allow queries to SimpleSlave's -- but not to the slave (nonmaster
) member of a replica pair | | /* we allow queries to SimpleSlave's -- but not to the slave (nonmaster
) member of a replica pair | |
| so that queries to a pair are realtime consistent as much as possibl
e. use setSlaveOk() to | | so that queries to a pair are realtime consistent as much as possibl
e. use setSlaveOk() to | |
| query the nonmaster member of a replica pair. | | query the nonmaster member of a replica pair. | |
| */ | | */ | |
| inline void replVerifyReadsOk(ParsedQuery& pq) { | | inline void replVerifyReadsOk(ParsedQuery& pq) { | |
|
| if( replSet ) | | if( replSet ) { | |
| notMasterUnless(isMaster() || pq.hasOption(QueryOption_SlaveOk) | | /* todo: speed up the secondary case. as written here there ar | |
| ); | | e 2 mutex entries, it can be 1. */ | |
| else | | if( isMaster() ) return; | |
| | | notMasterUnless( pq.hasOption(QueryOption_SlaveOk) && theReplSe | |
| | | t->isSecondary() ); | |
| | | } else { | |
| notMasterUnless(isMaster() || pq.hasOption(QueryOption_SlaveOk)
|| replSettings.slave == SimpleSlave ); | | notMasterUnless(isMaster() || pq.hasOption(QueryOption_SlaveOk)
|| replSettings.slave == SimpleSlave ); | |
|
| | | } | |
| } | | } | |
| | | | |
| inline bool isMasterNs( const char *ns ) { | | inline bool isMasterNs( const char *ns ) { | |
| char cl[ 256 ]; | | char cl[ 256 ]; | |
| nsToDatabase( ns, cl ); | | nsToDatabase( ns, cl ); | |
| return isMaster( cl ); | | return isMaster( cl ); | |
| } | | } | |
| | | | |
| inline ReplPair::ReplPair(const char *remoteEnd, const char *arb) { | | inline ReplPair::ReplPair(const char *remoteEnd, const char *arb) { | |
| state = -1; | | state = -1; | |
| | | | |
End of changes. 6 change blocks. |
| 8 lines changed or deleted | | 12 lines changed or added | |
|
| rs.h | | rs.h | |
| | | | |
| skipping to change at line 55 | | skipping to change at line 55 | |
| Member(HostAndPort h, unsigned ord, const ReplSetConfig::MemberCfg
*c, bool self); | | Member(HostAndPort h, unsigned ord, const ReplSetConfig::MemberCfg
*c, bool self); | |
| string fullName() const { return h().toString(); } | | string fullName() const { return h().toString(); } | |
| const ReplSetConfig::MemberCfg& config() const { return *_config; } | | const ReplSetConfig::MemberCfg& config() const { return *_config; } | |
| const HeartbeatInfo& hbinfo() const { return _hbinfo; } | | const HeartbeatInfo& hbinfo() const { return _hbinfo; } | |
| string lhb() { return _hbinfo.lastHeartbeatMsg; } | | string lhb() { return _hbinfo.lastHeartbeatMsg; } | |
| MemberState state() const { return _hbinfo.hbstate; } | | MemberState state() const { return _hbinfo.hbstate; } | |
| const HostAndPort& h() const { return _h; } | | const HostAndPort& h() const { return _h; } | |
| unsigned id() const { return _hbinfo.id(); } | | unsigned id() const { return _hbinfo.id(); } | |
| bool potentiallyHot() const { return _config->potentiallyHot(); } /
/ not arbiter, not priority 0 | | bool potentiallyHot() const { return _config->potentiallyHot(); } /
/ not arbiter, not priority 0 | |
| | | | |
|
| void summarizeAsHtml(stringstream& s) const; | | void summarizeMember(stringstream& s) const; | |
| friend class ReplSetImpl; | | friend class ReplSetImpl; | |
| private: | | private: | |
| const ReplSetConfig::MemberCfg *_config; /* todo: when this changes
??? */ | | const ReplSetConfig::MemberCfg *_config; /* todo: when this changes
??? */ | |
| HostAndPort _h; | | HostAndPort _h; | |
| HeartbeatInfo _hbinfo; | | HeartbeatInfo _hbinfo; | |
| }; | | }; | |
| | | | |
| class Manager : public task::Server { | | class Manager : public task::Server { | |
| ReplSetImpl *rs; | | ReplSetImpl *rs; | |
| bool busyWithElectSelf; | | bool busyWithElectSelf; | |
| | | | |
| skipping to change at line 261 | | skipping to change at line 261 | |
| protected: | | protected: | |
| bool _stepDown(); | | bool _stepDown(); | |
| private: | | private: | |
| void assumePrimary(); | | void assumePrimary(); | |
| void loadLastOpTimeWritten(); | | void loadLastOpTimeWritten(); | |
| void changeState(MemberState s); | | void changeState(MemberState s); | |
| | | | |
| 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 unocked, thus not a c++ string | | char _hbmsg[256]; // we change this unlocked, thus not an stl::stri
ng | |
| public: | | public: | |
|
| void sethbmsg(string s, int logLevel = 0) { | | void sethbmsg(string s, int logLevel = 0); | |
| unsigned sz = s.size(); | | | |
| if( sz >= 256 ) | | | |
| memcpy(_hbmsg, s.c_str(), 255); | | | |
| else { | | | |
| _hbmsg[sz] = 0; | | | |
| memcpy(_hbmsg, s.c_str(), sz); | | | |
| } | | | |
| if( !s.empty() ) | | | |
| log(logLevel) << "replSet " << s << rsLog; | | | |
| } | | | |
| protected: | | protected: | |
| bool initFromConfig(ReplSetConfig& c); // true if ok; throws if con
fig really bad; false if config doesn't include self | | bool initFromConfig(ReplSetConfig& c); // true if ok; throws if con
fig really bad; false if config doesn't include self | |
| void _fillIsMaster(BSONObjBuilder&); | | void _fillIsMaster(BSONObjBuilder&); | |
| void _fillIsMasterHost(const Member*, vector<string>&, vector<strin
g>&, vector<string>&); | | void _fillIsMasterHost(const Member*, vector<string>&, vector<strin
g>&, vector<string>&); | |
| const ReplSetConfig& config() { return *_cfg; } | | const ReplSetConfig& config() { return *_cfg; } | |
| string name() const { return _name; } /* @return replica set's logi
cal name */ | | string name() const { return _name; } /* @return replica set's logi
cal name */ | |
| MemberState state() const { return box.getState(); } | | MemberState state() const { return box.getState(); } | |
| void _fatal(); | | void _fatal(); | |
| void _getOplogDiagsAsHtml(unsigned server_id, stringstream& ss) con
st; | | void _getOplogDiagsAsHtml(unsigned server_id, stringstream& ss) con
st; | |
| void _summarizeAsHtml(stringstream&) const; | | void _summarizeAsHtml(stringstream&) const; | |
| | | | |
| skipping to change at line 330 | | skipping to change at line 320 | |
| void getTargets(list<Target>&, int &configVersion); | | void getTargets(list<Target>&, int &configVersion); | |
| void startThreads(); | | void startThreads(); | |
| friend class FeedbackThread; | | friend class FeedbackThread; | |
| friend class CmdReplSetElect; | | friend class CmdReplSetElect; | |
| friend class Member; | | friend class Member; | |
| friend class Manager; | | friend class Manager; | |
| friend class Consensus; | | friend class Consensus; | |
| | | | |
| private: | | private: | |
| /* pulling data from primary related - see rs_sync.cpp */ | | /* pulling data from primary related - see rs_sync.cpp */ | |
|
| | | bool initialSyncOplogApplication(string hn, const Member *primary,
OpTime applyGTE, OpTime minValid); | |
| void _syncDoInitialSync(); | | void _syncDoInitialSync(); | |
| void syncDoInitialSync(); | | void syncDoInitialSync(); | |
| void _syncThread(); | | void _syncThread(); | |
| void syncTail(); | | void syncTail(); | |
| void syncApply(const BSONObj &o); | | void syncApply(const BSONObj &o); | |
| void syncRollback(OplogReader& r); | | void syncRollback(OplogReader& r); | |
| void syncFixUp(HowToFixUp& h, OplogReader& r); | | void syncFixUp(HowToFixUp& h, OplogReader& r); | |
| public: | | public: | |
| void syncThread(); | | void syncThread(); | |
| }; | | }; | |
| | | | |
| skipping to change at line 355 | | skipping to change at line 346 | |
| bool stepDown() { return _stepDown(); } | | bool stepDown() { return _stepDown(); } | |
| | | | |
| string selfFullName() { | | string selfFullName() { | |
| lock lk(this); | | lock lk(this); | |
| return _self->fullName(); | | return _self->fullName(); | |
| } | | } | |
| | | | |
| /* call after constructing to start - returns fairly quickly after
la[unching its threads */ | | /* call after constructing to start - returns fairly quickly after
la[unching its threads */ | |
| void go() { _go(); } | | void go() { _go(); } | |
| void fatal() { _fatal(); } | | void fatal() { _fatal(); } | |
|
| bool isMaster(const char *client); | | bool isPrimary(); | |
| | | bool isSecondary(); | |
| MemberState state() const { return ReplSetImpl::state(); } | | MemberState state() const { return ReplSetImpl::state(); } | |
| string name() const { return ReplSetImpl::name(); } | | string name() const { return ReplSetImpl::name(); } | |
| const ReplSetConfig& config() { return ReplSetImpl::config(); } | | const ReplSetConfig& config() { return ReplSetImpl::config(); } | |
| void getOplogDiagsAsHtml(unsigned server_id, stringstream& ss) cons
t { _getOplogDiagsAsHtml(server_id,ss); } | | void getOplogDiagsAsHtml(unsigned server_id, stringstream& ss) cons
t { _getOplogDiagsAsHtml(server_id,ss); } | |
| void summarizeAsHtml(stringstream& ss) const { _summarizeAsHtml(ss)
; } | | void summarizeAsHtml(stringstream& ss) const { _summarizeAsHtml(ss)
; } | |
| void summarizeStatus(BSONObjBuilder& b) const { _summarizeStatus(b
); } | | void summarizeStatus(BSONObjBuilder& b) const { _summarizeStatus(b
); } | |
| void fillIsMaster(BSONObjBuilder& b) { _fillIsMaster(b); } | | void fillIsMaster(BSONObjBuilder& b) { _fillIsMaster(b); } | |
| | | | |
| /* we have a new config (reconfig) - apply it. | | /* we have a new config (reconfig) - apply it. | |
| @param comment write a no-op comment to the oplog about it. onl
y makes sense if one is primary and initiating the reconf. | | @param comment write a no-op comment to the oplog about it. onl
y makes sense if one is primary and initiating the reconf. | |
| | | | |
| skipping to change at line 383 | | skipping to change at line 375 | |
| | | | |
| // heartbeat msg to send to others; descriptive diagnostic info | | // heartbeat msg to send to others; descriptive diagnostic info | |
| string hbmsg() const { return _hbmsg; } | | string hbmsg() const { return _hbmsg; } | |
| }; | | }; | |
| | | | |
| /** base class for repl set commands. checks basic things such as in r
s mode before the command | | /** base class for repl set commands. checks basic things such as in r
s mode before the command | |
| does its real work | | does its real work | |
| */ | | */ | |
| class ReplSetCommand : public Command { | | class ReplSetCommand : public Command { | |
| protected: | | protected: | |
|
| ReplSetCommand(const char * s, bool show=false) : Command(s) { } | | ReplSetCommand(const char * s, bool show=false) : Command(s, show)
{ } | |
| virtual bool slaveOk() const { return true; } | | virtual bool slaveOk() const { return true; } | |
| virtual bool adminOnly() const { return true; } | | virtual bool adminOnly() const { return true; } | |
| 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";
} | |
| bool check(string& errmsg, BSONObjBuilder& result) { | | bool check(string& errmsg, BSONObjBuilder& result) { | |
| if( !replSet ) { | | if( !replSet ) { | |
| errmsg = "not running with --replSet"; | | errmsg = "not running with --replSet"; | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| skipping to change at line 412 | | skipping to change at line 404 | |
| | | | |
| /** inlines ----------------- */ | | /** inlines ----------------- */ | |
| | | | |
| inline Member::Member(HostAndPort h, unsigned ord, const ReplSetConfig:
:MemberCfg *c, bool self) : | | inline Member::Member(HostAndPort h, unsigned ord, const ReplSetConfig:
:MemberCfg *c, bool self) : | |
| _config(c), _h(h), _hbinfo(ord) { | | _config(c), _h(h), _hbinfo(ord) { | |
| if( self ) { | | if( self ) { | |
| _hbinfo.health = 1.0; | | _hbinfo.health = 1.0; | |
| } | | } | |
| } | | } | |
| | | | |
|
| inline bool ReplSet::isMaster(const char *client) { | | inline bool ReplSet::isPrimary() { | |
| /* todo replset */ | | /* todo replset */ | |
| return box.getState().primary(); | | return box.getState().primary(); | |
| } | | } | |
| | | | |
|
| | | inline bool ReplSet::isSecondary() { | |
| | | return box.getState().secondary(); | |
| | | } | |
| | | | |
| } | | } | |
| | | | |
End of changes. 8 change blocks. |
| 16 lines changed or deleted | | 12 lines changed or added | |
|