Skip to content

Commit

Permalink
some public accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Feb 12, 2011
1 parent 0196f01 commit f4f7cec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
24 changes: 10 additions & 14 deletions client/dbclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ namespace mongo {
public:
enum ConnectionType { INVALID , MASTER , PAIR , SET , SYNC };

ConnectionString() {
_type = INVALID;
}

ConnectionString( const HostAndPort& server ) {
_type = MASTER;
_servers.push_back( server );
Expand Down Expand Up @@ -163,30 +167,22 @@ namespace mongo {

bool isValid() const { return _type != INVALID; }

string toString() const {
return _string;
}

string toString() const { return _string; }

DBClientBase* connect( string& errmsg ) const;

string getSetName() const {
return _setName;
}
string getSetName() const { return _setName; }

vector<HostAndPort> getServers() const {
return _servers;
}
vector<HostAndPort> getServers() const { return _servers; }

ConnectionType type() const { return _type; }

static ConnectionString parse( const string& url , string& errmsg );

static string typeToString( ConnectionType type );

private:

ConnectionString() {
_type = INVALID;
}

void _fillServers( string s ) {
string::size_type idx;
while ( ( idx = s.find( ',' ) ) != string::npos ) {
Expand Down
12 changes: 11 additions & 1 deletion client/dbclient_rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace mongo {
massert( 13610 , "ConfigChangeHook already specified" , _hook == 0 );
_hook = hook;
}

string ReplicaSetMonitor::getServerAddress() const {
StringBuilder ss;
if ( _name.size() )
Expand All @@ -137,6 +137,16 @@ namespace mongo {
return ss.str();
}

bool ReplicaSetMonitor::contains( const string& server ) const {
scoped_lock lk( _lock );
for ( unsigned i=0; i<_nodes.size(); i++ ) {
if ( _nodes[i].addr == server )
return true;
}
return false;
}


void ReplicaSetMonitor::notifyFailure( const HostAndPort& server ) {
if ( _master >= 0 ) {
scoped_lock lk( _lock );
Expand Down
2 changes: 2 additions & 0 deletions client/dbclient_rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ namespace mongo {
string getName() const { return _name; }

string getServerAddress() const;

bool contains( const string& server ) const;

private:
/**
Expand Down

0 comments on commit f4f7cec

Please sign in to comment.