diff options
author | Andrew Morrow <acm@mongodb.com> | 2015-06-10 19:01:38 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2015-06-10 22:38:00 -0400 |
commit | 4035cab6b974613af9eb06ac1a92cc39d6ba8e06 (patch) | |
tree | 15c606e4514037d563fad28de9c091de3d9e473e /src/mongo/client | |
parent | 1360f243ee7fa662c0ded25a9bc479aa47388446 (diff) | |
download | mongo-4035cab6b974613af9eb06ac1a92cc39d6ba8e06.tar.gz |
SERVER-17307 Replace boost::shared_ptr and friends with std::shared_ptr
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/dbclient_rs.cpp | 3 | ||||
-rw-r--r-- | src/mongo/client/dbclient_rs.h | 7 | ||||
-rw-r--r-- | src/mongo/client/parallel.cpp | 11 | ||||
-rw-r--r-- | src/mongo/client/parallel.h | 17 | ||||
-rw-r--r-- | src/mongo/client/remote_command_targeter_rs.h | 4 | ||||
-rw-r--r-- | src/mongo/client/replica_set_monitor.cpp | 9 | ||||
-rw-r--r-- | src/mongo/client/replica_set_monitor.h | 9 | ||||
-rw-r--r-- | src/mongo/client/replica_set_monitor_test.cpp | 33 |
8 files changed, 43 insertions, 50 deletions
diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp index a344f8d3fb8..f6bdd726006 100644 --- a/src/mongo/client/dbclient_rs.cpp +++ b/src/mongo/client/dbclient_rs.cpp @@ -32,7 +32,6 @@ #include "mongo/client/dbclient_rs.h" #include <memory> -#include <boost/shared_ptr.hpp> #include <utility> #include "mongo/bson/util/builder.h" @@ -46,7 +45,7 @@ namespace mongo { - using boost::shared_ptr; + using std::shared_ptr; using std::unique_ptr; using std::endl; using std::map; diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h index ac2fd24f161..68481b34ec8 100644 --- a/src/mongo/client/dbclient_rs.h +++ b/src/mongo/client/dbclient_rs.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/shared_ptr.hpp> #include <utility> #include "mongo/client/dbclientinterface.h" @@ -40,7 +39,7 @@ namespace mongo { class ReplicaSetMonitor; class TagSet; struct ReadPreferenceSetting; - typedef boost::shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr; + typedef std::shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr; /** Use this class to connect to a replica set of servers. The class will manage checking for which server in a replica set is master, and do failover automatically. @@ -222,7 +221,7 @@ namespace mongo { * @throws DBException when an error occurred either when trying to connect to * a node that was thought to be ok or when an assertion happened. */ - DBClientConnection* selectNodeUsingTags(boost::shared_ptr<ReadPreferenceSetting> readPref); + DBClientConnection* selectNodeUsingTags(std::shared_ptr<ReadPreferenceSetting> readPref); /** * @return true if the last host used in the last slaveOk query is still in the @@ -277,7 +276,7 @@ namespace mongo { // if connection is primary, it is owned by _master so it is incorrect to return // it to the pool. std::unique_ptr<DBClientConnection> _lastSlaveOkConn; - boost::shared_ptr<ReadPreferenceSetting> _lastReadPref; + std::shared_ptr<ReadPreferenceSetting> _lastReadPref; double _so_timeout; diff --git a/src/mongo/client/parallel.cpp b/src/mongo/client/parallel.cpp index a9fd94e7e6a..9b9ddd5b6e2 100644 --- a/src/mongo/client/parallel.cpp +++ b/src/mongo/client/parallel.cpp @@ -34,7 +34,6 @@ #include "mongo/client/parallel.h" -#include <boost/shared_ptr.hpp> #include "mongo/client/connpool.h" #include "mongo/client/constants.h" @@ -53,7 +52,7 @@ namespace mongo { - using boost::shared_ptr; + using std::shared_ptr; using std::endl; using std::list; using std::map; @@ -560,7 +559,7 @@ namespace mongo { void ParallelSortClusteredCursor::setupVersionAndHandleSlaveOk( PCStatePtr state, const ShardId& shardId, - boost::shared_ptr<Shard> primary, + std::shared_ptr<Shard> primary, const NamespaceString& ns, const string& vinfo, ChunkManagerPtr manager ) { @@ -1187,7 +1186,7 @@ namespace mongo { return _cursorMap.size(); } - boost::shared_ptr<Shard> ParallelSortClusteredCursor::getQueryShard() { + std::shared_ptr<Shard> ParallelSortClusteredCursor::getQueryShard() { return grid.shardRegistry()->findIfExists(_cursorMap.begin()->first); } @@ -1199,9 +1198,9 @@ namespace mongo { } } - boost::shared_ptr<Shard> ParallelSortClusteredCursor::getPrimary() { + std::shared_ptr<Shard> ParallelSortClusteredCursor::getPrimary() { if (isSharded()) - return boost::shared_ptr<Shard>(); + return std::shared_ptr<Shard>(); return _cursorMap.begin()->second.pcState->primary; } diff --git a/src/mongo/client/parallel.h b/src/mongo/client/parallel.h index 25b1993631a..3e97b6c23ea 100644 --- a/src/mongo/client/parallel.h +++ b/src/mongo/client/parallel.h @@ -31,7 +31,6 @@ #pragma once -#include <boost/shared_ptr.hpp> #include "mongo/db/namespace_string.h" #include "mongo/s/client/shard.h" @@ -62,7 +61,7 @@ namespace mongo { }; class DBClientCursor; - typedef boost::shared_ptr<DBClientCursor> DBClientCursorPtr; + typedef std::shared_ptr<DBClientCursor> DBClientCursorPtr; class ParallelConnectionState { public: @@ -77,7 +76,7 @@ namespace mongo { // Version information ChunkManagerPtr manager; - boost::shared_ptr<Shard> primary; + std::shared_ptr<Shard> primary; // Cursor status information long long count; @@ -91,7 +90,7 @@ namespace mongo { }; typedef ParallelConnectionState PCState; - typedef boost::shared_ptr<PCState> PCStatePtr; + typedef std::shared_ptr<PCState> PCStatePtr; class ParallelConnectionMetadata { public: @@ -123,7 +122,7 @@ namespace mongo { }; typedef ParallelConnectionMetadata PCMData; - typedef boost::shared_ptr<PCMData> PCMDataPtr; + typedef std::shared_ptr<PCMData> PCMDataPtr; /** * Runs a query in parallel across N servers, enforcing compatible chunk versions for queries @@ -188,13 +187,13 @@ namespace mongo { * Returns the single shard with an open cursor. * It is an error to call this if getNumQueryShards() > 1 */ - boost::shared_ptr<Shard> getQueryShard(); + std::shared_ptr<Shard> getQueryShard(); /** * Returns primary shard with an open cursor. * It is an error to call this if the collection is sharded. */ - boost::shared_ptr<Shard> getPrimary(); + std::shared_ptr<Shard> getPrimary(); DBClientCursorPtr getShardCursor(const ShardId& shardId); @@ -239,7 +238,7 @@ namespace mongo { */ void setupVersionAndHandleSlaveOk(PCStatePtr state /* in & out */, const ShardId& shardId, - boost::shared_ptr<Shard> primary /* in */, + std::shared_ptr<Shard> primary /* in */, const NamespaceString& ns, const std::string& vinfo, ChunkManagerPtr manager /* in */ ); @@ -355,7 +354,7 @@ namespace mongo { * @param conn optional connection to use. will use standard pooled if non-specified * @param useShardConn use ShardConnection */ - static boost::shared_ptr<CommandResult> spawnCommand( const std::string& server, + static std::shared_ptr<CommandResult> spawnCommand( const std::string& server, const std::string& db, const BSONObj& cmd, int options, diff --git a/src/mongo/client/remote_command_targeter_rs.h b/src/mongo/client/remote_command_targeter_rs.h index 253b0da7d2e..43f3ffd7be2 100644 --- a/src/mongo/client/remote_command_targeter_rs.h +++ b/src/mongo/client/remote_command_targeter_rs.h @@ -28,7 +28,7 @@ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <string> #include <vector> @@ -58,7 +58,7 @@ namespace mongo { const std::string _rsName; // Monitor for this replica set - boost::shared_ptr<ReplicaSetMonitor> _rsMonitor; + std::shared_ptr<ReplicaSetMonitor> _rsMonitor; }; } // namespace mongo diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp index 0b92969acc5..98cfde7af7b 100644 --- a/src/mongo/client/replica_set_monitor.cpp +++ b/src/mongo/client/replica_set_monitor.cpp @@ -32,7 +32,6 @@ #include "mongo/client/replica_set_monitor.h" #include <algorithm> -#include <boost/make_shared.hpp> #include <boost/thread.hpp> #include <boost/thread/condition.hpp> #include <limits> @@ -50,7 +49,7 @@ namespace mongo { - using boost::shared_ptr; + using std::shared_ptr; using std::numeric_limits; using std::set; using std::string; @@ -264,7 +263,7 @@ namespace { bool ReplicaSetMonitor::useDeterministicHostSelection = false; ReplicaSetMonitor::ReplicaSetMonitor(StringData name, const std::set<HostAndPort>& seeds) - : _state(boost::make_shared<SetState>(name, seeds)) { + : _state(std::make_shared<SetState>(name, seeds)) { log() << "starting new replica set monitor for replica set " << name << " with seeds "; @@ -360,7 +359,7 @@ namespace { boost::lock_guard<boost::mutex> lk(setsLock); ReplicaSetMonitorPtr& m = sets[name]; if (!m) { - m = boost::make_shared<ReplicaSetMonitor>(name, servers); + m = std::make_shared<ReplicaSetMonitor>(name, servers); } replicaSetMonitorWatcher.safeGo(); @@ -589,7 +588,7 @@ namespace { } ScanStatePtr Refresher::startNewScan(const SetState* set) { - const ScanStatePtr scan = boost::make_shared<ScanState>(); + const ScanStatePtr scan = std::make_shared<ScanState>(); // The heuristics we use in deciding the order to contact hosts are designed to find a // master as quickly as possible. This is because we can't use any hosts we find until diff --git a/src/mongo/client/replica_set_monitor.h b/src/mongo/client/replica_set_monitor.h index 64b7a89274e..599cc187dc9 100644 --- a/src/mongo/client/replica_set_monitor.h +++ b/src/mongo/client/replica_set_monitor.h @@ -27,7 +27,6 @@ #pragma once -#include <boost/shared_ptr.hpp> #include <set> #include <string> @@ -41,7 +40,7 @@ namespace mongo { class BSONObj; class ReplicaSetMonitor; struct ReadPreferenceSetting; - typedef boost::shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr; + typedef std::shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr; /** * Holds state about a replica set and provides a means to refresh the local view. @@ -145,7 +144,7 @@ namespace mongo { * it will return none. If createFromSeed is true, it will try to look up the last known * servers list for this set and will create a new monitor using that as the seed list. */ - static boost::shared_ptr<ReplicaSetMonitor> get(const std::string& name); + static std::shared_ptr<ReplicaSetMonitor> get(const std::string& name); /** * Returns all the currently tracked replica set names. @@ -191,8 +190,8 @@ namespace mongo { struct IsMasterReply; struct ScanState; struct SetState; - typedef boost::shared_ptr<ScanState> ScanStatePtr; - typedef boost::shared_ptr<SetState> SetStatePtr; + typedef std::shared_ptr<ScanState> ScanStatePtr; + typedef std::shared_ptr<SetState> SetStatePtr; // // FOR TESTING ONLY diff --git a/src/mongo/client/replica_set_monitor_test.cpp b/src/mongo/client/replica_set_monitor_test.cpp index 736e59f3f57..d2870739f1e 100644 --- a/src/mongo/client/replica_set_monitor_test.cpp +++ b/src/mongo/client/replica_set_monitor_test.cpp @@ -28,7 +28,6 @@ #include "mongo/platform/basic.h" -#include <boost/make_shared.hpp> #include "mongo/client/replica_set_monitor.h" #include "mongo/client/replica_set_monitor_internal.h" @@ -64,7 +63,7 @@ namespace { // NOT something that non-test code should do. TEST(ReplicaSetMonitor, InitialState) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); ASSERT_EQUALS(state->name, "name"); ASSERT(state->seedNodes == basicSeedsSet); ASSERT(state->lastSeenMaster.empty()); @@ -247,7 +246,7 @@ namespace { } TEST(ReplicaSetMonitor, CheckAllSeedsSerial) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -287,7 +286,7 @@ namespace { } TEST(ReplicaSetMonitor, CheckAllSeedsParallel) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -337,7 +336,7 @@ namespace { } TEST(ReplicaSetMonitor, NoMasterInitAllUp) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -376,7 +375,7 @@ namespace { } TEST(ReplicaSetMonitor, MasterNotInSeeds_NoPrimaryInIsMaster) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -435,7 +434,7 @@ namespace { } TEST(ReplicaSetMonitor, MasterNotInSeeds_PrimaryInIsMaster) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -492,7 +491,7 @@ namespace { TEST(ReplicaSetMonitor, SlavesUsableEvenIfNoMaster) { std::set<HostAndPort> seeds; seeds.insert(HostAndPort("a")); - SetStatePtr state = boost::make_shared<SetState>("name", seeds); + SetStatePtr state = std::make_shared<SetState>("name", seeds); Refresher refresher(state); const ReadPreferenceSetting secondary(ReadPreference::SecondaryOnly, TagSet()); @@ -528,7 +527,7 @@ namespace { // Test multiple nodes that claim to be master (we use a last-wins policy) TEST(ReplicaSetMonitor, MultipleMasterLastNodeWins) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -583,7 +582,7 @@ namespace { // Test nodes disagree about who is in the set, master is source of truth TEST(ReplicaSetMonitor, MasterIsSourceOfTruth) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); BSONArray primaryHosts = BSON_ARRAY("a" << "b" << "d"); @@ -614,7 +613,7 @@ namespace { // Test multiple master nodes that disagree about set membership TEST(ReplicaSetMonitor, MultipleMastersDisagree) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); BSONArray hostsForSeed[3]; @@ -695,7 +694,7 @@ namespace { // Ensure getMatchingHost returns hosts even if scan is ongoing TEST(ReplicaSetMonitor, GetMatchingDuringScan) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); const ReadPreferenceSetting primaryOnly(ReadPreference::PrimaryOnly, TagSet()); @@ -746,8 +745,8 @@ namespace { // Ensure nothing breaks when out-of-band failedHost is called during scan TEST(ReplicaSetMonitor, OutOfBandFailedHost) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); - ReplicaSetMonitorPtr rsm = boost::make_shared<ReplicaSetMonitor>(state); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); + ReplicaSetMonitorPtr rsm = std::make_shared<ReplicaSetMonitor>(state); Refresher refresher = rsm->startOrContinueRefresh(); for (size_t i = 0; i != basicSeeds.size(); ++i) { @@ -784,7 +783,7 @@ namespace { // Newly elected primary with electionId >= maximum electionId seen by the Refresher TEST(ReplicaSetMonitorTests, NewPrimaryWithMaxElectionId) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -840,7 +839,7 @@ namespace { // Ignore electionId of secondaries TEST(ReplicaSetMonitorTests, IgnoreElectionIdFromSecondaries) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); set<HostAndPort> seen; @@ -879,7 +878,7 @@ namespace { // Stale Primary with obsolete electionId TEST(ReplicaSetMonitorTests, StalePrimaryWithObsoleteElectionId) { - SetStatePtr state = boost::make_shared<SetState>("name", basicSeedsSet); + SetStatePtr state = std::make_shared<SetState>("name", basicSeedsSet); Refresher refresher(state); const OID firstElectionId = OID::gen(); |