Skip to content

Commit

Permalink
allow arbiters and passives as seeds SERVER-2547
Browse files Browse the repository at this point in the history
  • Loading branch information
kchodorow committed Apr 12, 2011
1 parent 41631ef commit 1c9e34b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
18 changes: 17 additions & 1 deletion jstests/sharding/addshard4.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ config.members[2].priority = 0;

r.initiate(config);

var master = r.getMaster().master;
var master = r.getMaster();

var members = config.members.map(function(elem) { return elem.host; });
var shardName = "addshard4/"+members.join(",");
Expand All @@ -20,5 +20,21 @@ print("adding shard "+shardName);
var result = s.adminCommand({"addshard" : shardName});

printjson(result);
assert.eq(result, true);

r = new ReplSetTest({name : "addshard42", nodes : 3, startPort : 36000});
r.startSet();

config = r.getReplSetConfig();
config.members[2].arbiterOnly = true;

r.initiate(config);

master = r.getMaster();

print("adding shard addshard42");

result = s.adminCommand({"addshard" : "addshard42/"+config.members[2].host});

printjson(result);
assert.eq(result, true);
8 changes: 7 additions & 1 deletion s/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ namespace mongo {
hostSet.insert( piter.next().String() ); // host:port
}
}
if ( resIsMaster["arbiters"].isABSONObj() ) {
BSONObjIterator piter( resIsMaster["arbiters"].Obj() );
while ( piter.more() ) {
hostSet.insert( piter.next().String() ); // host:port
}
}

vector<HostAndPort> hosts = servers.getServers();
for ( size_t i = 0 ; i < hosts.size() ; i++ ) {
Expand All @@ -213,7 +219,7 @@ namespace mongo {
}
if ( ! foundAll ) {
ostringstream ss;
ss << "host " << offendingHost << " does not belong to replica set as a non-passive member" << setName;;
ss << "host " << offendingHost << " does not belong to replica set" << setName;;
errMsg = ss.str();
newShardConn.done();
return false;
Expand Down

0 comments on commit 1c9e34b

Please sign in to comment.