Skip to content

Commit ef5c255

Browse files
yawzhangxiaoxichen
authored andcommitted
init nuraft message port by the current repl svc port
1 parent 15396b2 commit ef5c255

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/include/homestore/replication_service.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class ReplApplication {
114114

115115
// Get the current application/server repl uuid
116116
virtual replica_id_t get_my_repl_id() const = 0;
117+
118+
// Get the current replication service port
119+
virtual uint32_t get_my_repl_svc_port() const = 0;
117120
};
118121

119122
} // namespace homestore

‎src/lib/replication/service/raft_repl_service.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void RaftReplService::start() {
8787
std::string ssl_ca_file = HS_DYNAMIC_CONFIG(consensus.ssl_ca_file);
8888
auto params = nuraft_mesg::Manager::Params{
8989
.server_uuid_ = m_my_uuid,
90-
.mesg_port_ = m_repl_app->lookup_peer(m_my_uuid).second,
90+
.mesg_port_ = static_cast< uint16_t >(m_repl_app->get_my_repl_svc_port()),
9191
.default_group_type_ = "homestore_replication",
9292
.ssl_key_ = ioenvironment.get_ssl_key(),
9393
.ssl_cert_ = ioenvironment.get_ssl_cert(),

‎src/tests/test_common/hs_repl_test_common.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class HSReplTestHelper : public HSTestHelper {
135135
}
136136

137137
homestore::replica_id_t get_my_repl_id() const override { return helper_.my_replica_id_; }
138+
uint32_t get_my_repl_svc_port() const override {
139+
return SISL_OPTIONS["base_port"].as< uint16_t >() + helper_.replica_num_;
140+
}
138141
};
139142

140143
public:

‎src/tests/test_solo_repl_dev.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class SoloReplDevTest : public testing::Test {
160160
void on_repl_devs_init_completed() { LOGINFO("Repl dev init completed CB called"); }
161161
std::pair< std::string, uint16_t > lookup_peer(uuid_t uuid) const override { return std::make_pair("", 0u); }
162162
replica_id_t get_my_repl_id() const override { return hs_utils::gen_random_uuid(); }
163+
uint32_t get_my_repl_svc_port() const override { return 0; }
163164
};
164165

165166
protected:

0 commit comments

Comments
 (0)