From 8afdf52bada2f435c9be70712e2589ee819b0b82 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 19 Apr 2010 16:55:16 -0400 Subject: Shard abstraction --- s/config.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 's/config.h') 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 _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; } -- cgit v1.2.1