Starting nukeeper server

This commit is contained in:
alesapin 2021-01-21 23:01:25 +03:00
parent 4aa11b3494
commit c2e6d6cfe8
4 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,13 @@
#include <Coordination/NuKeeperServer.h>
namespace DB
{
void NuKeeperServer::addServer(int server_id_, const std::string & server_uri)
{
if (raft_instance->is_leader())
{
nuraft::srv_config first_config(server_id, server_uri);
}
}

View File

@ -0,0 +1,43 @@
#pragma once
#include <libnuraft/nuraft.hxx>
#include <Coordination/InMemoryLogStore.h>
#include <Coordination/InMemoryStateManager.h>
#include <Coordination/NuKeeperStateMachine.h>
#include <Coordination/TestKeeperStorage.h>
namespace DB
{
class NuKeeperServer
{
private:
int server_id;
std::string hostname;
int port;
std::string endpoint;
nuraft::ptr<StateMachine> state_machine;
nuraft::ptr<nuraft::state_mgr> state_manager;
nuraft::raft_launcher launcher;
nuraft::ptr<nuraft::raft_server> raft_instance;
public:
NuKeeperServer(int server_id, const std::string & hostname, int port);
void startup();
TestKeeperStorage::ResponsesForSessions putRequests(const TestKeeperStorage::RequestsForSessions & requests);
void addServer(int server_id_, const std::string & server_uri);
void shutdown();
};
}

View File

@ -81,7 +81,6 @@ bool NuKeeperStateMachine::apply_snapshot(nuraft::snapshot & s)
nuraft::ptr<nuraft::snapshot> NuKeeperStateMachine::last_snapshot()
{
LOG_DEBUG(log, "Trying to get last snapshot");
// Just return the latest snapshot.
std::lock_guard<std::mutex> lock(snapshots_lock);

View File

@ -78,6 +78,7 @@ public:
{
return session_id_counter++;
}
ResponsesForSessions processRequest(const Coordination::ZooKeeperRequestPtr & request, int64_t session_id);
ResponsesForSessions finalize(const RequestsForSessions & expired_requests);
};