summaryrefslogtreecommitdiff
path: root/client/dbclient_rs.h
diff options
context:
space:
mode:
Diffstat (limited to 'client/dbclient_rs.h')
-rw-r--r--client/dbclient_rs.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/client/dbclient_rs.h b/client/dbclient_rs.h
index 91bde3b498c..0fc41aa8d0a 100644
--- a/client/dbclient_rs.h
+++ b/client/dbclient_rs.h
@@ -50,6 +50,14 @@ namespace mongo {
*/
void notifyFailure( const HostAndPort& server );
+ /** @return a random slave that is ok for reads */
+ HostAndPort getSlave();
+
+ /**
+ * notify the monitor that server has faild
+ */
+ void notifySlaveFailure( const HostAndPort& server );
+
string setName() const { return _name; }
string getServerAddress() const;
@@ -67,14 +75,20 @@ namespace mongo {
bool _checkConnection( DBClientConnection * c , string& maybePrimary , bool verbose );
int _find( const string& server ) const ;
+ int _find( const HostAndPort& server ) const ;
mutable mongo::mutex _lock; // protects _nodes
string _name;
struct Node {
- Node( const HostAndPort& a , DBClientConnection* c ) : addr( a ) , conn(c){}
+ Node( const HostAndPort& a , DBClientConnection* c ) : addr( a ) , conn(c) , ok(true){}
HostAndPort addr;
DBClientConnection* conn;
+
+ // if this node is in a failure state
+ // used for slave routing
+ // this is too simple, should make it better
+ bool ok;
};
vector<Node> _nodes;
@@ -170,12 +184,17 @@ namespace mongo {
private:
DBClientConnection * checkMaster();
- void _checkMaster();
+ DBClientConnection * checkSlave();
+
+ void _auth( DBClientConnection * conn );
ReplicaSetMonitorPtr _monitor;
HostAndPort _masterHost;
scoped_ptr<DBClientConnection> _master;
+
+ HostAndPort _slaveHost;
+ scoped_ptr<DBClientConnection> _slave;
/**
* for storing authentication info