mongo::SyncClusterConnection Class Reference

This is a connection to a cluster of servers that operate as one for super high durability. More...

#include <syncclusterconnection.h>

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

List of all members.

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< DBClientCursorquery (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< DBClientCursorgetMore (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)
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 ()
 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)
 Authorize access to a particular database.
virtual bool lazySupported () const

Detailed Description

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.


Constructor & Destructor Documentation

mongo::SyncClusterConnection::SyncClusterConnection ( const list< HostAndPort > &  L,
double  socketTimeout = 0 
)
Parameters:
commaSeparated should be 3 hosts comma separated

Member Function Documentation

bool mongo::SyncClusterConnection::auth ( const string &  dbname,
const string &  username,
const string &  pwd,
string &  errmsg,
bool  digestPassword 
) [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.

Parameters:
digestPassword if password is plain text, set this to true. otherwise assumed to be pre-digested
Returns:
true if successful

Reimplemented from mongo::DBClientWithCommands.

BSONObj mongo::SyncClusterConnection::findOne ( const string &  ns,
const Query query,
const BSONObj fieldsToReturn,
int  queryOptions 
) [virtual]
Returns:
a single object that matches the query. if none do, then the object is empty
Exceptions:
AssertionException 

Reimplemented from mongo::DBClientInterface.

BSONObj mongo::SyncClusterConnection::getLastErrorDetailed (  )  [virtual]

Get error result from the last write operation (insert/update/delete) on this connection.

Returns:
full error object.

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

Parameters:
cursorId id of cursor to retrieve
Returns:
an handle to a previously allocated cursor
Exceptions:
AssertionException 

Reimplemented from mongo::DBClientBase.

bool mongo::SyncClusterConnection::prepare ( string &  errmsg  ) 
Returns:
true if all servers are up and ready for writes
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.

Parameters:
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
Returns:
cursor. 0 if error (connection failure)
Exceptions:
AssertionException 

Reimplemented from mongo::DBClientBase.

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

remove matching objects from the database

Parameters:
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