}
}
+template<typename QueryPtrType>
+int
+HAService::getPendingRequest(const QueryPtrType& query) {
+ if (MultiThreadingMgr::instance().getMode()) {
+ std::lock_guard<std::mutex> lock(pending_requests_mutex_);
+ if (pending_requests_.count(query) == 0) {
+ return (0);
+ } else {
+ return (pending_requests_[query]);
+ }
+ } else {
+ if (pending_requests_.count(query) == 0) {
+ return (0);
+ } else {
+ return (pending_requests_[query]);
+ }
+ }
+}
+
+// Explicit instantiations.
+template int HAService::getPendingRequest(const Pkt4Ptr&);
+template int HAService::getPendingRequest(const Pkt6Ptr&);
+
} // end of namespace isc::ha
} // end of namespace isc
template<typename QueryPtrType>
void updatePendingRequest(QueryPtrType& query);
-protected:
/// @brief Get the number of entries in the pending request map.
/// @note Currently for testing purposes only.
/// @return Number of entries in the pending request map.
size_t pendingRequestSize();
+ /// @brief Get the number of scheduled requests for a given query.
+ /// @note Currently for testing purposes only.
+ ///
+ /// If there is an entry in the pending request map for the given
+ /// query the entry is returned else zero is returned.
+ ///
+ /// @param query Pointer to the DHCP client's query.
+ /// @return Number of scheduled requests for the query or zero.
+ template<typename QueryPtrType>
+ int getPendingRequest(const QueryPtrType& query);
+
private:
/// @brief Handle last pending request for this query.
///
using HAService::verboseTransition;
using HAService::shouldSendLeaseUpdates;
using HAService::pendingRequestSize;
+ using HAService::getPendingRequest;
using HAService::network_state_;
using HAService::config_;
using HAService::communication_state_;
service.asyncSendLeaseUpdates(query, leases4, deleted_leases4,
parking_lot_handle));
- if (num_updates == 0) {
- EXPECT_TRUE((service.pending_requests_.count(query) == 0) ||
- (service.pending_requests_[query] == 0));
- } else {
- // The number of pending requests should be 2 times the number of
- // contacted servers because we send one lease update and one
- // lease deletion to each contacted server from which we expect
- // an acknowledgment.
- EXPECT_EQ(2*num_updates, service.pending_requests_[query]);
- }
+ // The number of pending requests should be 2 times the number of
+ // contacted servers because we send one lease update and one
+ // lease deletion to each contacted server from which we expect
+ // an acknowledgment.
+ EXPECT_EQ(2*num_updates, service.getPendingRequest(query));
EXPECT_FALSE(state->isPoked());
service.asyncSendLeaseUpdates(query, leases6, deleted_leases6,
parking_lot_handle));
- if (num_updates == 0) {
- EXPECT_TRUE((service.pending_requests_.count(query) == 0) ||
- (service.pending_requests_[query] == 0));
- } else {
- // The number of requests we send is equal to the number of servers
- // from which we expect an acknowledgement. We send both lease updates
- // and the deletions in a single bulk update command.
- EXPECT_EQ(num_updates, service.pending_requests_[query]);
- }
+ // The number of requests we send is equal to the number of servers
+ // from which we expect an acknowledgement. We send both lease updates
+ // and the deletions in a single bulk update command.
+ EXPECT_EQ(num_updates, service.getPendingRequest(query));
EXPECT_FALSE(state->isPoked());