fc20ddcd25
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
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include <ctime>
|
|
#include <random>
|
|
#include <thread>
|
|
|
|
#include <fmt/format.h>
|
|
#include <gflags/gflags.h>
|
|
#include <glog/logging.h>
|
|
|
|
#include "communication/rpc/client.hpp"
|
|
#include "io/network/endpoint.hpp"
|
|
#include "messages.hpp"
|
|
#include "utils/network.hpp"
|
|
#include "utils/signals/handler.hpp"
|
|
#include "utils/terminate_handler.hpp"
|
|
|
|
using namespace communication::rpc;
|
|
using namespace std::literals::chrono_literals;
|
|
|
|
DEFINE_string(server_interface, "127.0.0.1",
|
|
"Server interface on which to communicate.");
|
|
DEFINE_int32(server_port, 8010, "Server port on which to communicate.");
|
|
|
|
volatile sig_atomic_t is_shutting_down = 0;
|
|
|
|
int main(int argc, char **argv) {
|
|
google::SetUsageMessage("Raft RPC Client");
|
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
google::InitGoogleLogging(argv[0]);
|
|
|
|
// Initialize client.
|
|
Client client(
|
|
io::network::Endpoint(utils::ResolveHostname(FLAGS_server_interface),
|
|
FLAGS_server_port),
|
|
"main");
|
|
|
|
// Try to send 100 values to server.
|
|
// If requests timeout, try to resend it.
|
|
// Log output on server should contain all values once
|
|
// in correct order.
|
|
for (int i = 1; i <= 100; ++i) {
|
|
LOG(INFO) << fmt::format("Apennding value: {}", i);
|
|
auto result_tuple = client.Call<AppendEntry>(i);
|
|
if (!result_tuple) {
|
|
LOG(INFO) << "Request unsuccessful";
|
|
// Try to resend value
|
|
--i;
|
|
} else {
|
|
LOG(INFO) << fmt::format("Appended value: {}", i);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|