summaryrefslogtreecommitdiff
path: root/src/mongo/client/server_ping_monitor.h
diff options
context:
space:
mode:
authorHaley Connelly <haley.connelly@mongodb.com>2020-03-27 13:47:34 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-27 18:02:58 +0000
commit4aa3ad525c1012fe9e3dbcb6e0d79745a5446cf5 (patch)
treec1b973f50c9aa9b734a1d643b692515413a7cd98 /src/mongo/client/server_ping_monitor.h
parentfb09428156a33be70d30452fb3bb91f73be94ee7 (diff)
downloadmongo-4aa3ad525c1012fe9e3dbcb6e0d79745a5446cf5.tar.gz
Revert "SERVER-46681 Integrate the ServerPingMonitor into the StreamableReplicaSetMonitor"
This reverts commit 6694a0434f37db0d6671d05e37a54e78eb1f156b.
Diffstat (limited to 'src/mongo/client/server_ping_monitor.h')
-rw-r--r--src/mongo/client/server_ping_monitor.h34
1 files changed, 18 insertions, 16 deletions
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<SingleServer
public:
explicit SingleServerPingMonitor(sdam::ServerAddress hostAndPort,
sdam::TopologyListener* rttListener,
- Milliseconds pingFrequency,
+ Seconds pingFrequency,
std::shared_ptr<executor::TaskExecutor> 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::TaskExecutor> _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::TaskExecutor> 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<std::shared_ptr<executor::TaskExecutor>> 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,15 +156,16 @@ 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.
*/
sdam::TopologyListener* _rttListener;
@@ -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::TaskExecutor> _executor;
- static constexpr auto kLogLevel = 0;
-
mutable Mutex _mutex = MONGO_MAKE_LATCH("ServerPingMonitor::mutex");
/**