1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_RBD_MIRROR_H
5 #define CEPH_RBD_MIRROR_H
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"
20 namespace librbd { struct ImageCtx; }
25 template <typename> struct ServiceDaemon;
26 template <typename> struct Threads;
27 class MirrorAdminSocketHook;
30 * Contains the main loop and overall state for rbd-mirror.
32 * Sets up mirroring, and coordinates between noticing config
33 * changes and applying them.
37 Mirror(CephContext *cct, const std::vector<const char*> &args);
38 Mirror(const Mirror&) = delete;
39 Mirror& operator=(const Mirror&) = delete;
44 void handle_signal(int signum);
46 void print_status(Formatter *f, stringstream *ss);
51 void release_leader();
54 typedef ClusterWatcher::PoolPeers PoolPeers;
55 typedef std::pair<int64_t, peer_t> PoolPeer;
57 void update_pool_replayers(const PoolPeers &pool_peers);
60 std::vector<const char*> m_args;
61 Threads<librbd::ImageCtx> *m_threads = nullptr;
65 std::unique_ptr<ServiceDaemon<librbd::ImageCtx>> m_service_daemon;
67 // monitor local cluster for config changes in peers
68 std::unique_ptr<ClusterWatcher> m_local_cluster_watcher;
69 std::unique_ptr<ImageDeleter<>> m_image_deleter;
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;
79 #endif // CEPH_RBD_MIRROR_H