summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/commands/cluster_count_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_find_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_index_filter_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_pipeline_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_plan_cache_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp2
-rw-r--r--src/mongo/s/commands/commands_public.cpp6
-rw-r--r--src/mongo/s/request.cpp8
-rw-r--r--src/mongo/s/strategy.cpp1
-rw-r--r--src/mongo/s/strategy.h44
11 files changed, 36 insertions, 41 deletions
diff --git a/src/mongo/s/commands/cluster_count_cmd.cpp b/src/mongo/s/commands/cluster_count_cmd.cpp
index 2ed5124da2a..8e277d6735d 100644
--- a/src/mongo/s/commands/cluster_count_cmd.cpp
+++ b/src/mongo/s/commands/cluster_count_cmd.cpp
@@ -157,7 +157,7 @@ namespace {
}
vector<Strategy::CommandResult> countResult;
- STRATEGY->commandOp(dbname,
+ Strategy::commandOp(dbname,
countCmdBuilder.done(),
options,
fullns,
@@ -223,7 +223,7 @@ namespace {
Timer timer;
vector<Strategy::CommandResult> shardResults;
- STRATEGY->commandOp(dbname,
+ Strategy::commandOp(dbname,
explainCmdBob.obj(),
0,
fullns,
diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp
index 0ce83b267b9..f92c486c6ee 100644
--- a/src/mongo/s/commands/cluster_find_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_cmd.cpp
@@ -106,7 +106,7 @@ namespace mongo {
Timer timer;
vector<Strategy::CommandResult> shardResults;
- STRATEGY->commandOp(dbname,
+ Strategy::commandOp(dbname,
explainCmdBob.obj(),
lpq->getOptions(),
fullns,
diff --git a/src/mongo/s/commands/cluster_index_filter_cmd.cpp b/src/mongo/s/commands/cluster_index_filter_cmd.cpp
index b2549aba733..8ff8e9b28b3 100644
--- a/src/mongo/s/commands/cluster_index_filter_cmd.cpp
+++ b/src/mongo/s/commands/cluster_index_filter_cmd.cpp
@@ -120,7 +120,7 @@ namespace mongo {
// Targeted shard commands are generally data-dependent but index filter
// commands are tied to query shape (data has no effect on query shape).
vector<Strategy::CommandResult> results;
- STRATEGY->commandOp(dbName, cmdObj, options, nss.ns(), BSONObj(), &results);
+ Strategy::commandOp(dbName, cmdObj, options, nss.ns(), BSONObj(), &results);
// Set value of first shard result's "ok" field.
bool clusterCmdResult = true;
diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
index 931f1455294..d1a8571f871 100644
--- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
@@ -319,7 +319,7 @@ namespace {
// TODO: take distributed lock to prevent split / migration?
try {
- STRATEGY->commandOp(dbname, shardedCommand, 0, fullns, q, &mrCommandResults);
+ Strategy::commandOp(dbname, shardedCommand, 0, fullns, q, &mrCommandResults);
}
catch (DBException& e){
e.addContext(str::stream() << "could not run map command on all shards for ns "
@@ -485,7 +485,7 @@ namespace {
mrCommandResults.clear();
try {
- STRATEGY->commandOp(outDB, finalCmdObj, 0, finalColLong, BSONObj(), &mrCommandResults);
+ Strategy::commandOp(outDB, finalCmdObj, 0, finalColLong, BSONObj(), &mrCommandResults);
ok = true;
}
catch (DBException& e){
diff --git a/src/mongo/s/commands/cluster_pipeline_cmd.cpp b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
index 9f4f44edc2a..ec03c7e618d 100644
--- a/src/mongo/s/commands/cluster_pipeline_cmd.cpp
+++ b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
@@ -170,7 +170,7 @@ namespace {
// Run the command on the shards
// TODO need to make sure cursors are killed if a retry is needed
vector<Strategy::CommandResult> shardResults;
- STRATEGY->commandOp(dbname,
+ Strategy::commandOp(dbname,
shardedCommand,
options,
fullns,
diff --git a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp
index 314314cdd51..aeaa6609a9a 100644
--- a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp
+++ b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp
@@ -121,7 +121,7 @@ namespace mongo {
// Targeted shard commands are generally data-dependent but plan cache
// commands are tied to query shape (data has no effect on query shape).
vector<Strategy::CommandResult> results;
- STRATEGY->commandOp(dbName, cmdObj, options, nss.ns(), BSONObj(), &results);
+ Strategy::commandOp(dbName, cmdObj, options, nss.ns(), BSONObj(), &results);
// Set value of first shard result's "ok" field.
bool clusterCmdResult = true;
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index 83a039a3f3b..a22dd2c7dc7 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -123,7 +123,7 @@ namespace {
// Target the command to the shards based on the singleton batch item.
BatchItemRef targetingBatchItem(&request, 0);
vector<Strategy::CommandResult> shardResults;
- Status status = STRATEGY->commandOpWrite(dbname,
+ Status status = Strategy::commandOpWrite(dbname,
explainCmdBob.obj(),
targetingBatchItem,
&shardResults);
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp
index e7b6c0caf91..381f27d5de6 100644
--- a/src/mongo/s/commands/commands_public.cpp
+++ b/src/mongo/s/commands/commands_public.cpp
@@ -1089,7 +1089,7 @@ namespace mongo {
Timer timer;
Strategy::CommandResult singleResult;
- Status commandStat = STRATEGY->commandOpUnsharded(dbname,
+ Status commandStat = Strategy::commandOpUnsharded(dbname,
explainCmdBob.obj(),
0,
fullns,
@@ -1266,7 +1266,7 @@ namespace mongo {
BSONObj finder = BSON("files_id" << cmdObj.firstElement());
vector<Strategy::CommandResult> results;
- STRATEGY->commandOp(dbName, cmdObj, 0, fullns, finder, &results);
+ Strategy::commandOp(dbName, cmdObj, 0, fullns, finder, &results);
verify(results.size() == 1); // querying on shard key so should only talk to one shard
BSONObj res = results.begin()->result;
@@ -1299,7 +1299,7 @@ namespace mongo {
vector<Strategy::CommandResult> results;
try {
- STRATEGY->commandOp(dbName, shardCmd, 0, fullns, finder, &results);
+ Strategy::commandOp(dbName, shardCmd, 0, fullns, finder, &results);
}
catch( DBException& e ){
//This is handled below and logged
diff --git a/src/mongo/s/request.cpp b/src/mongo/s/request.cpp
index 5c231d507c9..6ece1659e93 100644
--- a/src/mongo/s/request.cpp
+++ b/src/mongo/s/request.cpp
@@ -118,20 +118,20 @@ namespace mongo {
<< ") for $cmd type ns - can only be 1 or -1",
n == 1 || n == -1 );
- STRATEGY->clientCommandOp(*this);
+ Strategy::clientCommandOp(*this);
}
else {
- STRATEGY->queryOp( *this );
+ Strategy::queryOp( *this );
}
globalOpCounters.gotOp( op , iscmd );
}
else if ( op == dbGetMore ) {
- STRATEGY->getMore( *this );
+ Strategy::getMore( *this );
globalOpCounters.gotOp( op , iscmd );
}
else {
- STRATEGY->writeOp( op, *this );
+ Strategy::writeOp( op, *this );
// globalOpCounters are handled by write commands.
}
diff --git a/src/mongo/s/strategy.cpp b/src/mongo/s/strategy.cpp
index 6e6b129ca10..d28d778ea7b 100644
--- a/src/mongo/s/strategy.cpp
+++ b/src/mongo/s/strategy.cpp
@@ -700,5 +700,4 @@ namespace mongo {
}
}
- Strategy * STRATEGY = new Strategy();
}
diff --git a/src/mongo/s/strategy.h b/src/mongo/s/strategy.h
index dbb02ec2d15..0cab91329d7 100644
--- a/src/mongo/s/strategy.h
+++ b/src/mongo/s/strategy.h
@@ -43,13 +43,11 @@ namespace mongo {
class Strategy {
public:
- Strategy() {}
+ static void queryOp(Request& r);
- void queryOp( Request& r );
+ static void getMore(Request& r);
- void getMore( Request& r );
-
- void writeOp( int op , Request& r );
+ static void writeOp(int op , Request& r);
struct CommandResult {
Shard shardTarget;
@@ -66,12 +64,12 @@ namespace mongo {
* TODO: Replace these methods and all other methods of command dispatch with a more general
* command op framework.
*/
- void commandOp( const std::string& db,
- const BSONObj& command,
- int options,
- const std::string& versionedNS,
- const BSONObj& targetingQuery,
- std::vector<CommandResult>* results );
+ static void commandOp(const std::string& db,
+ const BSONObj& command,
+ int options,
+ const std::string& versionedNS,
+ const BSONObj& targetingQuery,
+ std::vector<CommandResult>* results);
/**
* Executes a write command against a particular database, and targets the command based on
@@ -82,10 +80,10 @@ namespace mongo {
* Similar to commandOp() above, but the targeting rules are different for writes than for
* reads.
*/
- Status commandOpWrite(const std::string& db,
- const BSONObj& command,
- BatchItemRef targetingBatchItem,
- std::vector<CommandResult>* results);
+ static Status commandOpWrite(const std::string& db,
+ const BSONObj& command,
+ BatchItemRef targetingBatchItem,
+ std::vector<CommandResult>* results);
/**
* Some commands can only be run in a sharded configuration against a namespace that has
@@ -96,26 +94,24 @@ namespace mongo {
* On success, fills in 'shardResult' with output from the namespace's primary shard. This
* output may itself indicate an error status on the shard.
*/
- Status commandOpUnsharded(const std::string& db,
- const BSONObj& command,
- int options,
- const std::string& versionedNS,
- CommandResult* shardResult);
+ static Status commandOpUnsharded(const std::string& db,
+ const BSONObj& command,
+ int options,
+ const std::string& versionedNS,
+ CommandResult* shardResult);
/**
* Executes a command represented in the Request on the sharded cluster.
*
* DEPRECATED: should not be used by new code.
*/
- void clientCommandOp( Request& r );
+ static void clientCommandOp( Request& r );
protected:
- bool handleSpecialNamespaces( Request& r , QueryMessage& q );
+ static bool handleSpecialNamespaces( Request& r , QueryMessage& q );
};
- extern Strategy* STRATEGY;
-
}