summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/plan_cache_commands.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/plan_cache_commands.h')
-rw-r--r--src/mongo/db/commands/plan_cache_commands.h271
1 files changed, 135 insertions, 136 deletions
diff --git a/src/mongo/db/commands/plan_cache_commands.h b/src/mongo/db/commands/plan_cache_commands.h
index 05b7c5969a8..3858704dbde 100644
--- a/src/mongo/db/commands/plan_cache_commands.h
+++ b/src/mongo/db/commands/plan_cache_commands.h
@@ -33,155 +33,154 @@
namespace mongo {
+/**
+ * DB commands for plan cache.
+ * These are in a header to facilitate unit testing. See plan_cache_commands_test.cpp.
+ */
+
+/**
+ * PlanCacheCommand
+ * Defines common attributes for all plan cache related commands
+ * such as slaveOk.
+ */
+class PlanCacheCommand : public Command {
+public:
+ PlanCacheCommand(const std::string& name, const std::string& helpText, ActionType actionType);
+
/**
- * DB commands for plan cache.
- * These are in a header to facilitate unit testing. See plan_cache_commands_test.cpp.
+ * Entry point from command subsystem.
+ * Implementation provides standardization of error handling
+ * such as adding error code and message to BSON result.
+ *
+ * Do not override in derived classes.
+ * Override runPlanCacheCommands instead to
+ * implement plan cache command functionality.
*/
+ bool run(OperationContext* txn,
+ const std::string& dbname,
+ BSONObj& cmdObj,
+ int options,
+ std::string& errmsg,
+ BSONObjBuilder& result);
+
+ virtual bool isWriteCommandForConfigServer() const;
+
+ virtual bool slaveOk() const;
+
+ virtual bool slaveOverrideOk() const;
+
+ virtual void help(std::stringstream& ss) const;
+
/**
- * PlanCacheCommand
- * Defines common attributes for all plan cache related commands
- * such as slaveOk.
+ * Two action types defined for plan cache commands:
+ * - planCacheRead
+ * - planCacheWrite
*/
- class PlanCacheCommand : public Command {
- public:
- PlanCacheCommand(const std::string& name, const std::string& helpText,
- ActionType actionType);
-
- /**
- * Entry point from command subsystem.
- * Implementation provides standardization of error handling
- * such as adding error code and message to BSON result.
- *
- * Do not override in derived classes.
- * Override runPlanCacheCommands instead to
- * implement plan cache command functionality.
- */
-
- bool run(OperationContext* txn,
- const std::string& dbname,
- BSONObj& cmdObj,
- int options,
- std::string& errmsg,
- BSONObjBuilder& result);
-
- virtual bool isWriteCommandForConfigServer() const;
-
- virtual bool slaveOk() const;
-
- virtual bool slaveOverrideOk() const;
-
- virtual void help(std::stringstream& ss) const;
-
- /**
- * Two action types defined for plan cache commands:
- * - planCacheRead
- * - planCacheWrite
- */
- virtual Status checkAuthForCommand(ClientBasic* client,
- const std::string& dbname,
- const BSONObj& cmdObj);
- /**
- * Subset of command arguments used by plan cache commands
- * Override to provide command functionality.
- * Should contain just enough logic to invoke run*Command() function
- * in plan_cache.h
- */
- virtual Status runPlanCacheCommand(OperationContext* txn,
- const std::string& ns,
- BSONObj& cmdObj,
- BSONObjBuilder* bob) = 0;
-
- /**
- * Validatess query shape from command object and returns canonical query.
- */
- static Status canonicalize(OperationContext* txn,
- const std::string& ns,
- const BSONObj& cmdObj,
- CanonicalQuery** canonicalQueryOut);
-
- private:
- std::string helpText;
- ActionType actionType;
- };
+ virtual Status checkAuthForCommand(ClientBasic* client,
+ const std::string& dbname,
+ const BSONObj& cmdObj);
+ /**
+ * Subset of command arguments used by plan cache commands
+ * Override to provide command functionality.
+ * Should contain just enough logic to invoke run*Command() function
+ * in plan_cache.h
+ */
+ virtual Status runPlanCacheCommand(OperationContext* txn,
+ const std::string& ns,
+ BSONObj& cmdObj,
+ BSONObjBuilder* bob) = 0;
/**
- * planCacheListQueryShapes
- *
- * { planCacheListQueryShapes: <collection> }
- *
+ * Validatess query shape from command object and returns canonical query.
*/
- class PlanCacheListQueryShapes : public PlanCacheCommand {
- public:
- PlanCacheListQueryShapes();
- virtual Status runPlanCacheCommand(OperationContext* txn,
- const std::string& ns,
- BSONObj& cmdObj,
- BSONObjBuilder* bob);
-
- /**
- * Looks up cache keys for collection's plan cache.
- * Inserts keys for query into BSON builder.
- */
- static Status list(const PlanCache& planCache, BSONObjBuilder* bob);
- };
+ static Status canonicalize(OperationContext* txn,
+ const std::string& ns,
+ const BSONObj& cmdObj,
+ CanonicalQuery** canonicalQueryOut);
+
+private:
+ std::string helpText;
+ ActionType actionType;
+};
+
+/**
+ * planCacheListQueryShapes
+ *
+ * { planCacheListQueryShapes: <collection> }
+ *
+ */
+class PlanCacheListQueryShapes : public PlanCacheCommand {
+public:
+ PlanCacheListQueryShapes();
+ virtual Status runPlanCacheCommand(OperationContext* txn,
+ const std::string& ns,
+ BSONObj& cmdObj,
+ BSONObjBuilder* bob);
/**
- * planCacheClear
- *
- * {
- * planCacheClear: <collection>,
- * query: <query>,
- * sort: <sort>,
- * projection: <projection>
- * }
- *
+ * Looks up cache keys for collection's plan cache.
+ * Inserts keys for query into BSON builder.
*/
- class PlanCacheClear : public PlanCacheCommand {
- public:
- PlanCacheClear();
- virtual Status runPlanCacheCommand(OperationContext* txn,
- const std::string& ns,
- BSONObj& cmdObj,
- BSONObjBuilder* bob);
-
- /**
- * Clears collection's plan cache.
- * If query shape is provided, clears plans for that single query shape only.
- */
- static Status clear(OperationContext* txn,
- PlanCache* planCache,
- const std::string& ns,
- const BSONObj& cmdObj);
- };
+ static Status list(const PlanCache& planCache, BSONObjBuilder* bob);
+};
+
+/**
+ * planCacheClear
+ *
+ * {
+ * planCacheClear: <collection>,
+ * query: <query>,
+ * sort: <sort>,
+ * projection: <projection>
+ * }
+ *
+ */
+class PlanCacheClear : public PlanCacheCommand {
+public:
+ PlanCacheClear();
+ virtual Status runPlanCacheCommand(OperationContext* txn,
+ const std::string& ns,
+ BSONObj& cmdObj,
+ BSONObjBuilder* bob);
/**
- * planCacheListPlans
- *
- * {
- * planCacheListPlans: <collection>,
- * query: <query>,
- * sort: <sort>,
- * projection: <projection>
- * }
- *
+ * Clears collection's plan cache.
+ * If query shape is provided, clears plans for that single query shape only.
+ */
+ static Status clear(OperationContext* txn,
+ PlanCache* planCache,
+ const std::string& ns,
+ const BSONObj& cmdObj);
+};
+
+/**
+ * planCacheListPlans
+ *
+ * {
+ * planCacheListPlans: <collection>,
+ * query: <query>,
+ * sort: <sort>,
+ * projection: <projection>
+ * }
+ *
+ */
+class PlanCacheListPlans : public PlanCacheCommand {
+public:
+ PlanCacheListPlans();
+ virtual Status runPlanCacheCommand(OperationContext* txn,
+ const std::string& ns,
+ BSONObj& cmdObj,
+ BSONObjBuilder* bob);
+
+ /**
+ * Displays the cached plans for a query shape.
*/
- class PlanCacheListPlans : public PlanCacheCommand {
- public:
- PlanCacheListPlans();
- virtual Status runPlanCacheCommand(OperationContext* txn,
- const std::string& ns,
- BSONObj& cmdObj,
- BSONObjBuilder* bob);
-
- /**
- * Displays the cached plans for a query shape.
- */
- static Status list(OperationContext* txn,
- const PlanCache& planCache,
- const std::string& ns,
- const BSONObj& cmdObj,
- BSONObjBuilder* bob);
- };
+ static Status list(OperationContext* txn,
+ const PlanCache& planCache,
+ const std::string& ns,
+ const BSONObj& cmdObj,
+ BSONObjBuilder* bob);
+};
} // namespace mongo