|
MongoDB
2.1.1-pre-
|
Use this class to connect to a replica set of servers. More...
#include <dbclient_rs.h>
Classes | |
| 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, Auth::Level *level=NULL) |
| Authorize. | |
| virtual auto_ptr< DBClientCursor > | query (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) |
| DBClientConnection & | masterConn () |
| DBClientConnection & | slaveConn () |
| virtual void | say (Message &toSend, bool isRetry=false, string *actualServer=0) |
| 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 |
|
virtual ConnectionString::ConnectionType | 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 | |
|
class mongo::DBClientReplicaSet::LazyState | _lazyState |
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.
| 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.
| bool mongo::DBClientReplicaSet::auth | ( | const string & | dbname, |
| const string & | username, | ||
| const string & | pwd, | ||
| string & | errmsg, | ||
| bool | digestPassword = true, |
||
| Auth::Level * | level = NULL |
||
| ) | [virtual] |
| 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.
1.8.0