diff options
author | dwight <dwight@10gen.com> | 2010-07-18 13:34:16 -0400 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2010-07-18 13:34:16 -0400 |
commit | 46542f495c58da5e87b44c0d736b5cb88619fd8e (patch) | |
tree | 6cdc2f61107069633f50c38767d5a568eb6ef24f /db | |
parent | 7fc85d6c80db5edd5c84d4a265c48499f291c237 (diff) | |
download | mongo-46542f495c58da5e87b44c0d736b5cb88619fd8e.tar.gz |
cleaning
Diffstat (limited to 'db')
-rw-r--r-- | db/db.vcxproj | 1 | ||||
-rwxr-xr-x | db/db.vcxproj.filters | 3 | ||||
-rw-r--r-- | db/dbmessage.h | 19 | ||||
-rw-r--r-- | db/instance.cpp | 2 | ||||
-rw-r--r-- | db/query.cpp | 4 | ||||
-rw-r--r-- | db/repl.h | 66 | ||||
-rw-r--r-- | db/repl/rs_initialsync.cpp | 4 |
7 files changed, 13 insertions, 86 deletions
diff --git a/db/db.vcxproj b/db/db.vcxproj index d729c3814fd..a193c011ca4 100644 --- a/db/db.vcxproj +++ b/db/db.vcxproj @@ -599,6 +599,7 @@ <ClInclude Include="geo\core.h" />
<ClInclude Include="helpers\dblogger.h" />
<ClInclude Include="instance.h" />
+ <ClInclude Include="oplogreader.h" />
<ClInclude Include="repl.h" />
<ClInclude Include="replpair.h" />
<ClInclude Include="rec.h" />
diff --git a/db/db.vcxproj.filters b/db/db.vcxproj.filters index bb102cad6d2..4962c515c43 100755 --- a/db/db.vcxproj.filters +++ b/db/db.vcxproj.filters @@ -759,6 +759,9 @@ <ClInclude Include="..\s\d_logic.h">
<Filter>sharding</Filter>
</ClInclude>
+ <ClInclude Include="oplogreader.h">
+ <Filter>repl_old</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="libs">
diff --git a/db/dbmessage.h b/db/dbmessage.h index f46736c6a89..f6738765718 100644 --- a/db/dbmessage.h +++ b/db/dbmessage.h @@ -20,6 +20,7 @@ #include "jsobj.h" #include "namespace.h" #include "../util/message.h" +#include "../client/constants.h" namespace mongo { @@ -37,24 +38,6 @@ namespace mongo { #pragma pack(1) struct QueryResult : public MsgData { - enum ResultFlagType { - /* returned, with zero results, when getMore is called but the cursor id - is not valid at the server. */ - ResultFlag_CursorNotFound = 1, - - /* { $err : ... } is being returned */ - ResultFlag_ErrSet = 2, - - /* Have to update config from the server, usually $err is also set */ - ResultFlag_ShardConfigStale = 4, - - /* for backward compatability: this let's us know the server supports - the QueryOption_AwaitData option. if it doesn't, a repl slave client should sleep - a little between getMore's. - */ - ResultFlag_AwaitCapable = 8 - }; - long long cursorId; int startingFrom; int nReturned; diff --git a/db/instance.cpp b/db/instance.cpp index 7b0a5113a77..eb05c9c6eb6 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -198,7 +198,7 @@ namespace mongo { QueryResult * msgdata = (QueryResult *) b.buf(); b.decouple(); QueryResult *qr = msgdata; - qr->_resultFlags() = QueryResult::ResultFlag_ErrSet; + qr->_resultFlags() = ResultFlag_ErrSet; qr->len = b.len(); qr->setOperation(opReply); qr->cursorId = 0; diff --git a/db/query.cpp b/db/query.cpp index 4ffa629f6f8..cacb0376fd4 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -285,14 +285,14 @@ namespace mongo { b.skip(sizeof(QueryResult)); - int resultFlags = QueryResult::ResultFlag_AwaitCapable; + int resultFlags = ResultFlag_AwaitCapable; int start = 0; int n = 0; if ( !cc ) { log() << "getMore: cursorid not found " << ns << " " << cursorid << endl; cursorid = 0; - resultFlags = QueryResult::ResultFlag_CursorNotFound; + resultFlags = ResultFlag_CursorNotFound; } else { if ( pass == 0 ) diff --git a/db/repl.h b/db/repl.h index 01c3860ffed..f33acad4350 100644 --- a/db/repl.h +++ b/db/repl.h @@ -36,6 +36,7 @@ #include "../util/optime.h" #include "oplog.h" #include "../util/concurrency/thread_pool.h" +#include "oplogreader.h" namespace mongo { @@ -78,71 +79,6 @@ namespace mongo { SyncException() : DBException( "sync exception" , 10001 ){} }; - /* started abstracting out the querying of the primary/master's oplog - still fairly awkward but a start. - */ - class OplogReader { - auto_ptr<DBClientConnection> _conn; - auto_ptr<DBClientCursor> cursor; - public: - - void reset() { - cursor.reset(); - } - void resetConnection() { - cursor.reset(); - _conn.reset(); - } - DBClientConnection* conn() { return _conn.get(); } - BSONObj findOne(const char *ns, Query& q) { - return conn()->findOne(ns, q); - } - - /* ok to call if already connected */ - bool connect(string hostname); - - void getReady() { - if( cursor.get() && cursor->isDead() ) { - log() << "repl: old cursor isDead, initiating a new one" << endl; - reset(); - } - } - - bool haveCursor() { return cursor.get() != 0; } - - void tailingQuery(const char *ns, BSONObj& query) { - assert( !haveCursor() ); - log(2) << "repl: " << ns << ".find(" << query.toString() << ')' << endl; - cursor = _conn->query( ns, query, 0, 0, 0, - QueryOption_CursorTailable | QueryOption_SlaveOk | QueryOption_OplogReplay | - QueryOption_AwaitData - ); - } - - bool more() { - assert( cursor.get() ); - return cursor->more(); - } - - /* old mongod's can't do the await flag... */ - bool awaitCapable() { - return cursor->hasResultFlag(QueryResult::ResultFlag_AwaitCapable); - } - - void peek(vector<BSONObj>& v, int n) { - if( cursor.get() ) - cursor->peek(v,n); - } - - BSONObj next() { - return cursor->next(); - } - - void putBack(BSONObj op) { - cursor->putBack(op); - } - }; - /* A Source is a source from which we can pull (replicate) data. stored in collection local.sources. diff --git a/db/repl/rs_initialsync.cpp b/db/repl/rs_initialsync.cpp index c9ca269bccd..456202f9d77 100644 --- a/db/repl/rs_initialsync.cpp +++ b/db/repl/rs_initialsync.cpp @@ -18,6 +18,7 @@ #include "../client.h" #include "../../client/dbclient.h" #include "rs.h" +#include "../oplogreader.h" namespace mongo { @@ -25,6 +26,9 @@ namespace mongo { void ReplSetImpl::syncDoInitialSync() { log() << "replSet syncDoInitialSync" << rsLog; + + OplogReader r; + sethbmsg("initial sync drop all databases"); dropAllDatabasesExceptLocal(); sethbmsg("initial sync - not yet implemented"); |