zookeeper-cpp
ZooKeeper Client for C++
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
server.hpp
1 #pragma once
2 
3 #include <zk/config.hpp>
4 
5 #include <atomic>
6 #include <exception>
7 #include <memory>
8 #include <string>
9 #include <thread>
10 
11 namespace zk::server
12 {
13 
14 namespace detail
15 {
16 
17 class event_handle;
18 
19 }
20 
24 
25 class classpath;
26 class configuration;
27 
29 class server final
30 {
31 public:
38  explicit server(classpath packages, configuration settings);
39 
46  explicit server(configuration settings);
47 
48  server(const server&) = delete;
49 
50  ~server() noexcept;
51 
57  void shutdown(bool wait_for_stop = false);
58 
59 private:
60  void run_process(const classpath&, const configuration&);
61 
62 private:
63  std::atomic<bool> _running;
64  std::unique_ptr<detail::event_handle> _shutdown_event;
65  std::thread _worker;
66 
67  // NOTE: The configuration is NOT stored in the server object. This is because configuration can be changed by the
68  // ZK process in cases like ensemble reconfiguration. It is the job of run_process to deal with this.
69 };
70 
72 
73 }
Represents a collection of JARs or other Java entities that should be provided as the --classpath to ...
Definition: classpath.hpp:18
Controls a ZooKeeper server process on this local machine.
Definition: server.hpp:29
server(classpath packages, configuration settings)
Create a running server process with the specified packages and settings.
Definition: server.cpp:33
void shutdown(bool wait_for_stop=false)
Initiate shutting down the server process.
Definition: server.cpp:54
Represents a configuration which should be run by server instance.