From a4bc56e0ed623c46e954e88c4c4cea1356126217 Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Wed, 28 Oct 2015 17:50:50 -0400 Subject: SERVER-21186 Make catalog manager insert virtual --- src/mongo/client/replica_set_monitor.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/mongo/client/replica_set_monitor.cpp') diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp index bd57fdacea1..aa3151d789f 100644 --- a/src/mongo/client/replica_set_monitor.cpp +++ b/src/mongo/client/replica_set_monitor.cpp @@ -74,6 +74,9 @@ typedef SetState::Nodes Nodes; const double socketTimeoutSecs = 5; +// Intentionally chosen to compare worse than all known latencies. +const int64_t unknownLatency = numeric_limits::max(); + // TODO: Move to ReplicaSetMonitorManager ReplicaSetMonitor::ConfigChangeHook asyncConfigChangeHook; ReplicaSetMonitor::ConfigChangeHook syncConfigChangeHook; @@ -196,6 +199,7 @@ StaticObserver staticObserver; bool isMaster(const Node& node) { return node.isMaster; } + bool compareLatencies(const Node* lhs, const Node* rhs) { // NOTE: this automatically compares Node::unknownLatency worse than all others. return lhs->latencyMicros < rhs->latencyMicros; @@ -249,6 +253,7 @@ struct HostNotIn { } const std::set& _hosts; }; + } // namespace // At 1 check every 10 seconds, 30 checks takes 5 minutes @@ -795,7 +800,12 @@ void IsMasterReply::parse(const BSONObj& obj) { } } -const int64_t Node::unknownLatency = numeric_limits::max(); +Node::Node(const HostAndPort& host) : host(host), latencyMicros(unknownLatency) {} + +void Node::markFailed() { + isUp = false; + isMaster = false; +} bool Node::matches(const ReadPreference pref) const { if (!isUp) -- cgit v1.2.1