|
MongoDB
2.1.1-pre-
|
This is a connection to a cluster of servers that operate as one for super high durability. More...
#include <syncclusterconnection.h>
Public Member Functions | |
| SyncClusterConnection (const list< HostAndPort > &, double socketTimeout=0) | |
| SyncClusterConnection (string commaSeparated, double socketTimeout=0) | |
| SyncClusterConnection (string a, string b, string c, double socketTimeout=0) | |
| bool | prepare (string &errmsg) |
| bool | fsync (string &errmsg) |
| runs fsync on all servers | |
| virtual BSONObj | findOne (const string &ns, const Query &query, const BSONObj *fieldsToReturn, int queryOptions) |
| virtual auto_ptr< DBClientCursor > | query (const string &ns, Query query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, int batchSize) |
| send a query to the database. | |
| virtual auto_ptr< DBClientCursor > | getMore (const string &ns, long long cursorId, int nToReturn, int options) |
| don't use this - called automatically by DBClientCursor for you | |
| 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 a vector of objects into the database | |
| virtual void | remove (const string &ns, Query query, bool justOne) |
| remove matching objects from the database | |
| virtual void | update (const string &ns, Query query, BSONObj obj, bool upsert, bool multi) |
| updates objects matching query | |
| virtual bool | call (Message &toSend, Message &response, bool assertOk, string *actualServer) |
| actualServer is set to the actual server where they call went if there was a choice (SlaveOk) | |
| virtual void | say (Message &toSend, bool isRetry=false, string *actualServer=0) |
| virtual void | sayPiggyBack (Message &toSend) |
| virtual void | killCursor (long long cursorID) |
| virtual string | getServerAddress () const |
| virtual bool | isFailed () const |
| virtual string | toString () |
| virtual BSONObj | getLastErrorDetailed (bool fsync=false, bool j=false, int w=0, int wtimeout=0) |
| Get error result from the last write operation (insert/update/delete) on this connection. | |
| virtual bool | callRead (Message &toSend, Message &response) |
|
virtual ConnectionString::ConnectionType | type () const |
| void | setAllSoTimeouts (double socketTimeout) |
| double | getSoTimeout () const |
| virtual bool | auth (const string &dbname, const string &username, const string &password_text, string &errmsg, bool digestPassword, Auth::Level *level=NULL) |
| Authorize access to a particular database. | |
| virtual bool | lazySupported () const |
This is a connection to a cluster of servers that operate as one for super high durability.
Write operations are two-phase. First, all nodes are asked to fsync. If successful everywhere, the write is sent everywhere and then followed by an fsync. There is no rollback if a problem occurs during the second phase. Naturally, with all these fsyncs, these operations will be quite slow -- use sparingly.
Read operations are sent to a single random node.
The class checks if a command is read or write style, and sends to a single node if a read lock command and to all in two phases with a write style command.
| mongo::SyncClusterConnection::SyncClusterConnection | ( | const list< HostAndPort > & | L, |
| double | socketTimeout = 0 |
||
| ) |
| commaSeparated | should be 3 hosts comma separated |
| bool mongo::SyncClusterConnection::auth | ( | const string & | dbname, |
| const string & | username, | ||
| const string & | pwd, | ||
| string & | errmsg, | ||
| bool | digestPassword, | ||
| Auth::Level * | level = NULL |
||
| ) | [virtual] |
Authorize access to a particular database.
Authentication is separate for each database on the server -- you may authenticate for any number of databases on a single connection. The "admin" database is special and once authenticated provides access to all databases on the server.
| digestPassword | if password is plain text, set this to true. otherwise assumed to be pre-digested | |
| [out] | authLevel | level of authentication for the given user |
Reimplemented from mongo::DBClientWithCommands.
| BSONObj mongo::SyncClusterConnection::findOne | ( | const string & | ns, |
| const Query & | query, | ||
| const BSONObj * | fieldsToReturn, | ||
| int | queryOptions | ||
| ) | [virtual] |
| AssertionException |
Reimplemented from mongo::DBClientInterface.
| BSONObj mongo::SyncClusterConnection::getLastErrorDetailed | ( | bool | fsync = false, |
| bool | j = false, |
||
| int | w = 0, |
||
| int | wtimeout = 0 |
||
| ) | [virtual] |
Get error result from the last write operation (insert/update/delete) on this connection.
If "w" is -1, wait for propagation to majority of nodes. If "wtimeout" is 0, the operation will block indefinitely if needed.
Reimplemented from mongo::DBClientWithCommands.
| auto_ptr< DBClientCursor > mongo::SyncClusterConnection::getMore | ( | const string & | ns, |
| long long | cursorId, | ||
| int | nToReturn, | ||
| int | options | ||
| ) | [virtual] |
don't use this - called automatically by DBClientCursor for you
| cursorId | id of cursor to retrieve |
| AssertionException |
Reimplemented from mongo::DBClientBase.
| bool mongo::SyncClusterConnection::prepare | ( | string & | errmsg | ) |
| auto_ptr< DBClientCursor > mongo::SyncClusterConnection::query | ( | const string & | ns, |
| Query | query, | ||
| int | nToReturn, | ||
| int | nToSkip, | ||
| const BSONObj * | fieldsToReturn, | ||
| int | queryOptions, | ||
| int | batchSize | ||
| ) | [virtual] |
send a query to the database.
| ns | namespace to query, format is <dbname>.<collectname>[.<collectname>]* |
| query | query to perform on the collection. this is a BSONObj (binary JSON) You may format as { query: { ... }, orderby: { ... } } to specify a sort order. |
| nToReturn | n to return (i.e., limit). 0 = unlimited |
| nToSkip | start with the nth item |
| fieldsToReturn | optional template of which fields to select. if unspecified, returns all fields |
| queryOptions | see options enum at top of this file |
| AssertionException |
Reimplemented from mongo::DBClientBase.
| void mongo::SyncClusterConnection::remove | ( | const string & | ns, |
| Query | q, | ||
| bool | justOne | ||
| ) | [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