]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_RBD_MIRROR_H | |
5 | #define CEPH_RBD_MIRROR_H | |
6 | ||
7 | #include "common/ceph_context.h" | |
8 | #include "common/Mutex.h" | |
9 | #include "include/rados/librados.hpp" | |
10 | #include "ClusterWatcher.h" | |
11 | #include "PoolReplayer.h" | |
12 | #include "ImageDeleter.h" | |
13 | #include "types.h" | |
14 | ||
15 | #include <set> | |
16 | #include <map> | |
17 | #include <memory> | |
18 | #include <atomic> | |
19 | ||
20 | namespace librbd { struct ImageCtx; } | |
21 | ||
22 | namespace rbd { | |
23 | namespace mirror { | |
24 | ||
c07f9fc5 | 25 | template <typename> struct ServiceDaemon; |
7c673cae FG |
26 | template <typename> struct Threads; |
27 | class MirrorAdminSocketHook; | |
28 | ||
29 | /** | |
30 | * Contains the main loop and overall state for rbd-mirror. | |
31 | * | |
32 | * Sets up mirroring, and coordinates between noticing config | |
33 | * changes and applying them. | |
34 | */ | |
35 | class Mirror { | |
36 | public: | |
37 | Mirror(CephContext *cct, const std::vector<const char*> &args); | |
38 | Mirror(const Mirror&) = delete; | |
39 | Mirror& operator=(const Mirror&) = delete; | |
40 | ~Mirror(); | |
41 | ||
42 | int init(); | |
43 | void run(); | |
44 | void handle_signal(int signum); | |
45 | ||
46 | void print_status(Formatter *f, stringstream *ss); | |
47 | void start(); | |
48 | void stop(); | |
49 | void restart(); | |
50 | void flush(); | |
51 | void release_leader(); | |
52 | ||
53 | private: | |
54 | typedef ClusterWatcher::PoolPeers PoolPeers; | |
55 | typedef std::pair<int64_t, peer_t> PoolPeer; | |
56 | ||
57 | void update_pool_replayers(const PoolPeers &pool_peers); | |
58 | ||
59 | CephContext *m_cct; | |
60 | std::vector<const char*> m_args; | |
61 | Threads<librbd::ImageCtx> *m_threads = nullptr; | |
62 | Mutex m_lock; | |
63 | Cond m_cond; | |
64 | RadosRef m_local; | |
c07f9fc5 | 65 | std::unique_ptr<ServiceDaemon<librbd::ImageCtx>> m_service_daemon; |
7c673cae FG |
66 | |
67 | // monitor local cluster for config changes in peers | |
68 | std::unique_ptr<ClusterWatcher> m_local_cluster_watcher; | |
c07f9fc5 | 69 | std::unique_ptr<ImageDeleter<>> m_image_deleter; |
7c673cae FG |
70 | std::map<PoolPeer, std::unique_ptr<PoolReplayer> > m_pool_replayers; |
71 | std::atomic<bool> m_stopping = { false }; | |
72 | bool m_manual_stop = false; | |
73 | MirrorAdminSocketHook *m_asok_hook; | |
74 | }; | |
75 | ||
76 | } // namespace mirror | |
77 | } // namespace rbd | |
78 | ||
79 | #endif // CEPH_RBD_MIRROR_H |