MongoDB C++ Driver  legacy-1.1.2
Classes | Public Member Functions | Static Public Member Functions | List of all members
mongo::ReplicaSetMonitor::Refresher Class Reference

Refreshes the local view of a replica set. More...

#include <replica_set_monitor.h>

Classes

struct  NextStep
 

Public Member Functions

HostAndPort refreshUntilMatches (const ReadPreferenceSetting &criteria)
 Contact hosts in the set to refresh our view, but stop once a host matches criteria. More...
 
void refreshAll ()
 Refresh all hosts. More...
 
 Refresher (const SetStatePtr &setState)
 Any passed-in pointers are shared with caller. More...
 
NextStep getNextStep ()
 Returns the next step to take. More...
 
void receivedIsMaster (const HostAndPort &from, int64_t latencyMicros, const BSONObj &reply)
 Call this if a host returned from getNextStep successfully replied to an isMaster call. More...
 
void failedHost (const HostAndPort &host)
 Call this if a host returned from getNextStep failed to reply to an isMaster call.
 
bool startedNewScan () const
 True if this Refresher started a new full scan rather than joining an existing one.
 

Static Public Member Functions

static ScanStatePtr startNewScan (const SetState *set)
 Starts a new scan over the hosts in set.
 

Detailed Description

Refreshes the local view of a replica set.

Use ReplicaSetMonitor::startOrContinueRefresh() to obtain a Refresher.

Multiple threads can refresh a single set without any additional synchronization, however they must each use their own Refresher object.

All logic related to choosing the hosts to contact and updating the SetState based on replies lives in this class.

Constructor & Destructor Documentation

mongo::ReplicaSetMonitor::Refresher::Refresher ( const SetStatePtr &  setState)
explicit

Any passed-in pointers are shared with caller.

If no scan is in-progress, this function is responsible for setting up a new scan.

Member Function Documentation

NextStep mongo::ReplicaSetMonitor::Refresher::getNextStep ( )

Returns the next step to take.

By calling this, you promise to call receivedIsMaster or failedHost if the NextStep is CONTACT_HOST.

void mongo::ReplicaSetMonitor::Refresher::receivedIsMaster ( const HostAndPort from,
int64_t  latencyMicros,
const BSONObj reply 
)

Call this if a host returned from getNextStep successfully replied to an isMaster call.

Negative latencyMicros are ignored.

void mongo::ReplicaSetMonitor::Refresher::refreshAll ( )
inline

Refresh all hosts.

Equivalent to refreshUntilMatches with a criteria that never matches.

This is intended to be called periodically, possibly from a background thread.

HostAndPort mongo::ReplicaSetMonitor::Refresher::refreshUntilMatches ( const ReadPreferenceSetting criteria)
inline

Contact hosts in the set to refresh our view, but stop once a host matches criteria.

Returns the matching host or empty if none match after a refresh.

This is called by ReplicaSetMonitor::getHostWithRefresh()


The documentation for this class was generated from the following file: