// Check if the lease update should be sent to the server. If we're in
// the partner-down state we don't send lease updates to the partner.
if (!shouldSendLeaseUpdates(conf)) {
+ // If we decide to not send the lease updates to an active partner, we
+ // should make a record of it in the communication state. The partner
+ // can check if there were any unsent lease updates when he determines
+ // whether it should synchronize its database or not when it recovers
+ // from the partner-down state.
+ if (conf->getRole() != HAConfig::PeerConfig::BACKUP) {
+ communication_state_->increaseUnsentUpdateCount();
+ }
continue;
}
// Check if the lease update should be sent to the server. If we're in
// the partner-down state we don't send lease updates to the partner.
if (!shouldSendLeaseUpdates(conf)) {
+ // If we decide to not send the lease updates to an active partner, we
+ // should make a record of it in the communication state. The partner
+ // can check if there were any unsent lease updates when he determines
+ // whether it should synchronize its database or not when it recovers
+ // from the partner-down state.
+ if (conf->getRole() != HAConfig::PeerConfig::BACKUP) {
+ communication_state_->increaseUnsentUpdateCount();
+ }
continue;
}
// updates are expected to be successful.
EXPECT_TRUE(unpark_called);
+ // Updates have been sent so this counter should remain 0.
+ EXPECT_EQ(0, service_->communication_state_->getUnsentUpdateCount());
+
// The server 2 should have received two commands.
EXPECT_EQ(2, factory2_->getResponseCreator()->getReceivedRequests().size());
// such situation the packet is not parked either.
EXPECT_FALSE(unpark_called);
+ // In the partner-down state we don't send lease updates. We
+ // should count transactions for which lease updates were not sent.
+ // This is later returned in the heartbeat so the partner can
+ // determine whether it should synchronize its lease database or
+ // not.
+ EXPECT_EQ(1, service_->communication_state_->getUnsentUpdateCount());
+
// Server 2 should not receive lease4-update.
auto update_request2 =
factory2_->getResponseCreator()->findRequest("lease4-update",
// updates are expected to be successful.
EXPECT_TRUE(unpark_called);
+ // Updates have been sent so this counter should remain 0.
+ EXPECT_EQ(0, service_->communication_state_->getUnsentUpdateCount());
+
// The server 2 should have received one command.
EXPECT_EQ(1, factory2_->getResponseCreator()->getReceivedRequests().size());
// situation the packet is not parked either.
EXPECT_FALSE(unpark_called);
+ // In the partner-down state we don't send lease updates. We
+ // should count transactions for which lease updates were not sent.
+ // This is later returned in the heartbeat so the partner can
+ // determine whether it should synchronize its lease database or
+ // not.
+ EXPECT_EQ(1, service_->communication_state_->getUnsentUpdateCount());
+
// Server 2 should not receive lease6-bulk-apply.
auto update_request2 =
factory2_->getResponseCreator()->findRequest("lease6-bulk-apply",