Skip to content

Commit

Permalink
SERVER-13641 Unify Command::newRun into run
Browse files Browse the repository at this point in the history
This is the result of the following seds and a few manual fixups, including
removing the old run() and fixing the comments.

git grep -l '\<run(const'  | xargs sed -si -e 's/\brun(const/newRun(TransactionExperiment* txn, const/'

git grep -l '\<run( const'  | xargs sed -si -e 's/\brun( const/newRun(TransactionExperiment* txn, const/'

git grep -l '\<newRun('  | xargs sed -si -e 's/\bnewRun(/run(/'
  • Loading branch information
RedBeard0531 committed May 14, 2014
1 parent 6378da0 commit e3885ba
Show file tree
Hide file tree
Showing 80 changed files with 214 additions and 228 deletions.
2 changes: 1 addition & 1 deletion src/mongo/db/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ namespace mongo {
actions.addAction(ActionType::internal);
out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
}
virtual bool run(const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
Client& c = cc();
c.gotHandshake( cmdObj );
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/clientcursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ namespace mongo {
actions.addAction(ActionType::cursorInfo);
out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
}
bool run(const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result,
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result,
bool fromRepl ) {
_appendCursorStats( result );
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/mongo/db/cloner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ namespace mongo {
return Status::OK();
}
CmdClone() : Command("clone") { }
virtual bool newRun(TransactionExperiment* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string from = cmdObj.getStringField("clone");
if ( from.empty() )
return false;
Expand Down Expand Up @@ -629,7 +629,7 @@ namespace mongo {
"is placed at the same db.collection (namespace) as the source.\n"
;
}
virtual bool newRun(TransactionExperiment* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string fromhost = cmdObj.getStringField("from");
if ( fromhost.empty() ) {
errmsg = "missing 'from' parameter";
Expand Down Expand Up @@ -696,7 +696,7 @@ namespace mongo {
help << "get a nonce for subsequent copy db request from secure server\n";
help << "usage: {copydbgetnonce: 1, fromhost: <hostname>}";
}
virtual bool run(const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string fromhost = cmdObj.getStringField("fromhost");
if ( fromhost.empty() ) {
/* copy from self */
Expand Down Expand Up @@ -780,7 +780,7 @@ namespace mongo {
help << "usage: {copydb: 1, fromhost: <connection string>, fromdb: <db>, todb: <db>"
<< "[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]}";
}
virtual bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string fromhost = cmdObj.getStringField("fromhost");
bool fromSelf = fromhost.empty();
if ( fromSelf ) {
Expand Down
14 changes: 2 additions & 12 deletions src/mongo/db/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ namespace mongo {
return ResourcePattern::forExactNamespace(NamespaceString(ns));
}

bool Command::newRun(TransactionExperiment* txn,
const string& db,
BSONObj& cmdObj,
int options,
string& errmsg,
BSONObjBuilder& result,
bool fromRepl) {
return run(db, cmdObj, options, errmsg, result, fromRepl);
}

void Command::htmlHelp(stringstream& ss) const {
string helpStr;
{
Expand Down Expand Up @@ -346,7 +336,7 @@ namespace mongo {
out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
}

virtual bool run(const string&, mongo::BSONObj&, int, std::string&, mongo::BSONObjBuilder& result, bool) {
virtual bool run(TransactionExperiment* txn, const string&, mongo::BSONObj&, int, std::string&, mongo::BSONObjBuilder& result, bool) {
shardConnectionPool.flush();
pool.flush();
return true;
Expand All @@ -369,7 +359,7 @@ namespace mongo {
actions.addAction(ActionType::connPoolStats);
out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
}
virtual bool run(const string&, mongo::BSONObj&, int, std::string&, mongo::BSONObjBuilder& result, bool) {
virtual bool run(TransactionExperiment* txn, const string&, mongo::BSONObj&, int, std::string&, mongo::BSONObjBuilder& result, bool) {
pool.appendInfo( result );
result.append( "numDBClientConnection" , DBClientConnection::getNumConnections() );
result.append( "numAScopedConnection" , AScopedConnection::getNumConnections() );
Expand Down
11 changes: 2 additions & 9 deletions src/mongo/db/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,14 @@ namespace mutablebson {
normally do not want to log the command to the local oplog.
return value is true if succeeded. if false, set errmsg text.
Default impl forwards to private run(). It will go away soon.
*/
virtual bool newRun(TransactionExperiment* txn,
virtual bool run(TransactionExperiment* txn,
const string& db,
BSONObj& cmdObj,
int options,
string& errmsg,
BSONObjBuilder& result,
bool fromRepl = false );
bool fromRepl = false ) = 0;

/**
* This designation for the command is only used by the 'help' call and has nothing to do
Expand Down Expand Up @@ -160,7 +158,6 @@ namespace mutablebson {
virtual ~Command() {}

protected:

/**
* Appends to "*out" the privileges required to run this command on database "dbname" with
* the invocation described by "cmdObj". New commands shouldn't implement this, they should
Expand Down Expand Up @@ -234,10 +231,6 @@ namespace mutablebson {
static int testCommandsEnabled;

private:
// This method is deprecated. It should only be used by commands that don't transactions
virtual bool run(const string& db, BSONObj& cmdObj, int options, string& errmsg, BSONObjBuilder& result, bool fromRepl = false ) {
invariant(false);
}

/**
* Checks to see if the client is authorized to run the given command with the given
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/apply_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace mongo {
// applyOps can do pretty much anything, so require all privileges.
RoleGraph::generateUniversalPrivileges(out);
}
virtual bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {

if ( cmdObj.firstElement().type() != Array ) {
errmsg = "ops has to be an array";
Expand Down
1 change: 1 addition & 0 deletions src/mongo/db/commands/auth_schema_upgrade_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ namespace {

class CmdAuthSchemaUpgradeD : public CmdAuthSchemaUpgrade {
virtual bool run(
TransactionExperiment* txn,
const string& dbname,
BSONObj& cmdObj,
int options,
Expand Down
6 changes: 3 additions & 3 deletions src/mongo/db/commands/authentication_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace mongo {
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {} // No auth required
bool run(const string&, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
bool run(TransactionExperiment* txn, const string&, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
nonce64 n = getNextNonce();
stringstream ss;
ss << hex << n;
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace mongo {
}
}

bool CmdAuthenticate::run(const string& dbname,
bool CmdAuthenticate::run(TransactionExperiment* txn, const string& dbname,
BSONObj& cmdObj,
int,
string& errmsg,
Expand Down Expand Up @@ -351,7 +351,7 @@ namespace mongo {
void help(stringstream& h) const { h << "de-authenticate"; }
virtual bool isWriteCommandForConfigServer() const { return false; }
CmdLogout() : Command("logout") {}
bool run(const string& dbname,
bool run(TransactionExperiment* txn, const string& dbname,
BSONObj& cmdObj,
int options,
string& errmsg,
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/authentication_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace mongo {
virtual void redactForLogging(mutablebson::Document* cmdObj);

CmdAuthenticate() : Command("authenticate") {}
bool run(const string& dbname,
bool run(TransactionExperiment* txn, const string& dbname,
BSONObj& cmdObj,
int options,
string& errmsg,
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/cleanup_orphaned_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace mongo {
// Output
static BSONField<BSONObj> stoppedAtKeyField;

bool newRun( TransactionExperiment* txn,
bool run( TransactionExperiment* txn,
string const &db,
BSONObj &cmdObj,
int,
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/commands/collection_to_capped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace mongo {
NamespaceString(dbname, collection)),
targetActions));
}
bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
string from = jsobj.getStringField( "cloneCollectionAsCapped" );
string to = jsobj.getStringField( "toCollection" );
double size = jsobj.getField( "size" ).number();
Expand Down Expand Up @@ -196,7 +196,7 @@ namespace mongo {
return std::vector<BSONObj>();
}

bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
// calls renamecollection which does a global lock, so we must too:
//
Lock::GlobalWrite globalWriteLock;
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/compact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace mongo {
return IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
}

virtual bool newRun(TransactionExperiment* txn, const string& db, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& db, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string coll = cmdObj.firstElement().valuestr();
if( coll.empty() || db.empty() ) {
errmsg = "no collection name specified";
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/connection_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace mongo {
h << "Returns connection-specific information such as logged-in users";
}

bool run(const string&, BSONObj& cmdObj, int, string& errmsg,
bool run(TransactionExperiment* txn, const string&, BSONObj& cmdObj, int, string& errmsg,
BSONObjBuilder& result, bool fromRepl) {
AuthorizationSession* authSession =
ClientBasic::getCurrent()->getAuthorizationSession();
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/create_indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace mongo {
return b.obj();
}

virtual bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int options,
virtual bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int options,
string& errmsg, BSONObjBuilder& result,
bool fromRepl = false ) {

Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/dbhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace mongo {
return hash;
}

bool DBHashCmd::run(const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool) {
bool DBHashCmd::run(TransactionExperiment* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool) {
Timer timer;

set<string> desiredCollections;
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/dbhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace mongo {
const BSONObj& cmdObj,
std::vector<Privilege>* out);

virtual bool run(const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool);
virtual bool run(TransactionExperiment* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool);

void wipeCacheForCollection( const StringData& ns );

Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/distinct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace mongo {
help << "{ distinct : 'collection name' , key : 'a.b' , query : {} }";
}

bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result,
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result,
bool fromRepl ) {

Timer t;
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/commands/drop_indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace mongo {
}

CmdDropIndexes() : Command("dropIndexes", false, "deleteIndexes") { }
bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& anObjBuilder, bool fromRepl) {
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& anObjBuilder, bool fromRepl) {
Lock::DBWrite dbXLock(dbname);
bool ok = wrappedRun(txn, dbname, jsobj, errmsg, anObjBuilder);
if (ok && !fromRepl)
Expand Down Expand Up @@ -212,7 +212,7 @@ namespace mongo {
return IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
}

bool newRun(TransactionExperiment* txn, const string& dbname , BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool /*fromRepl*/) {
bool run(TransactionExperiment* txn, const string& dbname , BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool /*fromRepl*/) {
static DBDirectClient db;

BSONElement e = jsobj.firstElement();
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/fail_point_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace mongo {
h << "modifies the settings of a fail point";
}

bool run(const string& dbname,
bool run(TransactionExperiment* txn, const string& dbname,
BSONObj& cmdObj,
int,
string& errmsg,
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/find_and_modify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ namespace mongo {
return true;
}

virtual bool newRun(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int x, string& errmsg, BSONObjBuilder& result, bool y) {
virtual bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int x, string& errmsg, BSONObjBuilder& result, bool y) {
DBDirectClient db(txn);

if (cmdObj["sort"].eoo()) {
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/fsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace mongo {
actions.addAction(ActionType::fsync);
out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
}
virtual bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
virtual bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {

if (Lock::isLocked()) {
errmsg = "fsync: Cannot execute fsync command from contexts that hold a data lock";
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/geonear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace mongo {
out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions));
}

bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
const string ns = dbname + "." + cmdObj.firstElement().valuestr();

if (!cmdObj["start"].eoo()) {
Expand Down
6 changes: 3 additions & 3 deletions src/mongo/db/commands/get_last_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace mongo {
help << "reset error state (used with getpreverror)";
}
CmdResetError() : Command("resetError", false, "reseterror") {}
bool run(const string& db, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
bool run(TransactionExperiment* txn, const string& db, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
LastError *le = lastError.get();
verify( le );
le->reset();
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace mongo {
<< " { wtimeout:m} - timeout for w in m milliseconds";
}

bool run( const string& dbname,
bool run(TransactionExperiment* txn, const string& dbname,
BSONObj& cmdObj,
int,
string& errmsg,
Expand Down Expand Up @@ -262,7 +262,7 @@ namespace mongo {
const BSONObj& cmdObj,
std::vector<Privilege>* out) {} // No auth required
CmdGetPrevError() : Command("getPrevError", false, "getpreverror") {}
bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
LastError *le = lastError.disableForCommand();
le->appendSelf( result );
if ( le->valid )
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ namespace mongo {
return true;
}

bool run(const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
bool run(TransactionExperiment* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {

if ( !globalScriptEngine ) {
errmsg = "server-side JavaScript execution is disabled";
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/hashcmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace mongo {
*> "out" : NumberLong(6271151123721111923),
*> "ok" : 1 }
**/
bool run( const string& db,
bool run(TransactionExperiment* txn, const string& db,
BSONObj& cmdObj,
int options, string& errmsg,
BSONObjBuilder& result,
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/index_filter_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace mongo {
: Command(name),
helpText(helpText) { }

bool IndexFilterCommand::run(const string& dbname, BSONObj& cmdObj, int options,
bool IndexFilterCommand::run(TransactionExperiment* txn, const string& dbname, BSONObj& cmdObj, int options,
string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string ns = parseNs(dbname, cmdObj);

Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/index_filter_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace mongo {
* implement plan cache command functionality.
*/

bool run(const std::string& dbname, BSONObj& cmdObj, int options,
bool run(TransactionExperiment* txn, const std::string& dbname, BSONObj& cmdObj, int options,
std::string& errmsg, BSONObjBuilder& result, bool fromRepl);

virtual bool isWriteCommandForConfigServer() const;
Expand Down
Loading

0 comments on commit e3885ba

Please sign in to comment.