diff options
| author | Marcin Siodelski <marcin@isc.org> | 2022-09-16 12:28:26 +0200 |
|---|---|---|
| committer | Marcin Siodelski <marcin@isc.org> | 2022-09-22 15:26:49 +0200 |
| commit | 8d073a06dd3ad504ffea85f80dee75305851bcab (patch) | |
| tree | 099137c00ce040dd474f786bf90e48192d95659e | |
| parent | 89d2727478e5b7990fae2b849f8490fa8bc489dd (diff) | |
[#2408] Rename new communication state functions
5 files changed, 61 insertions, 61 deletions
diff --git a/src/hooks/dhcp/high_availability/communication_state.cc b/src/hooks/dhcp/high_availability/communication_state.cc index ce0d7ca4a6..60bccca80d 100644 --- a/src/hooks/dhcp/high_availability/communication_state.cc +++ b/src/hooks/dhcp/high_availability/communication_state.cc @@ -676,12 +676,12 @@ CommunicationState4::clearConnectingClients() { } size_t -CommunicationState4::getRejectedLeasesCount() const { +CommunicationState4::getRejectedLeaseUpdatesCount() const { return (rejected_clients_.size()); } bool -CommunicationState4::reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& message) { +CommunicationState4::reportRejectedLeaseUpdate(const boost::shared_ptr<dhcp::Pkt>& message) { Pkt4Ptr msg = boost::dynamic_pointer_cast<Pkt4>(message); if (!msg) { isc_throw(BadValue, "DHCP message for which the lease update was rejected is not a DHCPv4 message"); @@ -702,7 +702,7 @@ CommunicationState4::reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& mes } void -CommunicationState4::clearRejectedLeases() { +CommunicationState4::clearRejectedLeaseUpdates() { rejected_clients_.clear(); } @@ -834,12 +834,12 @@ CommunicationState6::clearConnectingClients() { } size_t -CommunicationState6::getRejectedLeasesCount() const { +CommunicationState6::getRejectedLeaseUpdatesCount() const { return (rejected_clients_.size()); } bool -CommunicationState6::reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& message) { +CommunicationState6::reportRejectedLeaseUpdate(const boost::shared_ptr<dhcp::Pkt>& message) { Pkt6Ptr msg = boost::dynamic_pointer_cast<Pkt6>(message); if (!msg) { isc_throw(BadValue, "DHCP message for which the lease update was rejected is not a DHCPv6 message"); @@ -859,7 +859,7 @@ CommunicationState6::reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& mes } void -CommunicationState6::clearRejectedLeases() { +CommunicationState6::clearRejectedLeaseUpdates() { rejected_clients_.clear(); } diff --git a/src/hooks/dhcp/high_availability/communication_state.h b/src/hooks/dhcp/high_availability/communication_state.h index 840c1ff488..3229d1aba6 100644 --- a/src/hooks/dhcp/high_availability/communication_state.h +++ b/src/hooks/dhcp/high_availability/communication_state.h @@ -286,13 +286,13 @@ protected: public: - /// @brief Returns the number of distinct leases sent to and rejected - /// by the partner. + /// @brief Returns the number of lease updates rejected by the partner. /// - /// Each rejected lease is counted only once if it failed multiple times + /// Each rejected lease update is counted only once if it failed + /// multiple times /// - /// @return Current rejected client leases number count. - virtual size_t getRejectedLeasesCount() const = 0; + /// @return Current rejected lease update number count. + virtual size_t getRejectedLeaseUpdatesCount() const = 0; /// @brief Marks that the lease update failed due to a conflict for the /// specified DHCP message. @@ -302,12 +302,12 @@ public: /// /// @param message DHCP message for which a lease update failed due to /// a conflict. - /// @return true if the lease was rejected for the first time, false + /// @return true if the update was rejected for the first time, false /// otherwise. - virtual bool reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& message) = 0; + virtual bool reportRejectedLeaseUpdate(const boost::shared_ptr<dhcp::Pkt>& message) = 0; /// @brief Clears rejected client leases. - virtual void clearRejectedLeases() = 0; + virtual void clearRejectedLeaseUpdates() = 0; /// @brief Issues a warning about high clock skew between the active /// servers if one is warranted. @@ -670,13 +670,13 @@ public: /// @return Number of unacked clients. virtual size_t getUnackedClientsCount() const; - /// @brief Returns the number of distinct leases sent to and rejected - /// by the partner. + /// @brief Returns the number of lease updates rejected by the partner. /// - /// Each rejected lease is counted only once if it failed multiple times + /// Each rejected lease update is counted only once if it failed + /// multiple times /// - /// @return Current rejected client leases number count. - virtual size_t getRejectedLeasesCount() const; + /// @return Current rejected lease update number count. + virtual size_t getRejectedLeaseUpdatesCount() const; /// @brief Marks that the lease update failed due to a conflict for the /// specified DHCP message. @@ -686,12 +686,12 @@ public: /// /// @param message DHCP message for which a lease update failed due to /// a conflict. - /// @return true if the lease was rejected for the first time, false + /// @return true if the update was rejected for the first time, false /// otherwise. - virtual bool reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& message); + virtual bool reportRejectedLeaseUpdate(const boost::shared_ptr<dhcp::Pkt>& message); /// @brief Clears rejected client leases. - virtual void clearRejectedLeases(); + virtual void clearRejectedLeaseUpdates(); protected: @@ -849,13 +849,13 @@ public: /// @return Number of unacked clients. virtual size_t getUnackedClientsCount() const; - /// @brief Returns the number of distinct leases sent to and rejected - /// by the partner. + /// @brief Returns the number of lease updates rejected by the partner. /// - /// Each rejected lease is counted only once if it failed multiple times + /// Each rejected lease update is counted only once if it failed + /// multiple times /// - /// @return Current rejected client leases number count. - virtual size_t getRejectedLeasesCount() const; + /// @return Current rejected lease update number count. + virtual size_t getRejectedLeaseUpdatesCount() const; /// @brief Marks that the lease update failed due to a conflict for the /// specified DHCP message. @@ -865,12 +865,12 @@ public: /// /// @param message DHCP message for which a lease update failed due to /// a conflict. - /// @return true if the lease was rejected for the first time, false + /// @return true if the update was rejected for the first time, false /// otherwise. - virtual bool reportRejectedLease(const boost::shared_ptr<dhcp::Pkt>& message); + virtual bool reportRejectedLeaseUpdate(const boost::shared_ptr<dhcp::Pkt>& message); /// @brief Clears rejected client leases. - virtual void clearRejectedLeases(); + virtual void clearRejectedLeaseUpdates(); protected: diff --git a/src/hooks/dhcp/high_availability/ha_service.cc b/src/hooks/dhcp/high_availability/ha_service.cc index c12f04704d..ff99aba466 100644 --- a/src/hooks/dhcp/high_availability/ha_service.cc +++ b/src/hooks/dhcp/high_availability/ha_service.cc @@ -481,7 +481,7 @@ HAService::partnerDownStateHandler() { query_filter_.serveDefaultScopes(); } adjustNetworkState(); - communication_state_->clearRejectedLeases(); + communication_state_->clearRejectedLeaseUpdates(); // Log if the state machine is paused. conditionalLogPausedState(); @@ -616,7 +616,7 @@ HAService::readyStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); - communication_state_->clearRejectedLeases(); + communication_state_->clearRejectedLeaseUpdates(); // Log if the state machine is paused. conditionalLogPausedState(); @@ -696,7 +696,7 @@ HAService::syncingStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); - communication_state_->clearRejectedLeases(); + communication_state_->clearRejectedLeaseUpdates(); // Log if the state machine is paused. conditionalLogPausedState(); @@ -786,7 +786,7 @@ HAService::terminatedStateHandler() { if (doOnEntry()) { query_filter_.serveDefaultScopes(); adjustNetworkState(); - communication_state_->clearRejectedLeases(); + communication_state_->clearRejectedLeaseUpdates(); // In the terminated state we don't send heartbeat. communication_state_->stopHeartbeat(); @@ -808,7 +808,7 @@ HAService::waitingStateHandler() { if (doOnEntry()) { query_filter_.serveNoScopes(); adjustNetworkState(); - communication_state_->clearRejectedLeases(); + communication_state_->clearRejectedLeaseUpdates(); // Log if the state machine is paused. conditionalLogPausedState(); @@ -1117,7 +1117,7 @@ HAService::shouldTerminate() const { // has been exceeded. should_terminate = config_->getMaxRejectedClients() && - (config_->getMaxRejectedClients() <= communication_state_->getRejectedLeasesCount()); + (config_->getMaxRejectedClients() <= communication_state_->getRejectedLeaseUpdatesCount()); } return (should_terminate); @@ -1415,7 +1415,7 @@ HAService::asyncSendLeaseUpdate(const QueryPtrType& query, // Handle forth group of errors. lease_update_conflict = true; lease_update_success = false; - communication_state_->reportRejectedLease(query); + communication_state_->reportRejectedLeaseUpdate(query); LOG_WARN(ha_logger, HA_LEASE_UPDATE_CONFLICT) .arg(query->getLabel()) diff --git a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc index 2cc0fc7faa..4ae8cd4d79 100644 --- a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc @@ -702,21 +702,21 @@ CommunicationStateTest::hasPartnerNewUnsentUpdatesTest() { void CommunicationStateTest::reportRejectedLeasesV4Test() { - EXPECT_EQ(0, state_.getRejectedLeasesCount()); + EXPECT_EQ(0, state_.getRejectedLeaseUpdatesCount()); auto msg = createMessage4(DHCPREQUEST, 1, 0, 0); - state_.reportRejectedLease(msg); - EXPECT_EQ(1, state_.getRejectedLeasesCount()); + state_.reportRejectedLeaseUpdate(msg); + EXPECT_EQ(1, state_.getRejectedLeaseUpdatesCount()); msg = createMessage4(DHCPREQUEST, 2, 0, 0); - state_.reportRejectedLease(msg); - EXPECT_EQ(2, state_.getRejectedLeasesCount()); + state_.reportRejectedLeaseUpdate(msg); + EXPECT_EQ(2, state_.getRejectedLeaseUpdatesCount()); msg = createMessage4(DHCPREQUEST, 2, 0, 0); - state_.reportRejectedLease(msg); - EXPECT_EQ(2, state_.getRejectedLeasesCount()); + state_.reportRejectedLeaseUpdate(msg); + EXPECT_EQ(2, state_.getRejectedLeaseUpdatesCount()); - state_.clearRejectedLeases(); - EXPECT_EQ(0, state_.getRejectedLeasesCount()); + state_.clearRejectedLeaseUpdates(); + EXPECT_EQ(0, state_.getRejectedLeaseUpdatesCount()); } void @@ -724,26 +724,26 @@ CommunicationStateTest::reportRejectedLeasesV4InvalidValuesTest() { // Using DHCPv6 message in the DHCPv4 context is a programming // error and deserves an exception. auto msg = createMessage6(DHCPV6_REQUEST, 1, 0); - EXPECT_THROW(state_.reportRejectedLease(msg), BadValue); + EXPECT_THROW(state_.reportRejectedLeaseUpdate(msg), BadValue); } void CommunicationStateTest::reportRejectedLeasesV6Test() { - EXPECT_EQ(0, state6_.getRejectedLeasesCount()); + EXPECT_EQ(0, state6_.getRejectedLeaseUpdatesCount()); auto msg = createMessage6(DHCPV6_SOLICIT, 1, 0); - state6_.reportRejectedLease(msg); - EXPECT_EQ(1, state6_.getRejectedLeasesCount()); + state6_.reportRejectedLeaseUpdate(msg); + EXPECT_EQ(1, state6_.getRejectedLeaseUpdatesCount()); msg = createMessage6(DHCPV6_SOLICIT, 2, 0); - state6_.reportRejectedLease(msg); - EXPECT_EQ(2, state6_.getRejectedLeasesCount()); + state6_.reportRejectedLeaseUpdate(msg); + EXPECT_EQ(2, state6_.getRejectedLeaseUpdatesCount()); msg = createMessage6(DHCPV6_SOLICIT, 2, 0); - state6_.reportRejectedLease(msg); - EXPECT_EQ(2, state6_.getRejectedLeasesCount()); + state6_.reportRejectedLeaseUpdate(msg); + EXPECT_EQ(2, state6_.getRejectedLeaseUpdatesCount()); - state6_.clearRejectedLeases(); - EXPECT_EQ(0, state6_.getRejectedLeasesCount()); + state6_.clearRejectedLeaseUpdates(); + EXPECT_EQ(0, state6_.getRejectedLeaseUpdatesCount()); } void @@ -751,11 +751,11 @@ CommunicationStateTest::reportRejectedLeasesV6InvalidValuesTest() { // Using DHCPv4 message in the DHCPv6 context is a programming // error and deserves an exception. auto msg0 = createMessage4(DHCPREQUEST, 1, 1, 0); - EXPECT_THROW(state6_.reportRejectedLease(msg0), BadValue); + EXPECT_THROW(state6_.reportRejectedLeaseUpdate(msg0), BadValue); auto msg1 = createMessage6(DHCPV6_SOLICIT, 1, 0); msg1->delOption(D6O_CLIENTID); - EXPECT_FALSE(state6_.reportRejectedLease(msg1)); + EXPECT_FALSE(state6_.reportRejectedLeaseUpdate(msg1)); } TEST_F(CommunicationStateTest, partnerStateTest) { diff --git a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc index 70339db57b..fb53204293 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc @@ -1472,7 +1472,7 @@ public: // Ensure that the server has recorded a lease update conflict. The conflict // reported by the backup server should not count. - EXPECT_EQ(1, service_->communication_state_->getRejectedLeasesCount()); + EXPECT_EQ(1, service_->communication_state_->getRejectedLeaseUpdatesCount()); } /// @brief Tests scenarios when all lease updates are sent successfully. @@ -5160,7 +5160,7 @@ public: for (auto i = 0; i < leases_num; ++i) { // Create query with random HW address. Pkt4Ptr query4 = createQuery4(randomKey(HWAddr::ETHERNET_HWADDR_LEN)); - static_cast<void>(state_->reportRejectedLease(query4)); + static_cast<void>(state_->reportRejectedLeaseUpdate(query4)); } // The state machine needs to react to the rejected leases. service_->runModel(HAService::NOP_EVT); @@ -5427,7 +5427,7 @@ public: simulateRejectedLeaseUpdates(1); service_->verboseTransition(my_state.state_); service_->runModel(TestHAService::NOP_EVT); - return (state_->getRejectedLeasesCount() == 0); + return (state_->getRejectedLeaseUpdatesCount() == 0); } /// @brief Pointer to the communication state used in the tests. |
