memgraph/tests/manual/raft_rpc.cpp
Matej Ferencevic fc20ddcd25 RPC refactor
Summary:
Start removal of old logic
Remove more obsolete classes
Move Message class to RPC
Remove client logic from system
Remove messaging namespace
Move protocol from messaging to rpc
Move System from messaging to rpc
Remove unnecessary namespace
Remove System from RPC Client
Split Client and Server into separate files
Start implementing new client logic
First semi-working state
Changed network protocol layout
Rewrite client
Fix client receive bug
Cleanup code of debug lines
Migrate to accessors
Migrate back to binary boost archives
Remove debug logging from server
Disable timeout test
Reduce message_id from uint64_t to uint32_t
Add multiple workers to server
Fix compiler warnings
Apply clang-format

Reviewers: teon.banek, florijan, dgleich, buda, mtomic

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1129
2018-01-24 15:27:40 +01:00

61 lines
1.7 KiB
C++

#include "boost/serialization/export.hpp"
#include "boost/archive/binary_iarchive.hpp"
#include "boost/archive/binary_oarchive.hpp"
#include "boost/archive/text_iarchive.hpp"
#include "boost/archive/text_oarchive.hpp"
#include "boost/serialization/export.hpp"
#include "communication/raft/rpc.hpp"
#include "communication/raft/storage/file.hpp"
#include "communication/raft/test_utils.hpp"
using namespace std::literals::chrono_literals;
namespace raft = communication::raft;
using io::network::Endpoint;
using raft::RaftConfig;
using raft::RpcNetwork;
using raft::test_utils::DummyState;
DEFINE_string(member_id, "", "id of Raft member");
DEFINE_string(log_dir, "", "Raft log directory");
BOOST_CLASS_EXPORT(raft::PeerRpcReply);
BOOST_CLASS_EXPORT(raft::PeerRpcRequest<DummyState>);
/* Start cluster members with:
* ./raft_rpc --member-id a --log-dir a_log
* ./raft_rpc --member-id b --log-dir b_log
* ./raft_rpc --member-id c --log-dir c_log
*
* Enjoy democracy!
*/
int main(int argc, char *argv[]) {
google::InitGoogleLogging(argv[0]);
gflags::ParseCommandLineFlags(&argc, &argv, true);
std::unordered_map<std::string, Endpoint> directory = {
{"a", Endpoint("127.0.0.1", 12345)},
{"b", Endpoint("127.0.0.1", 12346)},
{"c", Endpoint("127.0.0.1", 12347)}};
communication::rpc::System my_system(directory[FLAGS_member_id]);
RpcNetwork<DummyState> network(my_system, directory);
raft::SimpleFileStorage<DummyState> storage(FLAGS_log_dir);
raft::RaftConfig config{{"a", "b", "c"}, 150ms, 300ms, 70ms, 30ms};
{
raft::RaftMember<DummyState> raft_member(network, storage, FLAGS_member_id,
config);
while (true) {
continue;
}
}
return 0;
}