MongoDB C++ Driver
legacy-1.1.2
|
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. | |
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.
|
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.
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.
|
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.
|
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()