Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Jun 25, 2024
1 parent 4df8807 commit 94de408
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/meta/meta_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool construct_replica(meta_view view, const gpid &pid, int max_replica_count)
GET_HOST_PORTS(pc, last_drops1, last_drops);
CHECK(last_drops.empty(), "last_drops of partition({}) must be empty", pid);
for (auto iter = drop_list.rbegin(); iter != drop_list.rend(); ++iter) {
if (last_drops.size() + 1 >= max_replica_count) {
if (pc.hp_last_drops1.size() + 1 >= max_replica_count) {
break;
}
// similar to cc.drop_list, pc.last_drop is also a stack structure
Expand Down
13 changes: 9 additions & 4 deletions src/meta/meta_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,18 @@ inline config_context *get_config_context(app_mapper &apps, const dsn::gpid &gpi
return &(iter->second->helpers->contexts[gpid.get_partition_index()]);
}

inline int replica_count(const partition_configuration &pc)
inline size_t replica_count(const partition_configuration &pc)
{
host_port primary;
GET_HOST_PORT(pc, primary1, primary);
size_t rc = 0;
if (pc.primary1) {
host_port primary;
GET_HOST_PORT(pc, primary1, primary);
rc += (primary ? 1 : 0);
}
std::vector<host_port> secondaries;
GET_HOST_PORTS(pc, secondaries1, secondaries);
return (primary ? 1 : 0) + secondaries.size();
rc += secondaries.size();
return rc;
}

enum health_status
Expand Down
1 change: 1 addition & 0 deletions src/meta/meta_http_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

#include <fmt/core.h>
#include <fmt/format.h>
#include <rapidjson/ostreamwrapper.h>
#include <algorithm>
#include <map>
Expand Down
18 changes: 11 additions & 7 deletions src/meta/test/json_compacity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,21 @@ void meta_service_test_app::json_compacity()
ASSERT_EQ(info2.partition_count, 16);

// 4. old pc version
const char *json3 =
"{\"pid\":\"1.1\",\"ballot\":234,\"max_replica_count\":3,"
"\"primary\":\"invalid address\",\"secondaries\":[\"127.0.0.1:6\"],"
"\"hp_primary\":\"invalid host_port\",\"hp_secondaries1\":[\"localhost:6\"],"
"\"last_drops\":[],\"last_committed_decree\":157}";
const char *json3 = "{\"pid\":\"1.1\",\"ballot\":234,\"max_replica_count\":3,"
"\"primary1\":\"127.0.0.1:1\",\"secondaries1\":[\"127.0.0.1:6\"],"
"\"hp_primary1\":\"localhost:1\",\"hp_secondaries1\":[\"localhost:6\"],"
"\"last_drops\":[],\"last_committed_decree\":157}";
dsn::partition_configuration pc;
dsn::json::json_forwarder<dsn::partition_configuration>::decode(
dsn::blob(json3, 0, strlen(json3)), pc);
ASSERT_EQ(234, pc.ballot);
ASSERT_TRUE(!pc.hp_primary1);
ASSERT_TRUE(!pc.primary1);
// As how we do in src/meta/server_state.cpp, we have to set the '__isset' fields manually.
ASSERT_FALSE(pc.__isset.hp_primary1);
ASSERT_TRUE(pc.hp_primary1);
ASSERT_TRUE(pc.primary1);
ASSERT_STREQ("127.0.0.1:1", pc.primary1.to_string());
ASSERT_EQ("localhost:1", pc.hp_primary1.to_string());
ASSERT_FALSE(pc.__isset.hp_secondaries1);
ASSERT_EQ(1, pc.hp_secondaries1.size());
ASSERT_EQ(1, pc.secondaries1.size());
ASSERT_STREQ("127.0.0.1:6", pc.secondaries1[0].to_string());
Expand Down
2 changes: 1 addition & 1 deletion src/replica/duplication/replica_follower.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "common/gpid.h"
#include "dsn.layer2_types.h"
#include "replica/replica_base.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/dns_resolver.h" // IWYU pragma: keep
#include "runtime/rpc/rpc_host_port.h"
#include "runtime/task/task_tracker.h"
#include "utils/error_code.h"
Expand Down
2 changes: 2 additions & 0 deletions src/replica/replica_backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "replica/replication_app_base.h"
#include "replica_stub.h"
#include "runtime/api_layer1.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/rpc_host_port.h"
#include "runtime/task/async_calls.h"
#include "utils/autoref_ptr.h"
#include "utils/env.h"
Expand Down
1 change: 1 addition & 0 deletions src/shell/commands/data_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <boost/cstdint.hpp>
#include <boost/lexical_cast.hpp>
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/printf.h>
#include <getopt.h>
#include <inttypes.h>
Expand Down
2 changes: 2 additions & 0 deletions src/test/function_test/detect_hotspot/test_detect_hotspot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

#include "client/replication_ddl_client.h"
#include "common/gpid.h"
#include "dsn.layer2_types.h"
#include "gtest/gtest.h"
#include "include/pegasus/client.h"
#include "include/pegasus/error.h"
#include "replica_admin_types.h"
#include "runtime/api_layer1.h"
#include "runtime/rpc/rpc_host_port.h"
#include "test/function_test/utils/test_util.h"
#include "test/function_test/utils/utils.h"
#include "utils/error_code.h"
Expand Down
2 changes: 2 additions & 0 deletions src/test/kill_test/kill_testor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

#include <fmt/core.h>
#include <fmt/format.h>
#include <pegasus/client.h>
#include <stdint.h>
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions src/test/kill_test/partition_kill_testor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "partition_kill_testor.h"
#include "remote_cmd/remote_command.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/rpc_host_port.h"
#include "runtime/task/task.h"
#include "test/kill_test/kill_testor.h"
#include "utils/autoref_ptr.h"
Expand Down

0 comments on commit 94de408

Please sign in to comment.