diff options
author | Alberto Lerner <alerner@10gen.com> | 2010-07-16 11:49:40 -0400 |
---|---|---|
committer | Alberto Lerner <alerner@10gen.com> | 2010-07-16 11:49:40 -0400 |
commit | 2ea2bb00d639684f6ec40d690f4b0147b4b7eb8c (patch) | |
tree | 836d9e5fa038571a3cf82452ee1d11be1c49abce | |
parent | 86c01b838c12b4ca7f794b0df2a57e3a00315838 (diff) | |
download | mongo-2ea2bb00d639684f6ec40d690f4b0147b4b7eb8c.tar.gz |
SERVER-1353 removeShard takes shard name as well
-rw-r--r-- | jstests/slowNightly/sharding_balance1.js | 3 | ||||
-rw-r--r-- | s/commands_admin.cpp | 21 |
2 files changed, 12 insertions, 12 deletions
diff --git a/jstests/slowNightly/sharding_balance1.js b/jstests/slowNightly/sharding_balance1.js index d56c2a31c01..66b1563e177 100644 --- a/jstests/slowNightly/sharding_balance1.js +++ b/jstests/slowNightly/sharding_balance1.js @@ -44,8 +44,7 @@ assert.soon( function(){ } , "balance didn't happen" , 1000 * 60 * 3 , 5000 ); var chunkCount = sum(); -host = s.config.shards.findOne({_id : "shard0" }).host; -s.adminCommand( { removeshard: host } ); +s.adminCommand( { removeshard: "shard0" } ); assert.soon( function(){ printjson(s.chunkCounts( "foo" )); diff --git a/s/commands_admin.cpp b/s/commands_admin.cpp index b6b060da318..3fcb7a5eeac 100644 --- a/s/commands_admin.cpp +++ b/s/commands_admin.cpp @@ -708,8 +708,9 @@ namespace mongo { help << "remove a shard to the system."; } bool run(const string& , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){ - string shard = cmdObj.firstElement().valuestrsafe(); - if ( ! grid.knowAboutShard( shard ) ){ + string target = cmdObj.firstElement().valuestrsafe(); + Shard s = Shard::make( target ); + if ( ! grid.knowAboutShard( s.getConnString() ) ){ errmsg = "unknown shard"; return false; } @@ -717,20 +718,20 @@ namespace mongo { ScopedDbConnection conn( configServer.getPrimary() ); // If the server is not yet draining chunks, put it in draining mode. - BSONObj searchDoc = BSON( "host" << shard ); - BSONObj drainingDoc = BSON( "host" << shard << ShardFields::draining(true) ); + BSONObj searchDoc = BSON( "_id" << s.getName() ); + BSONObj drainingDoc = BSON( "_id" << s.getName() << ShardFields::draining(true) ); BSONObj shardDoc = conn->findOne( "config.shards", drainingDoc ); if ( shardDoc.isEmpty() ){ // TODO prevent move chunks to this shard. - log() << "going to start draining shard: " << shard << endl; + log() << "going to start draining shard: " << s.getName() << endl; BSONObj newStatus = BSON( "$set" << BSON( ShardFields::draining(true) ) ); conn->update( "config.shards" , searchDoc , newStatus, false /* do no upsert */); errmsg = conn->getLastError(); if ( errmsg.size() ){ - log() << "error starting remove shard: " << shard << " err: " << errmsg << endl; + log() << "error starting remove shard: " << s.getName() << " err: " << errmsg << endl; return false; } @@ -738,7 +739,7 @@ namespace mongo { result.append( "msg" , "draining started successfully" ); result.append( "state" , "started" ); - result.append( "shard" , shard ); + result.append( "shard" , s.getName() ); conn.done(); return true; } @@ -750,12 +751,12 @@ namespace mongo { BSONObj primaryDoc = BSON( "primary" << shardDoc[ "_id" ].str() ); long long dbCount = conn->count( "config.databases" , primaryDoc ); if ( ( chunkCount == 0 ) && ( dbCount == 0 ) ){ - log() << "going to remove shard: " << shard << endl; + log() << "going to remove shard: " << s.getName() << endl; conn->remove( "config.shards" , searchDoc ); errmsg = conn->getLastError(); if ( errmsg.size() ){ - log() << "error concluding remove shard: " << shard << " err: " << errmsg << endl; + log() << "error concluding remove shard: " << s.getName() << " err: " << errmsg << endl; return false; } @@ -764,7 +765,7 @@ namespace mongo { result.append( "msg" , "removeshard completed successfully" ); result.append( "state" , "completed" ); - result.append( "shard" , shard ); + result.append( "shard" , s.getName() ); conn.done(); return true; } |