-
Notifications
You must be signed in to change notification settings - Fork 0
/
glog_server.cc
62 lines (47 loc) · 1.37 KB
/
glog_server.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <map>
#include <string>
#include <thread>
#include <future>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <grpc++/grpc++.h>
#include <cassert>
#include "gsl.h"
#include "glog_server_impl.h"
#include "glog_client_impl.h"
#include "config.h"
#include "cqueue.h"
#include "utils.h"
#include "paxos.pb.h"
#include "callback.h"
#include "mem_storage.h"
using namespace std;
using paxos::Message;
using paxos::HardState;
using paxos::Paxos;
using namespace glog;
int
main ( int argc, char *argv[] )
{
printf ( "%s config\n", argv[0] );
assert(2 == argc);
const char* sConfigFileName = argv[1];
Config config({sConfigFileName, strlen(sConfigFileName)});
auto selfid = config.GetSelfId();
auto groups = config.GetGroups();
MemStorage storage;
GlogServiceImpl service{selfid, groups,
glog::ReadCallBack<MemStorage>{storage},
glog::WriteCallBack<MemStorage>{storage}};
grpc::ServerBuilder builder;
builder.AddListeningPort(
groups.at(selfid), grpc::InsecureServerCredentials());
builder.RegisterService(&service);
unique_ptr<grpc::Server> server(builder.BuildAndStart());
logdebug("Server %" PRIu64 " listening on %s\n",
selfid, groups.at(selfid).c_str());
server->Wait();
// f.get();
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */