diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2014-05-19 13:28:28 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2014-05-22 12:18:42 -0400 |
commit | 3cb9955b05bdef78cb8f72f63e657d920c0fa0bb (patch) | |
tree | 7768ef10ba9b219e22a04905ffa090d56ed1592d /src/mongo/db/repl | |
parent | 0d088b82f1490aa7053fdf2748a55162b30970c4 (diff) | |
download | mongo-3cb9955b05bdef78cb8f72f63e657d920c0fa0bb.tar.gz |
SERVER-14021 move all replication code into namespace replset
Diffstat (limited to 'src/mongo/db/repl')
55 files changed, 175 insertions, 72 deletions
diff --git a/src/mongo/db/repl/connections.h b/src/mongo/db/repl/connections.h index a32c77ed924..ec5eca84816 100644 --- a/src/mongo/db/repl/connections.h +++ b/src/mongo/db/repl/connections.h @@ -39,6 +39,7 @@ #include "mongo/db/repl/rs_config.h" namespace mongo { +namespace replset { /** here we keep a single connection (with reconnect) for a set of hosts, one each, and allow one user at a time per host. if in use already for that @@ -176,4 +177,5 @@ namespace mongo { // Keep trying to connect if we're not yet connected connect(); } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/consensus.cpp b/src/mongo/db/repl/consensus.cpp index 86bcc17f9df..d6c5ae1883d 100644 --- a/src/mongo/db/repl/consensus.cpp +++ b/src/mongo/db/repl/consensus.cpp @@ -33,6 +33,7 @@ #include "mongo/db/repl/replset_commands.h" namespace mongo { +namespace replset { /** the first cmd called by a node seeking election and it's a basic sanity test: do any of the nodes it can reach know that it can't be the primary? @@ -357,7 +358,7 @@ namespace mongo { void Consensus::_multiCommand(BSONObj cmd, list<Target>& L) { verify( !rs.lockedByMe() ); - mongo::multiCommand(cmd, L); + multiCommand(cmd, L); } void Consensus::_electSelf() { @@ -487,4 +488,5 @@ namespace mongo { } } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/consensus.h b/src/mongo/db/repl/consensus.h index becdabd64e1..87ce96c8bb3 100644 --- a/src/mongo/db/repl/consensus.h +++ b/src/mongo/db/repl/consensus.h @@ -37,6 +37,7 @@ #include "mongo/bson/bsonobj.h" namespace mongo { +namespace replset { class ReplSetImpl; struct Target; @@ -86,4 +87,5 @@ namespace mongo { OpTime getElectionTime() const { return _electionTime; } void setElectionTime(OpTime electionTime) { _electionTime = electionTime; } }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/health.cpp b/src/mongo/db/repl/health.cpp index 62c573a9428..420200c9a25 100644 --- a/src/mongo/db/repl/health.cpp +++ b/src/mongo/db/repl/health.cpp @@ -47,12 +47,10 @@ #include "mongo/util/ramlog.h" namespace mongo { +namespace replset { /* decls for connections.h */ ScopedConn::M& ScopedConn::_map = *(new ScopedConn::M()); mutex ScopedConn::mapMutex("ScopedConn::mapMutex"); -} - -namespace mongo { using namespace mongoutils::html; using namespace bson; @@ -468,4 +466,5 @@ namespace mongo { if( replSetBlind ) b.append("blind",true); // to avoid confusion if set...normally never set except for testing. } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/health.h b/src/mongo/db/repl/health.h index 1159764f45e..64f48a8de21 100644 --- a/src/mongo/db/repl/health.h +++ b/src/mongo/db/repl/health.h @@ -34,10 +34,14 @@ #include "mongo/logger/tee.h" namespace mongo { +namespace replset { + + void fillRsLog(std::stringstream&); // ramlog used for replSet actions extern logger::Tee* rsLog; // helper function needed by member.cpp std::string ago(time_t t); -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/heartbeat.cpp b/src/mongo/db/repl/heartbeat.cpp index 3606b26a22a..245ca56806d 100644 --- a/src/mongo/db/repl/heartbeat.cpp +++ b/src/mongo/db/repl/heartbeat.cpp @@ -48,6 +48,7 @@ #include "mongo/util/ramlog.h" namespace mongo { +namespace replset { using namespace bson; @@ -257,7 +258,8 @@ namespace mongo { // member heartbeats are started in ReplSetImpl::initFromConfig } -} +} // namespace replset +} // namespace mongo /* todo: stop bg job and delete on removefromset diff --git a/src/mongo/db/repl/heartbeat.h b/src/mongo/db/repl/heartbeat.h index 3c16feb213d..fc8544863d4 100644 --- a/src/mongo/db/repl/heartbeat.h +++ b/src/mongo/db/repl/heartbeat.h @@ -31,9 +31,10 @@ #include <string> namespace mongo { - class BSONObj; +namespace replset { + /* throws */ bool requestHeartbeat(const std::string& setname, const std::string& fromHost, @@ -42,4 +43,5 @@ namespace mongo { int myConfigVersion, int& theirConfigVersion, bool checkEmpty = false); -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/heartbeat_info.cpp b/src/mongo/db/repl/heartbeat_info.cpp index e6bd6b92fb9..083cf31b969 100644 --- a/src/mongo/db/repl/heartbeat_info.cpp +++ b/src/mongo/db/repl/heartbeat_info.cpp @@ -33,6 +33,7 @@ #include "mongo/util/fail_point_service.h" namespace mongo { +namespace replset { unsigned int HeartbeatInfo::numPings; @@ -84,4 +85,5 @@ namespace mongo { } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/heartbeat_info.h b/src/mongo/db/repl/heartbeat_info.h index 951a2a269d6..1718098dcbb 100644 --- a/src/mongo/db/repl/heartbeat_info.h +++ b/src/mongo/db/repl/heartbeat_info.h @@ -35,6 +35,7 @@ #include "mongo/util/concurrency/value.h" namespace mongo { +namespace replset { /* this is supposed to be just basic information on a member, and copy constructable. */ @@ -81,4 +82,5 @@ namespace mongo { unsigned _id; }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/initial_sync.cpp b/src/mongo/db/repl/initial_sync.cpp index 7f99106f25a..39d38eb431d 100644 --- a/src/mongo/db/repl/initial_sync.cpp +++ b/src/mongo/db/repl/initial_sync.cpp @@ -31,11 +31,10 @@ #include "mongo/db/repl/initial_sync.h" #include "mongo/db/repl/oplog.h" +#include "mongo/db/repl/replset_commands.h" #include "mongo/db/repl/rs.h" namespace mongo { - extern unsigned replSetForceInitialSyncFailure; - namespace replset { InitialSync::InitialSync(BackgroundSyncInterface *q) : SyncTail(q) {} diff --git a/src/mongo/db/repl/is_master.h b/src/mongo/db/repl/is_master.h index dc52d5b092b..26c32a5d15e 100644 --- a/src/mongo/db/repl/is_master.h +++ b/src/mongo/db/repl/is_master.h @@ -36,6 +36,7 @@ #include "mongo/util/mongoutils/str.h" namespace mongo { +namespace replset { /* We should not allow most operations when not the master also we report not master if we are "dead". @@ -76,4 +77,5 @@ namespace mongo { return ns[5] == 0 || ns[5] == '.'; } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/manager.cpp b/src/mongo/db/repl/manager.cpp index c84d0c803e7..91b0f0eb15e 100644 --- a/src/mongo/db/repl/manager.cpp +++ b/src/mongo/db/repl/manager.cpp @@ -36,6 +36,7 @@ #include "mongo/db/client.h" namespace mongo { +namespace replset { /* check members OTHER THAN US to see if they think they are primary */ const Member * Manager::findOtherPrimary(bool& two) { @@ -288,4 +289,5 @@ namespace mongo { busyWithElectSelf = false; } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/manager.h b/src/mongo/db/repl/manager.h index 0aae7357c5c..02b0c7ab7c7 100644 --- a/src/mongo/db/repl/manager.h +++ b/src/mongo/db/repl/manager.h @@ -32,6 +32,7 @@ #include "mongo/db/repl/server.h" namespace mongo { +namespace replset { class Member; class ReplSetImpl; @@ -56,4 +57,5 @@ namespace mongo { void msgCheckNewState(); }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index 4326a1d146c..30723f48a62 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -58,6 +58,7 @@ #include "mongo/util/exit.h" namespace mongo { +namespace replset { void pretouchOperation(const BSONObj& op); void pretouchN(vector<BSONObj>&, unsigned a, unsigned b); @@ -1308,5 +1309,5 @@ namespace mongo { } } +} // namespace replset } // namespace mongo - diff --git a/src/mongo/db/repl/master_slave.h b/src/mongo/db/repl/master_slave.h index 740a767cc4e..37adf66963a 100644 --- a/src/mongo/db/repl/master_slave.h +++ b/src/mongo/db/repl/master_slave.h @@ -40,10 +40,15 @@ */ namespace mongo { + namespace threadpool { + class ThreadPool; + } class Database; class OperationContext; +namespace replset { + // Main entry point for master/slave at startup time. void startMasterSlave(); @@ -54,16 +59,14 @@ namespace mongo { // Global variable that contains a std::string telling why master/slave halted extern const char *replAllDead; + extern const char *replInfo; + /* A replication exception */ class SyncException : public DBException { public: SyncException() : DBException( "sync exception" , 10001 ) {} }; - namespace threadpool { - class ThreadPool; - } - /* A Source is a source from which we can pull (replicate) data. stored in collection local.sources. @@ -182,4 +185,5 @@ namespace mongo { std::map< std::string, OpTime > _ignores; }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/member.cpp b/src/mongo/db/repl/member.cpp index 1b46e96cb56..5d4e6585caa 100644 --- a/src/mongo/db/repl/member.cpp +++ b/src/mongo/db/repl/member.cpp @@ -33,6 +33,7 @@ namespace mongo { +namespace replset { using namespace mongoutils::html; @@ -87,4 +88,5 @@ namespace mongo { return hbinfo().up() && (config().buildIndexes || !buildIndexes) && state().readable(); } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/member.h b/src/mongo/db/repl/member.h index 5364672f1ee..d05c9fa4d2c 100644 --- a/src/mongo/db/repl/member.h +++ b/src/mongo/db/repl/member.h @@ -33,6 +33,7 @@ #include "mongo/util/concurrency/list.h" namespace mongo { +namespace replset { /* member of a replica set */ class Member : public List1<Member>::Base { @@ -74,4 +75,5 @@ namespace mongo { HeartbeatInfo _hbinfo; }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/member_state.h b/src/mongo/db/repl/member_state.h index d9c1801dd59..985d5592fa6 100644 --- a/src/mongo/db/repl/member_state.h +++ b/src/mongo/db/repl/member_state.h @@ -31,6 +31,7 @@ #pragma once namespace mongo { +namespace replset { /* @@ -92,4 +93,5 @@ namespace mongo { return ""; } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/multicmd.h b/src/mongo/db/repl/multicmd.h index 02f53e2796e..6a95e7b6cbf 100644 --- a/src/mongo/db/repl/multicmd.h +++ b/src/mongo/db/repl/multicmd.h @@ -34,6 +34,7 @@ #include "mongo/util/background.h" namespace mongo { +namespace replset { struct Target { Target(std::string hostport) : toHost(hostport), ok(false) { } @@ -86,4 +87,5 @@ namespace mongo { (*i)->wait(); } } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 41c4ac7aacf..67588ead947 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -65,6 +65,7 @@ #include "mongo/util/startup_test.h" namespace mongo { +namespace replset { // cached copies of these...so don't rename them, drop them, etc.!!! static Database* localDB = NULL; @@ -772,4 +773,5 @@ namespace mongo { setNewOptime(lastOp[ "ts" ].date()); } } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h index 68714dea96d..675348bfc2e 100644 --- a/src/mongo/db/repl/oplog.h +++ b/src/mongo/db/repl/oplog.h @@ -29,12 +29,13 @@ #pragma once namespace mongo { - class BSONObj; class Database; class OperationContext; class OpTime; +namespace replset { + // These functions redefine the function for logOp(), // for either master/slave or replica sets. void oldRepl(); // master-slave @@ -112,4 +113,5 @@ namespace mongo { * Initializes the global OpTime with the value from the timestamp of the last oplog entry. */ void initOpTimeFromOplog(const std::string& oplogNS); -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/oplogreader.cpp b/src/mongo/db/repl/oplogreader.cpp index 6441d59e052..39b31de3d4d 100644 --- a/src/mongo/db/repl/oplogreader.cpp +++ b/src/mongo/db/repl/oplogreader.cpp @@ -45,6 +45,7 @@ #include "mongo/util/log.h" namespace mongo { +namespace replset { //number of readers created; // this happens when the source source changes, a reconfig/network-error or the cursor dies @@ -188,4 +189,5 @@ namespace mongo { tailingQuery(ns, query.done(), fields); } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h index 9121c466f66..14fc53edcd9 100644 --- a/src/mongo/db/repl/oplogreader.h +++ b/src/mongo/db/repl/oplogreader.h @@ -37,6 +37,8 @@ namespace mongo { extern const BSONObj reverseNaturalObj; // { $natural : -1 } + +namespace replset { /** * Authenticates conn using the server's cluster-membership credentials. * @@ -163,4 +165,5 @@ namespace mongo { bool passthroughHandshake(const mongo::OID& rid, const int f); }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/repl_reads_ok.cpp b/src/mongo/db/repl/repl_reads_ok.cpp index 6bec81ffbe9..ac2623eb709 100644 --- a/src/mongo/db/repl/repl_reads_ok.cpp +++ b/src/mongo/db/repl/repl_reads_ok.cpp @@ -36,6 +36,7 @@ #include "mongo/util/assert_util.h" namespace mongo { +namespace replset { /** we allow queries to SimpleSlave's */ void replVerifyReadsOk(const std::string& ns, const LiteParsedQuery* pq) { @@ -62,4 +63,5 @@ namespace mongo { } } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_reads_ok.h b/src/mongo/db/repl/repl_reads_ok.h index 492e8b55c78..825324d6a9c 100644 --- a/src/mongo/db/repl/repl_reads_ok.h +++ b/src/mongo/db/repl/repl_reads_ok.h @@ -32,10 +32,12 @@ namespace mongo { - class LiteParsedQuery; +namespace replset { + // Check to see if slaveOk reads are allowed, // based on read preference and query options void replVerifyReadsOk(const std::string& ns, const LiteParsedQuery* pq); -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/repl_set.h b/src/mongo/db/repl/repl_set.h index 5fadfa155c7..fea08ef3b5b 100644 --- a/src/mongo/db/repl/repl_set.h +++ b/src/mongo/db/repl/repl_set.h @@ -32,6 +32,7 @@ #include "mongo/util/concurrency/thread_pool.h" namespace mongo { +namespace replset { class ReplSet : public ReplSetImpl { public: @@ -96,4 +97,5 @@ namespace mongo { ReplSet(); }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_set_health_poll_task.cpp b/src/mongo/db/repl/repl_set_health_poll_task.cpp index 4bd9f113654..3e2340e1fd6 100644 --- a/src/mongo/db/repl/repl_set_health_poll_task.cpp +++ b/src/mongo/db/repl/repl_set_health_poll_task.cpp @@ -37,6 +37,7 @@ #include "mongo/db/repl/rs_config.h" namespace mongo { +namespace replset { int ReplSetHealthPollTask::s_try_offset = 0; @@ -292,4 +293,5 @@ namespace mongo { mem.electionTime = info["electionTime"].Date(); } } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_set_health_poll_task.h b/src/mongo/db/repl/repl_set_health_poll_task.h index d05f45d4b73..6d239e6e193 100644 --- a/src/mongo/db/repl/repl_set_health_poll_task.h +++ b/src/mongo/db/repl/repl_set_health_poll_task.h @@ -36,6 +36,7 @@ #include "mongo/util/net/hostandport.h" namespace mongo { +namespace replset { /** * Poll every other set member to check its status. @@ -90,4 +91,5 @@ namespace mongo { time_t _timeout; }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_set_impl.cpp b/src/mongo/db/repl/repl_set_impl.cpp index 75055a52c14..3d119df3b5b 100644 --- a/src/mongo/db/repl/repl_set_impl.cpp +++ b/src/mongo/db/repl/repl_set_impl.cpp @@ -30,6 +30,7 @@ #include "mongo/db/client.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/commands/get_last_error.h" #include "mongo/db/dbhelpers.h" #include "mongo/db/instance.h" #include "mongo/db/operation_context_impl.h" @@ -43,6 +44,7 @@ #include "mongo/util/exit.h" namespace mongo { +namespace replset { #ifdef MONGO_PLATFORM_64 const int ReplSetImpl::replWriterThreadCount = 16; const int ReplSetImpl::replPrefetcherThreadCount = 16; @@ -497,8 +499,6 @@ namespace { else _buildIndexes = true; } - extern BSONObj *getLastErrorDefault; - // @param reconf true if this is a reconfiguration and not an initial load of the configuration. // @return true if ok; throws if config really bad; false if config doesn't include self bool ReplSetImpl::initFromConfig(ReplSetConfig& c, bool reconf) { @@ -914,4 +914,5 @@ namespace { return true; } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_set_impl.h b/src/mongo/db/repl/repl_set_impl.h index 2e1c8d450b1..6b46d72d4ab 100644 --- a/src/mongo/db/repl/repl_set_impl.h +++ b/src/mongo/db/repl/repl_set_impl.h @@ -41,8 +41,10 @@ #include "mongo/util/concurrency/value.h" namespace mongo { - class Cloner; + +namespace replset { + struct FixUpInfo; class ReplSetCmdline; class ReplSetHealthPollTask; @@ -350,4 +352,5 @@ namespace mongo { static const char* _initialSyncFlagString; static const BSONObj _initialSyncFlag; }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_settings.cpp b/src/mongo/db/repl/repl_settings.cpp index 474631dd5e8..306ad48902c 100644 --- a/src/mongo/db/repl/repl_settings.cpp +++ b/src/mongo/db/repl/repl_settings.cpp @@ -45,6 +45,7 @@ #include "mongo/s/write_ops/batched_command_request.h" namespace mongo { +namespace replset { // our config from command line etc. @@ -209,4 +210,5 @@ namespace mongo { OpCounterServerStatusSection replOpCounterServerStatusSection( "opcountersRepl", &replOpCounters ); -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/repl_settings.h b/src/mongo/db/repl/repl_settings.h index 3b7238b7c63..00ae52f9e78 100644 --- a/src/mongo/db/repl/repl_settings.h +++ b/src/mongo/db/repl/repl_settings.h @@ -36,6 +36,7 @@ namespace mongo { +namespace replset { bool anyReplEnabled(); @@ -96,4 +97,5 @@ namespace mongo { }; extern ReplSettings replSettings; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/repl_start.cpp b/src/mongo/db/repl/repl_start.cpp index 2ca7650a6f9..54655160f88 100644 --- a/src/mongo/db/repl/repl_start.cpp +++ b/src/mongo/db/repl/repl_start.cpp @@ -39,6 +39,7 @@ #include "mongo/util/log.h" namespace mongo { +namespace replset { /** @param cfgString <setname>/<seedhost1>,<seedhost2> */ void parseReplsetCmdLine(const std::string& cfgString, @@ -108,4 +109,5 @@ namespace mongo { startMasterSlave(); } +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/repl_start.h b/src/mongo/db/repl/repl_start.h index 45643ad8ae1..1f621e08b0f 100644 --- a/src/mongo/db/repl/repl_start.h +++ b/src/mongo/db/repl/repl_start.h @@ -34,6 +34,7 @@ #include "mongo/util/net/hostandport.h" namespace mongo { +namespace replset { void parseReplsetCmdLine(const std::string& cfgString, std::string& setname, @@ -57,4 +58,5 @@ namespace mongo { // This function starts replica set or master/slave replication // based on command line/config parameters. void startReplication(); -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp index 1ac6e0daec3..a6f91384b6d 100644 --- a/src/mongo/db/repl/replset_commands.cpp +++ b/src/mongo/db/repl/replset_commands.cpp @@ -43,6 +43,7 @@ using namespace bson; namespace mongo { +namespace replset { void checkMembersUpForConfigChange(const ReplSetConfig& cfg, BSONObjBuilder& result, bool initial); @@ -452,4 +453,5 @@ namespace mongo { } } cmdReplSetUpdatePosition; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/replset_commands.h b/src/mongo/db/repl/replset_commands.h index e303ae13890..25dc174b945 100644 --- a/src/mongo/db/repl/replset_commands.h +++ b/src/mongo/db/repl/replset_commands.h @@ -35,8 +35,10 @@ #include "mongo/db/repl/rs.h" // replSet bool namespace mongo { +namespace replset { extern bool replSetBlind; + extern unsigned replSetForceInitialSyncFailure; /** * Base class for repl set commands. Checks basic things such if we're in @@ -73,4 +75,5 @@ namespace mongo { } }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/replset_web_handler.cpp b/src/mongo/db/repl/replset_web_handler.cpp index 0f4c9b96bca..631d4fa3643 100644 --- a/src/mongo/db/repl/replset_web_handler.cpp +++ b/src/mongo/db/repl/replset_web_handler.cpp @@ -36,10 +36,7 @@ #include "mongo/util/mongoutils/str.h" namespace mongo { - - extern void fillRsLog(std::stringstream&); - -namespace { +namespace replset { using namespace bson; using namespace mongoutils; @@ -129,5 +126,5 @@ namespace { } replSetHandler; -} // namespace -} // namespace mongo +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/resync.cpp b/src/mongo/db/repl/resync.cpp index 6db1ca4c6e2..dcd0ec414b5 100644 --- a/src/mongo/db/repl/resync.cpp +++ b/src/mongo/db/repl/resync.cpp @@ -33,6 +33,7 @@ #include "mongo/db/operation_context_impl.h" namespace mongo { +namespace replset { // operator requested resynchronization of replication (on a slave or secondary). {resync: 1} class CmdResync : public Command { @@ -117,4 +118,5 @@ namespace mongo { return true; } } cmdResync; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs.cpp b/src/mongo/db/repl/rs.cpp index c58c8d6a661..f2cba63d3df 100644 --- a/src/mongo/db/repl/rs.cpp +++ b/src/mongo/db/repl/rs.cpp @@ -42,6 +42,7 @@ using namespace std; namespace mongo { +namespace replset { using namespace bson; @@ -56,7 +57,7 @@ namespace mongo { return theReplSet && theReplSet->isPrimary(); } - void replset::sethbmsg(const string& s, const int level) { + void sethbmsg(const string& s, const int level) { if (theReplSet) { theReplSet->sethbmsg(s, level); } @@ -204,5 +205,5 @@ namespace mongo { } } replIndexPrefetch; -} - +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs.h b/src/mongo/db/repl/rs.h index 7be93804842..41ceddfb081 100644 --- a/src/mongo/db/repl/rs.h +++ b/src/mongo/db/repl/rs.h @@ -63,6 +63,7 @@ */ namespace mongo { +namespace replset { extern bool replSet; // true if using repl sets extern class ReplSet *theReplSet; // null until initialized @@ -73,6 +74,7 @@ namespace mongo { // Main entry point for replica sets void startReplSets(ReplSetCmdline *replSetCmdline); + bool isCurrentlyAReplSetPrimary(); /** * does local authentication @@ -109,4 +111,5 @@ namespace mongo { return true; } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_base.h b/src/mongo/db/repl/rs_base.h index 61c85dbdd56..b8615f46bfd 100644 --- a/src/mongo/db/repl/rs_base.h +++ b/src/mongo/db/repl/rs_base.h @@ -33,6 +33,7 @@ #include "mongo/util/log.h" namespace mongo { +namespace replset { /** * most operations on a ReplSet object should be done while locked. that @@ -88,4 +89,5 @@ namespace mongo { bool lockedByMe() { return _lockedByMe.get(); } }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/rs_config.cpp b/src/mongo/db/repl/rs_config.cpp index 889e79466dd..0897e859136 100644 --- a/src/mongo/db/repl/rs_config.cpp +++ b/src/mongo/db/repl/rs_config.cpp @@ -46,6 +46,7 @@ using namespace bson; namespace mongo { +namespace replset { mongo::mutex ReplSetConfig::groupMx("RS tag group"); const int ReplSetConfig::DEFAULT_HB_TIMEOUT = 10; @@ -763,4 +764,5 @@ namespace mongo { _constructed = true; } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_config.h b/src/mongo/db/repl/rs_config.h index f25984a9ddf..1dab0945f8d 100644 --- a/src/mongo/db/repl/rs_config.h +++ b/src/mongo/db/repl/rs_config.h @@ -37,6 +37,7 @@ #include "mongo/util/net/hostandport.h" namespace mongo { +namespace replset { class Member; const std::string rsConfigNs = "local.system.replset"; @@ -328,4 +329,5 @@ namespace mongo { }; }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_exception.h b/src/mongo/db/repl/rs_exception.h index 4b3fc643991..5e0b70aea71 100644 --- a/src/mongo/db/repl/rs_exception.h +++ b/src/mongo/db/repl/rs_exception.h @@ -31,6 +31,7 @@ #pragma once namespace mongo { +namespace replset { class VoteException : public std::exception { public: @@ -42,4 +43,5 @@ namespace mongo { const char * what() const throw () { return "RetryAfterSleepException"; } }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp index ba09cf6f9c1..7e31ac3e94e 100644 --- a/src/mongo/db/repl/rs_initialsync.cpp +++ b/src/mongo/db/repl/rs_initialsync.cpp @@ -30,28 +30,31 @@ #include "mongo/db/repl/rs.h" +#include "mongo/bson/optime.h" #include "mongo/db/auth/authorization_manager.h" #include "mongo/db/auth/authorization_manager_global.h" #include "mongo/db/client.h" #include "mongo/db/cloner.h" #include "mongo/db/dbhelpers.h" +#include "mongo/db/operation_context_impl.h" +#include "mongo/db/operation_context_impl.h" +#include "mongo/db/pdfile.h" #include "mongo/db/repl/bgsync.h" +#include "mongo/db/repl/initial_sync.h" +#include "mongo/db/repl/initial_sync.h" #include "mongo/db/repl/member.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/bson/optime.h" #include "mongo/db/repl/repl_settings.h" // replSettings -#include "mongo/db/repl/initial_sync.h" -#include "mongo/db/operation_context_impl.h" +#include "mongo/db/structure/catalog/namespace_details.h" #include "mongo/util/mongoutils/str.h" namespace mongo { +namespace replset { using namespace mongoutils; using namespace bson; - void dropAllDatabasesExceptLocal(); - // add try/catch with sleep void isyncassert(const string& msg, bool expr) { @@ -491,4 +494,5 @@ namespace mongo { sethbmsg("initial sync done",0); } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_initiate.cpp b/src/mongo/db/repl/rs_initiate.cpp index b007c1fc8bf..0c5cb6b2a44 100644 --- a/src/mongo/db/repl/rs_initiate.cpp +++ b/src/mongo/db/repl/rs_initiate.cpp @@ -53,6 +53,7 @@ using namespace bson; using namespace mongoutils; namespace mongo { +namespace replset { /* called on a reconfig AND on initiate throws @@ -298,4 +299,5 @@ namespace mongo { } } cmdReplSetInitiate; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 1e5dc7dbe9e..24fc8fa5dd0 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -82,6 +82,7 @@ */ namespace mongo { +namespace replset { using namespace bson; @@ -744,4 +745,5 @@ namespace mongo { return 0; } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp index 2ccd9456ff4..85ffc3f7c8f 100644 --- a/src/mongo/db/repl/rs_sync.cpp +++ b/src/mongo/db/repl/rs_sync.cpp @@ -56,6 +56,7 @@ #include "mongo/util/fail_point_service.h" namespace mongo { +namespace replset { using namespace bson; @@ -300,4 +301,5 @@ namespace mongo { changeState(MemberState::RS_RECOVERING); } } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/state_box.h b/src/mongo/db/repl/state_box.h index 7a7a7b5663e..de9550e092a 100644 --- a/src/mongo/db/repl/state_box.h +++ b/src/mongo/db/repl/state_box.h @@ -33,6 +33,7 @@ #include "mongo/util/concurrency/rwlock.h" namespace mongo { +namespace replset { class Member; @@ -91,4 +92,5 @@ namespace mongo { RWLock m; SP sp; }; +} // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/sync.cpp b/src/mongo/db/repl/sync.cpp index 6ad56531f80..ce78d279d8e 100644 --- a/src/mongo/db/repl/sync.cpp +++ b/src/mongo/db/repl/sync.cpp @@ -42,6 +42,7 @@ #include "mongo/util/log.h" namespace mongo { +namespace replset { void Sync::setHostname(const string& hostname) { hn = hostname; @@ -135,4 +136,5 @@ namespace mongo { return true; } } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/sync.h b/src/mongo/db/repl/sync.h index 18ecaa63e54..fc1addcfafa 100644 --- a/src/mongo/db/repl/sync.h +++ b/src/mongo/db/repl/sync.h @@ -33,9 +33,10 @@ #include "mongo/db/jsobj.h" namespace mongo { - class Database; +namespace replset { + class Sync { protected: std::string hn; @@ -51,4 +52,5 @@ namespace mongo { void setHostname(const std::string& hostname); }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp index 03c243683b4..b4d7e16af65 100644 --- a/src/mongo/db/repl/sync_source_feedback.cpp +++ b/src/mongo/db/repl/sync_source_feedback.cpp @@ -40,6 +40,7 @@ #include "mongo/db/operation_context_impl.h" namespace mongo { +namespace replset { // used in replAuthenticate static const BSONObj userReplQuery = fromjson("{\"user\":\"repl\"}"); @@ -286,4 +287,5 @@ namespace mongo { } cc().shutdown(); } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/sync_source_feedback.h b/src/mongo/db/repl/sync_source_feedback.h index ba1fe483e45..8e7587382ca 100644 --- a/src/mongo/db/repl/sync_source_feedback.h +++ b/src/mongo/db/repl/sync_source_feedback.h @@ -35,6 +35,7 @@ #include "mongo/util/background.h" namespace mongo { +namespace replset { class Member; @@ -118,4 +119,5 @@ namespace mongo { // used to indicate a connection change which has not yet been shook on bool _handshakeNeeded; }; -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/write_concern.cpp b/src/mongo/db/repl/write_concern.cpp index a1d2481cc5d..ed7b2f09250 100644 --- a/src/mongo/db/repl/write_concern.cpp +++ b/src/mongo/db/repl/write_concern.cpp @@ -33,6 +33,7 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/user_name.h" #include "mongo/db/client.h" +#include "mongo/db/commands/fsync.h" #include "mongo/db/dbhelpers.h" #include "mongo/db/instance.h" #include "mongo/db/repl/is_master.h" @@ -43,10 +44,7 @@ #define REPLDEBUG(x) namespace mongo { - - // this is defined in fsync.cpp - // need to figure out where to put for real - bool lockedForWriting(); +namespace replset { using namespace mongoutils; @@ -367,4 +365,5 @@ namespace mongo { unsigned getSlaveCount() { return slaveTracking.getSlaveCount(); } -} +} // namespace replset +} // namespace mongo diff --git a/src/mongo/db/repl/write_concern.h b/src/mongo/db/repl/write_concern.h index 9c9aab87dc9..b9ec0b1ce8c 100644 --- a/src/mongo/db/repl/write_concern.h +++ b/src/mongo/db/repl/write_concern.h @@ -38,9 +38,10 @@ */ namespace mongo { - class CurOp; +namespace replset { + bool updateSlaveLocations(BSONArray optimes); void updateSlaveLocation( CurOp& curop, const char * oplog_ns , OpTime lastOp ); @@ -56,4 +57,5 @@ namespace mongo { void resetSlaveCache(); unsigned getSlaveCount(); -} +} // namespace replset +} // namespace mongo |