Skip to content

Commit

Permalink
7
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Apr 29, 2024
1 parent 9a3e14c commit b0a5829
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/common/replication_other_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "consensus_types.h"
#include "replica_admin_types.h"
#include "common/replication_enums.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_host_port.h"

Expand Down Expand Up @@ -79,17 +80,24 @@ inline bool is_partition_config_equal(const partition_configuration &pc1,
const partition_configuration &pc2)
{
// secondaries no need to be same order
for (const auto &hp : pc1.hp_secondaries1) {
if (!is_secondary(pc2, hp)) {
std::vector<host_port> pc1_secondaries;
GET_HOST_PORTS(pc1, secondaries1, pc1_secondaries);
for (const auto &pc1_secondary : pc1_secondaries) {
if (!is_secondary(pc2, pc1_secondary)) {
return false;
}
}

// last_drops is not considered into equality check
host_port pc1_primary;
GET_HOST_PORT(pc1, primary1, pc1_primary);
host_port pc2_primary;
GET_HOST_PORT(pc2, primary1, pc2_primary);
std::vector<host_port> pc2_secondaries;
GET_HOST_PORTS(pc2, secondaries1, pc2_secondaries);
return pc1.ballot == pc2.ballot && pc1.pid == pc2.pid &&
pc1.max_replica_count == pc2.max_replica_count && pc1.primary1 == pc2.primary1 &&
pc1.hp_primary1 == pc2.hp_primary1 &&
pc1.secondaries1.size() == pc2.secondaries1.size() &&
pc1.hp_secondaries1.size() == pc2.hp_secondaries1.size() &&
pc1.max_replica_count == pc2.max_replica_count && pc1_primary == pc2_primary &&
pc1_secondaries.size() == pc2_secondaries.size() &&
pc1.last_committed_decree == pc2.last_committed_decree;
}

Expand Down

0 comments on commit b0a5829

Please sign in to comment.