Fix build

This commit is contained in:
alesapin 2021-02-11 15:12:01 +03:00
parent 99a471e047
commit 447fcfa1c9
3 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,16 @@ namespace ErrorCodes
extern const int RAFT_ERROR;
}
InMemoryStateManager::InMemoryStateManager(int server_id_, const std::string & host, int port)
: my_server_id(server_id_)
, my_port(port)
, log_store(nuraft::cs_new<InMemoryLogStore>())
, cluster_config(nuraft::cs_new<nuraft::cluster_config>())
{
auto peer_config = nuraft::cs_new<nuraft::srv_config>(my_server_id, host + ":" + std::to_string(port));
cluster_config->get_servers().push_back(peer_config);
}
InMemoryStateManager::InMemoryStateManager(
int my_server_id_,
const std::string & config_prefix,

View File

@ -17,6 +17,11 @@ public:
const std::string & config_prefix,
const Poco::Util::AbstractConfiguration & config);
InMemoryStateManager(
int server_id_,
const std::string & host,
int port);
nuraft::ptr<nuraft::cluster_config> load_config() override { return cluster_config; }
void save_config(const nuraft::cluster_config & config) override;

View File

@ -27,7 +27,6 @@
TEST(CoordinationTest, BuildTest)
{
DB::InMemoryLogStore store;
DB::InMemoryStateManager state_manager(1, "localhost:12345");
DB::SummingStateMachine machine;
EXPECT_EQ(1, 1);
}
@ -74,7 +73,7 @@ struct SimpliestRaftServer
, port(port_)
, endpoint(hostname + ":" + std::to_string(port))
, state_machine(nuraft::cs_new<StateMachine>())
, state_manager(nuraft::cs_new<DB::InMemoryStateManager>(server_id, endpoint))
, state_manager(nuraft::cs_new<DB::InMemoryStateManager>(server_id, hostname, port))
{
nuraft::raft_params params;
params.heart_beat_interval_ = 100;