From 4aa3ad525c1012fe9e3dbcb6e0d79745a5446cf5 Mon Sep 17 00:00:00 2001 From: Haley Connelly Date: Fri, 27 Mar 2020 13:47:34 -0400 Subject: Revert "SERVER-46681 Integrate the ServerPingMonitor into the StreamableReplicaSetMonitor" This reverts commit 6694a0434f37db0d6671d05e37a54e78eb1f156b. --- src/mongo/client/server_ping_monitor.h | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/mongo/client/server_ping_monitor.h') diff --git a/src/mongo/client/server_ping_monitor.h b/src/mongo/client/server_ping_monitor.h index 80ebc8be95d..a7289a79d99 100644 --- a/src/mongo/client/server_ping_monitor.h +++ b/src/mongo/client/server_ping_monitor.h @@ -44,7 +44,7 @@ class SingleServerPingMonitor : public std::enable_shared_from_this executor); /** @@ -97,7 +97,7 @@ private: /** * The frequency at which ping requests should be sent to measure the round trip time. */ - Milliseconds _pingFrequency; + Seconds _pingFrequency; std::shared_ptr _executor; @@ -107,8 +107,6 @@ private: */ Date_t _nextPingStartDate{}; - static constexpr auto kLogLevel = 0; - /** * Must be held to access any of the member variables below. */ @@ -134,9 +132,14 @@ class ServerPingMonitor : public sdam::TopologyListener { ServerPingMonitor& operator=(const ServerPingMonitor&) = delete; public: - ServerPingMonitor(sdam::TopologyListener* rttListener, - Milliseconds pingFrequency, - std::shared_ptr executor); + /** + * Note: The ServerPingMonitor creates its own executor by default. It takes in an executor for + * testing only. + */ + ServerPingMonitor( + sdam::TopologyListener* rttListener, + Seconds pingFrequency, + boost::optional> executor = boost::none); ~ServerPingMonitor(); /** @@ -145,7 +148,7 @@ public: void shutdown(); /** - * The first isMaster exchange for a connection to the server succeeded. Creates a new + * The first isMaster exchange for a server succeeded. Creates a new * SingleServerPingMonitor to monitor the new replica set member. */ void onServerHandshakeCompleteEvent(sdam::IsMasterRTT durationMs, @@ -153,14 +156,15 @@ public: const BSONObj reply = BSONObj()); /** - * Drop corresponding SingleServerPingMonitors if the server is not included in the - * newDescritpion. + * The connection to the server was closed. Removes the server from the ServerPingMonitorList. */ - void onTopologyDescriptionChangedEvent(UUID topologyId, - sdam::TopologyDescriptionPtr previousDescription, - sdam::TopologyDescriptionPtr newDescription); + void onServerClosedEvent(const sdam::ServerAddress& address, OID topologyId); private: + /** + * Sets up and starts up the _executor if it did not already exist. + */ + void _setupTaskExecutor_inlock(); /** * Listens for when new RTT (Round Trip Time) values are published. */ @@ -169,15 +173,13 @@ private: /** * The interval at which ping requests should be sent to measure the RTT (Round Trip Time). */ - Milliseconds _pingFrequency; + Seconds _pingFrequency; /** * Executor for performing server monitoring pings for all of the replica set members. */ std::shared_ptr _executor; - static constexpr auto kLogLevel = 0; - mutable Mutex _mutex = MONGO_MAKE_LATCH("ServerPingMonitor::mutex"); /** -- cgit v1.2.1