…lines 1–41 unchanged (41 lines)
42 auto it = _serverHelloReplies.find(hostAndPort);
43 if (it != _serverHelloReplies.end()) {
44 it->second.emplace_back(Status::OK());
45 } else {
46 _serverHelloReplies.emplace(hostAndPort, std::vector<Status>{Status::OK()});
47 }
48 ++_serverHeartbeatCounts.successes;
49}
50
51void TopologyListenerMock::onServerHeartbeatFailureEvent(Status errorStatus,
52 const HostAndPort& hostAndPort,
53 const BSONObj reply) {
54 stdx::lock_guard lk(_mutex);
55 // If the map already contains an element for hostAndPort, append to its already existing
56 // vector. Otherwise, create a new vector.
57 auto it = _serverHelloReplies.find(hostAndPort);
58 if (it != _serverHelloReplies.end()) {
59 it->second.emplace_back(errorStatus);
60 } else {
61 _serverHelloReplies.emplace(hostAndPort, std::vector<Status>{errorStatus});
62 }
63 ++_serverHeartbeatCounts.failures;
64}
65
66TopologyListenerMock::Counts TopologyListenerMock::serverHeartbeatCounts() const {
67 return _serverHeartbeatCounts;
68}
69
70bool TopologyListenerMock::hasHelloResponse(const HostAndPort& hostAndPort) {
71 stdx::lock_guard lock(_mutex);
72 return _hasHelloResponse(lock, hostAndPort);
73}
74
…lines 75–132 unchanged (58 lines)