]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/rbd_mirror/Mirror.h
bump version to 12.1.1-pve1 while rebasing patches
[ceph.git] / ceph / src / tools / rbd_mirror / Mirror.h
CommitLineData
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
20namespace librbd { struct ImageCtx; }
21
22namespace rbd {
23namespace mirror {
24
25template <typename> struct Threads;
26class MirrorAdminSocketHook;
27
28/**
29 * Contains the main loop and overall state for rbd-mirror.
30 *
31 * Sets up mirroring, and coordinates between noticing config
32 * changes and applying them.
33 */
34class Mirror {
35public:
36 Mirror(CephContext *cct, const std::vector<const char*> &args);
37 Mirror(const Mirror&) = delete;
38 Mirror& operator=(const Mirror&) = delete;
39 ~Mirror();
40
41 int init();
42 void run();
43 void handle_signal(int signum);
44
45 void print_status(Formatter *f, stringstream *ss);
46 void start();
47 void stop();
48 void restart();
49 void flush();
50 void release_leader();
51
52private:
53 typedef ClusterWatcher::PoolPeers PoolPeers;
54 typedef std::pair<int64_t, peer_t> PoolPeer;
55
56 void update_pool_replayers(const PoolPeers &pool_peers);
57
58 CephContext *m_cct;
59 std::vector<const char*> m_args;
60 Threads<librbd::ImageCtx> *m_threads = nullptr;
61 Mutex m_lock;
62 Cond m_cond;
63 RadosRef m_local;
64
65 // monitor local cluster for config changes in peers
66 std::unique_ptr<ClusterWatcher> m_local_cluster_watcher;
67 std::shared_ptr<ImageDeleter> m_image_deleter;
7c673cae
FG
68 std::map<PoolPeer, std::unique_ptr<PoolReplayer> > m_pool_replayers;
69 std::atomic<bool> m_stopping = { false };
70 bool m_manual_stop = false;
71 MirrorAdminSocketHook *m_asok_hook;
72};
73
74} // namespace mirror
75} // namespace rbd
76
77#endif // CEPH_RBD_MIRROR_H