diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-08-05 10:42:01 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-08-05 10:42:01 -0400 |
commit | a30b27a87322addd9d9be9543fa318c8bedc4c07 (patch) | |
tree | cc3f5b0045881cee28243ccc24bd4507c7a50178 /s | |
parent | a3f80b90b2bcf4551046024061702cf70e43b348 (diff) | |
download | mongo-a30b27a87322addd9d9be9543fa318c8bedc4c07.tar.gz |
make sure initial set config in shards is correct SERVER-3333
Diffstat (limited to 's')
-rw-r--r-- | s/grid.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/s/grid.cpp b/s/grid.cpp index 6141e061be6..97a04a6dc49 100644 --- a/s/grid.cpp +++ b/s/grid.cpp @@ -125,6 +125,8 @@ namespace mongo { name = &nameInternal; } + ReplicaSetMonitorPtr rsMonitor; + // Check whether the host (or set) exists and run several sanity checks on this request. // There are two set of sanity checks: making sure adding this particular shard is consistent // with the replica set state (if it exists) and making sure this shards databases can be @@ -140,7 +142,7 @@ namespace mongo { errMsg = "can't use sync cluster as a shard. for replica set, have to use <setname>/<server1>,<server2>,..."; return false; } - + BSONObj resIsMongos; bool ok = newShardConn->runCommand( "admin" , BSON( "isdbgrid" << 1 ) , resIsMongos ); @@ -264,6 +266,9 @@ namespace mongo { } } + if ( newShardConn->type() == ConnectionString::SET ) + rsMonitor = ReplicaSetMonitor::get( setName ); + newShardConn.done(); } catch ( DBException& e ) { @@ -295,7 +300,7 @@ namespace mongo { // build the ConfigDB shard document BSONObjBuilder b; b.append( "_id" , *name ); - b.append( "host" , servers.toString() ); + b.append( "host" , rsMonitor ? rsMonitor->getServerAddress() : servers.toString() ); if ( maxSize > 0 ) { b.append( ShardFields::maxSize.name() , maxSize ); } |