mongo::ReplicaSetMonitor Class Reference

#include <dbclient_rs.h>

List of all members.

Classes

struct  Node

Public Types

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

Public Member Functions

void check ()
bool contains (const string &server) const
HostAndPort getMaster ()
string getName () const
string getServerAddress () const
HostAndPort getSlave ()
HostAndPort getSlave (const HostAndPort &prev)
void notifyFailure (const HostAndPort &server)
void notifySlaveFailure (const HostAndPort &server)
 ~ReplicaSetMonitor ()

Static Public Member Functions

static void checkAll ()
static ReplicaSetMonitorPtr get (const string &name, const vector< HostAndPort > &servers)
static void setConfigChangeHook (ConfigChangeHook hook)

Private Member Functions

void _check ()
bool _checkConnection (DBClientConnection *c, string &maybePrimary, bool verbose)
void _checkHosts (const BSONObj &hostList, bool &changed)
void _checkStatus (DBClientConnection *conn)
int _find (const HostAndPort &server) const
int _find (const string &server) const
 ReplicaSetMonitor (const string &name, const vector< HostAndPort > &servers)

Private Attributes

mongo::mutex _checkConnectionLock
mongo::mutex _lock
int _master
string _name
vector< Node_nodes

Static Private Attributes

static ConfigChangeHook _hook
static map< string,
ReplicaSetMonitorPtr
_sets
static mongo::mutex _setsLock

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

Definition at line 35 of file dbclient_rs.h.


Member Typedef Documentation

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

Definition at line 38 of file dbclient_rs.h.


Constructor & Destructor Documentation

mongo::ReplicaSetMonitor::~ReplicaSetMonitor (  ) 
mongo::ReplicaSetMonitor::ReplicaSetMonitor ( const string &  name,
const vector< HostAndPort > &  servers 
) [private]

This populates a list of hosts from the list of seeds (discarding the seed list).

Parameters:
name set name
servers seeds

Member Function Documentation

void mongo::ReplicaSetMonitor::_check (  )  [private]
bool mongo::ReplicaSetMonitor::_checkConnection ( DBClientConnection c,
string &  maybePrimary,
bool  verbose 
) [private]

Updates host list.

Parameters:
c the connection to check
maybePrimary OUT
verbose 
Returns:
if the connection is good
void mongo::ReplicaSetMonitor::_checkHosts ( const BSONObj hostList,
bool &  changed 
) [private]

Add array of hosts to host list. Doesn't do anything if hosts are already in host list.

Parameters:
hostList the list of hosts to add
changed if new hosts were added
void mongo::ReplicaSetMonitor::_checkStatus ( DBClientConnection conn  )  [private]

Use replSetGetStatus command to make sure hosts in host list are up and readable. Sets Node::ok appropriately.

int mongo::ReplicaSetMonitor::_find ( const HostAndPort server  )  const [private]
int mongo::ReplicaSetMonitor::_find ( const string &  server  )  const [private]
void mongo::ReplicaSetMonitor::check (  ) 

checks for current master and new secondaries

static void mongo::ReplicaSetMonitor::checkAll (  )  [static]

checks all sets for current master and new secondaries usually only called from a BackgroundJob

bool mongo::ReplicaSetMonitor::contains ( const string &  server  )  const
static ReplicaSetMonitorPtr mongo::ReplicaSetMonitor::get ( const string &  name,
const vector< HostAndPort > &  servers 
) [static]

gets a cached Monitor per name or will create if doesn't exist

HostAndPort mongo::ReplicaSetMonitor::getMaster (  ) 
Returns:
HostAndPort or throws an exception
string mongo::ReplicaSetMonitor::getName (  )  const [inline]

Definition at line 86 of file dbclient_rs.h.

string mongo::ReplicaSetMonitor::getServerAddress (  )  const
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
void mongo::ReplicaSetMonitor::notifyFailure ( const HostAndPort server  ) 

notify the monitor that server has faild

void mongo::ReplicaSetMonitor::notifySlaveFailure ( const HostAndPort server  ) 

notify the monitor that server has faild

static void mongo::ReplicaSetMonitor::setConfigChangeHook ( ConfigChangeHook  hook  )  [static]

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


Member Data Documentation

Definition at line 130 of file dbclient_rs.h.

Definition at line 155 of file dbclient_rs.h.

Definition at line 129 of file dbclient_rs.h.

Definition at line 149 of file dbclient_rs.h.

Definition at line 132 of file dbclient_rs.h.

Host list.

Definition at line 147 of file dbclient_rs.h.

Definition at line 153 of file dbclient_rs.h.

Definition at line 152 of file dbclient_rs.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


mongodb
Author(s): Nate Koenig
autogenerated on Fri Jan 11 12:15:57 2013