2018-11-19 18:27:45 +08:00
|
|
|
#include "raft/raft_server.hpp"
|
|
|
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
|
|
|
|
#include <gflags/gflags.h>
|
|
|
|
#include <glog/logging.h>
|
|
|
|
|
2018-11-21 22:49:04 +08:00
|
|
|
#include "raft/coordination.hpp"
|
|
|
|
#include "raft/exceptions.hpp"
|
|
|
|
#include "raft/raft_rpc_messages.hpp"
|
|
|
|
#include "utils/exceptions.hpp"
|
|
|
|
|
2018-11-19 18:27:45 +08:00
|
|
|
|
|
|
|
namespace raft {
|
|
|
|
|
2018-11-21 22:49:04 +08:00
|
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
|
|
|
|
const std::string kRaftDir = "raft";
|
|
|
|
|
|
|
|
RaftServer::RaftServer(uint16_t server_id, const std::string &durability_dir,
|
|
|
|
const Config &config, Coordination *coordination)
|
2018-11-19 18:27:45 +08:00
|
|
|
: config_(config),
|
|
|
|
server_id_(server_id),
|
2018-11-21 22:49:04 +08:00
|
|
|
disk_storage_(fs::path(durability_dir) / kRaftDir) {
|
2018-11-19 18:27:45 +08:00
|
|
|
coordination->Register<RequestVoteRpc>(
|
|
|
|
[this](const auto &req_reader, auto *res_builder) {
|
|
|
|
throw utils::NotYetImplemented("RaftServer constructor");
|
|
|
|
});
|
|
|
|
|
|
|
|
coordination->Register<AppendEntriesRpc>(
|
|
|
|
[this](const auto &req_reader, auto *res_builder) {
|
|
|
|
throw utils::NotYetImplemented("RaftServer constructor");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void RaftServer::Transition(const Mode &new_mode) {
|
|
|
|
throw utils::NotYetImplemented("RaftServer transition");
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace raft
|