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