diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-04-19 10:15:15 -0400 |
---|---|---|
committer | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-04-19 15:13:07 -0400 |
commit | 052e2702906d3bbcf2d594548702fca5d0b1cfbf (patch) | |
tree | 462f0662c52b029e0b81dfd0cf7d235cad92f7ce /src/mongo/s/client/shard.h | |
parent | 67c4cdae5ca86e628442ee4e5918996e989dd1f4 (diff) | |
download | mongo-052e2702906d3bbcf2d594548702fca5d0b1cfbf.tar.gz |
SERVER-23497 add RemoteShard class (temporarily called Shard)
Diffstat (limited to 'src/mongo/s/client/shard.h')
-rw-r--r-- | src/mongo/s/client/shard.h | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/mongo/s/client/shard.h b/src/mongo/s/client/shard.h index 9d273d6904a..a8a41214389 100644 --- a/src/mongo/s/client/shard.h +++ b/src/mongo/s/client/shard.h @@ -31,13 +31,15 @@ #include <string> #include "mongo/base/disallow_copying.h" +#include "mongo/bson/bsonobj.h" #include "mongo/client/connection_string.h" +#include "mongo/client/remote_command_targeter.h" +#include "mongo/db/namespace_string.h" +#include "mongo/db/repl/optime.h" +#include "mongo/executor/task_executor.h" namespace mongo { -class BSONObj; -class RemoteCommandTargeter; - using ShardId = std::string; class Shard; @@ -51,6 +53,16 @@ class Shard { MONGO_DISALLOW_COPYING(Shard); public: + struct CommandResponse { + BSONObj response; + BSONObj metadata; + }; + + struct QueryResponse { + std::vector<BSONObj> docs; + repl::OpTime opTime; + }; + /** * Instantiates a new shard connection management object for the specified shard. */ @@ -69,7 +81,6 @@ public: */ bool isConfig() const; - /** * Returns the current config string. */ @@ -92,6 +103,22 @@ public: */ std::string toString() const; + StatusWith<CommandResponse> runCommand(OperationContext* txn, + const ReadPreferenceSetting& readPref, + const std::string& dbName, + const BSONObj& cmdObj, + const BSONObj& metadata); + + /** + * Warning: This method exhausts the cursor and pulls all data into memory. + * Do not use other than for very small (i.e., admin or metadata) collections. + */ + StatusWith<QueryResponse> exhaustiveFindOnConfig(OperationContext* txn, + const ReadPreferenceSetting& readPref, + const NamespaceString& nss, + const BSONObj& query, + const BSONObj& sort, + const boost::optional<long long> limit); /** * Notifies the RemoteCommandTargeter owned by the shard of a particular mode of failure for the @@ -99,8 +126,22 @@ public: */ void updateReplSetMonitor(const HostAndPort& remoteHost, const Status& remoteCommandStatus); - private: + // TODO: SERVER-23782 make Shard::_runCommand take a timeout argument. + StatusWith<CommandResponse> _runCommand(OperationContext* txn, + const ReadPreferenceSetting& readPref, + const std::string& dbname, + const BSONObj& cmdObj, + const BSONObj& metadata); + + // TODO: SERVER-23782 make Shard::_exhaustiveFindOnConfig take a timeout argument. + StatusWith<QueryResponse> _exhaustiveFindOnConfig(OperationContext* txn, + const ReadPreferenceSetting& readPref, + const NamespaceString& nss, + const BSONObj& query, + const BSONObj& sort, + boost::optional<long long> limit); + /** * Identifier of the shard as obtained from the configuration data (i.e. shard0000). */ |