mongo::DBClientReplicaSet Class Reference

Use this class to connect to a replica set of servers. More...

#include <dbclient_rs.h>

Inheritance diagram for mongo::DBClientReplicaSet:
mongo::DBClientBase mongo::DBClientWithCommands mongo::DBConnector mongo::DBClientInterface

List of all members.


struct  AuthInfo
 for storing authentication info fields are exactly for DBClientConnection::auth
class  LazyState
 for storing (non-threadsafe) information between lazy calls More...

Public Member Functions

 DBClientReplicaSet (const string &name, const vector< HostAndPort > &servers, double so_timeout=0)
 Call connect() after constructing.
bool connect ()
 Returns false if nomember of the set were reachable, or neither is master, although, when false returned, you can still try to use this connection object, it will try reconnects.
virtual bool auth (const string &dbname, const string &username, const string &pwd, string &errmsg, bool digestPassword=true)
virtual auto_ptr< DBClientCursorquery (const string &ns, Query query, int nToReturn=0, int nToSkip=0, const BSONObj *fieldsToReturn=0, int queryOptions=0, int batchSize=0)
 throws userassertion "no master found"
virtual BSONObj findOne (const string &ns, const Query &query, const BSONObj *fieldsToReturn=0, int queryOptions=0)
 throws userassertion "no master found"
virtual void insert (const string &ns, BSONObj obj, int flags=0)
 insert an object into the database
virtual void insert (const string &ns, const vector< BSONObj > &v, int flags=0)
 insert multiple objects.
virtual void remove (const string &ns, Query obj, bool justOne=0)
 remove matching objects from the database
virtual void update (const string &ns, Query query, BSONObj obj, bool upsert=0, bool multi=0)
 updates objects matching query
virtual void killCursor (long long cursorID)
DBClientConnectionmasterConn ()
DBClientConnectionslaveConn ()
virtual void say (Message &toSend, bool isRetry=false)
virtual bool recv (Message &toRecv)
virtual void checkResponse (const char *data, int nReturned, bool *retry=NULL, string *targetHost=NULL)
void isntMaster ()
void isntSecondary ()
virtual bool isFailed () const
double getSoTimeout () const
string toString ()
string getServerAddress () const
type () const
virtual bool lazySupported () const
virtual bool call (Message &toSend, Message &response, bool assertOk=true, string *actualServer=0)
 actualServer is set to the actual server where they call went if there was a choice (SlaveOk)
virtual bool callRead (Message &toSend, Message &response)

Protected Member Functions

virtual void sayPiggyBack (Message &toSend)

Protected Attributes

 for storing (non-threadsafe) information between lazy calls

Detailed Description

Use this class to connect to a replica set of servers.

The class will manage checking for which server in a replica set is master, and do failover automatically.

This can also be used to connect to replica pairs since pairs are a subset of sets

On a failover situation, expect at least one operation to return an error (throw an exception) before the failover is complete. Operations are not retried.

Constructor & Destructor Documentation

mongo::DBClientReplicaSet::DBClientReplicaSet ( const string &  name,
const vector< HostAndPort > &  servers,
double  so_timeout = 0 

Call connect() after constructing.

autoReconnect is always on for DBClientReplicaSet connections.

Member Function Documentation

bool mongo::DBClientReplicaSet::auth ( const string &  dbname,
const string &  username,
const string &  pwd,
string &  errmsg,
bool  digestPassword = true 
) [virtual]


Authorizes all nodes as needed

Reimplemented from mongo::DBClientWithCommands.

void mongo::DBClientReplicaSet::insert ( const string &  ns,
const vector< BSONObj > &  v,
int  flags = 0 
) [virtual]

insert multiple objects.

Note that single object insert is asynchronous, so this version is only nominally faster and not worth a special effort to try to use.

Reimplemented from mongo::DBClientBase.

void mongo::DBClientReplicaSet::remove ( const string &  ns,
Query  q,
bool  justOne = 0 
) [virtual]

remove matching objects from the database

justOne if this true, then once a single match is found will stop

Reimplemented from mongo::DBClientBase.

The documentation for this class was generated from the following files:
Generated on Wed Sep 14 01:46:41 2011 for MongoDB by  doxygen 1.6.3