diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-04-19 16:55:16 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-04-19 16:55:16 -0400 |
commit | 8afdf52bada2f435c9be70712e2589ee819b0b82 (patch) | |
tree | 79b4409936c8286c0cc2f46cbfac743380427a09 /s/config.h | |
parent | 00bd05e7506de1639e117a76cad0a5cd41ec5b8d (diff) | |
download | mongo-8afdf52bada2f435c9be70712e2589ee819b0b82.tar.gz |
Shard abstraction
Diffstat (limited to 's/config.h')
-rw-r--r-- | s/config.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/s/config.h b/s/config.h index 3b0dc4c1b50..9d6f73208db 100644 --- a/s/config.h +++ b/s/config.h @@ -27,6 +27,7 @@ #include "../client/dbclient.h" #include "../client/model.h" #include "shardkey.h" +#include "shard.h" namespace mongo { @@ -76,13 +77,12 @@ namespace mongo { /** * @return the correct for shard for the ns - * if the namespace is sharded, will return an empty string + * if the namespace is sharded, will return NULL */ - string getShard( const string& ns ); + const Shard& getShard( const string& ns ); - string getPrimary(){ - if ( _primary.size() == 0 ) - throw UserException( 8041 , (string)"no primary shard configured for db: " + _name ); + const Shard& getPrimary(){ + uassert( 8041 , (string)"no primary shard configured for db: " + _name , _primary.ok() ); return _primary; } @@ -116,7 +116,7 @@ namespace mongo { bool removeSharding( const string& ns ); string _name; // e.g. "alleyinsider" - string _primary; // e.g. localhost , mongo.foo.com:9999 + Shard _primary; // e.g. localhost , mongo.foo.com:9999 bool _shardingEnabled; map<string,CollectionInfo> _sharded; // { "alleyinsider.blog.posts" : { ts : 1 } , ... ] - all ns that are sharded @@ -162,11 +162,11 @@ namespace mongo { bool ok(){ // TODO: check can connect - return _primary.size() > 0; + return _primary.ok(); } virtual string modelServer(){ - uassert( 10190 , "ConfigServer not setup" , _primary.size() ); + uassert( 10190 , "ConfigServer not setup" , _primary.ok() ); return _primary; } |