summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2009-09-01 16:23:56 -0400
committerDwight <dmerriman@gmail.com>2009-09-01 16:23:56 -0400
commit7172529835487de9dec84e03c5eea4c2d065a621 (patch)
tree1cebf3643ef3a641b51b82744dae49811a731992 /db
parent777c1883c3d019e1318703eb324fa55dff325ad8 (diff)
downloadmongo-7172529835487de9dec84e03c5eea4c2d065a621.tar.gz
some help for commands
Diffstat (limited to 'db')
-rw-r--r--db/cloner.cpp40
-rw-r--r--db/dbcommands.cpp30
2 files changed, 54 insertions, 16 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp
index b91552c63a1..76dace7c62d 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -381,6 +381,10 @@ namespace mongo {
virtual bool slaveOk() {
return false;
}
+ virtual void help( stringstream &help ) const {
+ help << "clone this database from an instance of the db on another host\n";
+ help << "example: { clone : \"host13\" }";
+ }
CmdClone() : Command("clone") { }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string from = cmdObj.getStringField("clone");
@@ -546,6 +550,10 @@ namespace mongo {
virtual bool slaveOk() {
return false;
}
+ virtual void help( stringstream &help ) const {
+ help << "copy a database from antoher host to this host\n";
+ help << "usage: {copydb: 1, fromhost: <hostname>, fromdb: <db>, todb: <db>}";
+ }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string fromhost = cmdObj.getStringField("fromhost");
if ( fromhost.empty() ) {
@@ -576,9 +584,9 @@ namespace mongo {
virtual bool slaveOk() {
return false;
}
- virtual bool logTheOp() {
- return true; // can't log steps when doing fast rename within a db, so always log the op rather than individual steps comprising it.
- }
+ virtual bool logTheOp() {
+ return true; // can't log steps when doing fast rename within a db, so always log the op rather than individual steps comprising it.
+ }
virtual void help( stringstream &help ) const {
help << " example: { renameCollection: foo.a, to: bar.b }";
}
@@ -602,16 +610,16 @@ namespace mongo {
setClient( target.c_str() );
uassert( "target namespace exists", !nsdetails( target.c_str() ) );
- {
- char from[256];
- nsToClient( source.c_str(), from );
- char to[256];
- nsToClient( target.c_str(), to );
- if ( strcmp( from, to ) == 0 ) {
- renameNamespace( source.c_str(), target.c_str() );
- return true;
- }
- }
+ {
+ char from[256];
+ nsToClient( source.c_str(), from );
+ char to[256];
+ nsToClient( target.c_str(), to );
+ if ( strcmp( from, to ) == 0 ) {
+ renameNamespace( source.c_str(), target.c_str() );
+ return true;
+ }
+ }
BSONObjBuilder spec;
if ( capped ) {
@@ -666,9 +674,9 @@ namespace mongo {
theDataFileMgr.insert( targetIndexes.c_str(), n );
}
- setClientTempNs( source.c_str() );
- dropCollection( source, errmsg, result );
- return true;
+ setClientTempNs( source.c_str() );
+ dropCollection( source, errmsg, result );
+ return true;
}
} cmdrenamecollection;
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index b6f68c368c1..9b6a44656df 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -209,6 +209,9 @@ namespace mongo {
virtual bool slaveOk() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "shutdown the database. must be ran against admin db and either (1) ran from localhost or (2) authenticated.\n";
+ }
CmdShutdown() : Command("shutdown") {}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
if( noauth ) {
@@ -241,6 +244,9 @@ namespace mongo {
virtual bool slaveOk() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "reset error state (used with getpreverror)";
+ }
CmdResetError() : Command("reseterror") {}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
LastError *le = lastError.get();
@@ -259,6 +265,9 @@ namespace mongo {
virtual bool slaveOk() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "return error status of the last operation";
+ }
CmdGetLastError() : Command("getlasterror") {}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
LastError *le = lastError.get();
@@ -294,6 +303,9 @@ namespace mongo {
virtual bool logTheOp() {
return false;
}
+ virtual void help( stringstream& help ) const {
+ help << "check for errors since last reseterror commandcal";
+ }
virtual bool slaveOk() {
return true;
}
@@ -316,6 +328,9 @@ namespace mongo {
virtual bool logTheOp() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "drop (delete) this database";
+ }
virtual bool slaveOk() {
return false;
}
@@ -339,6 +354,9 @@ namespace mongo {
virtual bool slaveOk() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "repair database. also compacts. note: slow.";
+ }
CmdRepairDatabase() : Command("repairDatabase") {}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
BSONElement e = cmdObj.findElement(name);
@@ -363,6 +381,9 @@ namespace mongo {
virtual bool slaveOk() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "enable or disable performance profiling";
+ }
CmdProfile() : Command("profile") {}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
BSONElement e = cmdObj.findElement(name);
@@ -441,6 +462,9 @@ namespace mongo {
virtual bool slaveOk() {
return true;
}
+ virtual void help( stringstream& help ) const {
+ help << "check if any asserts have occurred on the server";
+ }
CmdAssertInfo() : Command("assertinfo") {}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
result.appendBool("dbasserted", lastAssert[0].isSet() || lastAssert[1].isSet() || lastAssert[2].isSet());
@@ -678,6 +702,9 @@ namespace mongo {
virtual bool adminOnly() {
return false;
}
+ virtual void help( stringstream& help ) const {
+ help << "create a collection";
+ }
virtual bool run(const char *_ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
string ns = database->name + '.' + cmdObj.findElement(name).valuestr();
string err;
@@ -696,6 +723,9 @@ namespace mongo {
virtual bool slaveOk() {
return false;
}
+ virtual void help( stringstream& help ) const {
+ help << "delete indexes for a collection";
+ }
CmdDeleteIndexes() : Command("deleteIndexes") { }
bool run(const char *ns, BSONObj& jsobj, string& errmsg, BSONObjBuilder& anObjBuilder, bool /*fromRepl*/) {
/* note: temp implementation. space not reclaimed! */