summaryrefslogtreecommitdiff
path: root/client/dbclient.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-02-14 14:13:06 -0500
committerEliot Horowitz <eliot@10gen.com>2011-02-14 14:13:19 -0500
commita969a0168cdb23c8cfa0fbcb26a92d0cabebf411 (patch)
treee4a58f38f862bb65e4678ae2fcd63325d6725b06 /client/dbclient.h
parent91c51c6507562fbbccea49120e0845d4ef1a15f8 (diff)
downloadmongo-a969a0168cdb23c8cfa0fbcb26a92d0cabebf411.tar.gz
add ConnectionString and add a test
Diffstat (limited to 'client/dbclient.h')
-rw-r--r--client/dbclient.h31
1 files changed, 9 insertions, 22 deletions
diff --git a/client/dbclient.h b/client/dbclient.h
index ace3dd4d783..9cb6571ca85 100644
--- a/client/dbclient.h
+++ b/client/dbclient.h
@@ -154,13 +154,18 @@ namespace mongo {
}
ConnectionString( const string& s , ConnectionType favoredMultipleType ) {
+ _type = INVALID;
+
_fillServers( s );
- if ( _servers.size() == 1 ) {
+ if ( _type != INVALID ) {
+ // set already
+ }
+ else if ( _servers.size() == 1 ) {
_type = MASTER;
}
else {
_type = favoredMultipleType;
- assert( _type != MASTER );
+ assert( _type == SET || _type == SYNC );
}
_finishInit();
}
@@ -183,26 +188,8 @@ namespace mongo {
private:
- void _fillServers( string s ) {
- string::size_type idx;
- while ( ( idx = s.find( ',' ) ) != string::npos ) {
- _servers.push_back( s.substr( 0 , idx ) );
- s = s.substr( idx + 1 );
- }
- _servers.push_back( s );
- }
-
- void _finishInit() {
- stringstream ss;
- if ( _type == SET )
- ss << _setName << "/";
- for ( unsigned i=0; i<_servers.size(); i++ ) {
- if ( i > 0 )
- ss << ",";
- ss << _servers[i].toString();
- }
- _string = ss.str();
- }
+ void _fillServers( string s );
+ void _finishInit();
ConnectionType _type;
vector<HostAndPort> _servers;