identt
SyncServer.hpp
Go to the documentation of this file.
1 
33 #ifndef _IDENTT_HRPC_SYNC_SERVER_HPP_
34 #define _IDENTT_HRPC_SYNC_SERVER_HPP_
35 
36 #include <store/StoreBase.hpp>
37 #include <utils/ServerBase.hpp>
38 #include "http/HttpServer.hpp"
39 
40 
41 namespace identt {
42 namespace hrpc {
43 
44 class SyncServer :
45  virtual public identt::utils::ServerBase,
46  virtual public std::enable_shared_from_this<SyncServer> {
47 
48 public:
49  using pointer=std::shared_ptr<SyncServer>;
51 
56  SyncServer() = delete;
57  SyncServer(const SyncServer&) = delete;
58  SyncServer& operator=(const SyncServer&) = delete;
59 
60 
73  static pointer create(std::shared_ptr<::identt::http::io_whatever> io_whatever_, identt::utils::SharedTable::pointer stptr)
74  {
75  pointer p(new SyncServer(io_whatever_,stptr));
76  return p;
77  }
78 
85  pointer share()
86  {
87  return shared_from_this();
88  }
89 
90 
94  virtual ~SyncServer ();
95 
102  const static std::string GetSection();
103 
110  const static identt::utils::ServerBase::ParamsListT GetRequire();
111 
121  void init(identt::utils::ServerBase::ParamsListT params);
122 
129  void stop();
130 
131 protected:
132  std::shared_ptr<HttpServerT> server;
133  std::shared_ptr<::identt::http::io_whatever> io_whatever;
134 
135 private:
136  bool is_init;
138 
149  SyncServer(std::shared_ptr<::identt::http::io_whatever> io_whatever_, identt::utils::SharedTable::pointer stptr);
150 
157  void SyncFirst();
158 
165  void SyncFromMaster();
166 
176  bool CompareLog(std::string address);
177 
184  void MasterLoop();
185 
186 };
187 } // namespace hrpc
188 } // namespace identt
189 #endif /* _IDENTT_HRPC_SYNC_SERVER_HPP_ */
190 
void stop()
stop : shutdown
Definition: SyncServer.cc:139
virtual ~SyncServer()
destructor
Definition: SyncServer.cc:61
void init(identt::utils::ServerBase::ParamsListT params)
init : initialize rocksdb and others
Definition: SyncServer.cc:89
pointer share()
share : return instance
Definition: SyncServer.hpp:85
Definition: CryptoBase.hpp:49
SyncServer()=delete
make noncopyable
static const identt::utils::ServerBase::ParamsListT GetRequire()
GetRequire : parameters required.
Definition: SyncServer.cc:79
static const std::string GetSection()
GetSection : section required.
Definition: SyncServer.cc:70
static pointer create(std::shared_ptr<::identt::http::io_whatever > io_whatever_, identt::utils::SharedTable::pointer stptr)
create : static construction creates new first time
Definition: SyncServer.hpp:73
Definition: HttpServer.hpp:42
Definition: SyncServer.hpp:44
Definition: ServerBase.hpp:46