mongo::ReplicaSetMonitor Class Reference

manages state about a replica set for client keeps tabs on whose master and what slaves are up can hand a slave to someone for SLAVE_OK one instace per process per replica set TODO: we might be able to use a regular Node * to avoid _lock More...

#include <dbclient_rs.h>

List of all members.

Classes

struct  Node

Public Types

typedef boost::function1< void,
const ReplicaSetMonitor * > 
ConfigChangeHook

Public Member Functions

HostAndPort getMaster ()
void notifyFailure (const HostAndPort &server)
 notify the monitor that server has faild
HostAndPort getSlave (const HostAndPort &prev)
HostAndPort getSlave ()
void notifySlaveFailure (const HostAndPort &server)
 notify the monitor that server has faild
void check ()
 checks for current master and new secondaries
string getName () const
string getServerAddress () const
bool contains (const string &server) const

Static Public Member Functions

static ReplicaSetMonitorPtr get (const string &name, const vector< HostAndPort > &servers)
 gets a cached Monitor per name or will create if doesn't exist
static void checkAll ()
 checks all sets for current master and new secondaries usually only called from a BackgroundJob
static void setConfigChangeHook (ConfigChangeHook hook)
 this is called whenever the config of any repclia set changes currently only 1 globally asserts if one already exists ownership passes to ReplicaSetMonitor and the hook will actually never be deleted

Detailed Description

manages state about a replica set for client keeps tabs on whose master and what slaves are up can hand a slave to someone for SLAVE_OK one instace per process per replica set TODO: we might be able to use a regular Node * to avoid _lock


Member Function Documentation

HostAndPort mongo::ReplicaSetMonitor::getMaster (  ) 
Returns:
HostAndPort or throws an exception
HostAndPort mongo::ReplicaSetMonitor::getSlave (  ) 
Returns:
a random slave that is ok for reads
HostAndPort mongo::ReplicaSetMonitor::getSlave ( const HostAndPort prev  ) 
Returns:
prev if its still ok, and if not returns a random slave that is ok for reads

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