]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/rbd_mirror/ClusterWatcher.h
update sources to v12.1.2
[ceph.git] / ceph / src / tools / rbd_mirror / ClusterWatcher.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_CLUSTER_WATCHER_H
5#define CEPH_RBD_MIRROR_CLUSTER_WATCHER_H
6
7#include <map>
8#include <memory>
9#include <set>
10
11#include "common/ceph_context.h"
12#include "common/Mutex.h"
13#include "common/Timer.h"
14#include "include/rados/librados.hpp"
15#include "types.h"
c07f9fc5
FG
16#include "tools/rbd_mirror/service_daemon/Types.h"
17#include <unordered_map>
18
19namespace librbd { struct ImageCtx; }
7c673cae
FG
20
21namespace rbd {
22namespace mirror {
23
c07f9fc5
FG
24template <typename> class ServiceDaemon;
25
7c673cae
FG
26/**
27 * Tracks mirroring configuration for pools in a single
28 * cluster.
29 */
30class ClusterWatcher {
31public:
32 typedef std::set<peer_t> Peers;
33 typedef std::map<int64_t, Peers> PoolPeers;
34 typedef std::set<std::string> PoolNames;
35
c07f9fc5
FG
36 ClusterWatcher(RadosRef cluster, Mutex &lock,
37 ServiceDaemon<librbd::ImageCtx>* service_daemon);
7c673cae
FG
38 ~ClusterWatcher() = default;
39 ClusterWatcher(const ClusterWatcher&) = delete;
40 ClusterWatcher& operator=(const ClusterWatcher&) = delete;
41
42 // Caller controls frequency of calls
43 void refresh_pools();
44 const PoolPeers& get_pool_peers() const;
45
46private:
c07f9fc5
FG
47 typedef std::unordered_map<int64_t, service_daemon::CalloutId> ServicePools;
48
7c673cae 49 RadosRef m_cluster;
c07f9fc5
FG
50 Mutex &m_lock;
51 ServiceDaemon<librbd::ImageCtx>* m_service_daemon;
52
53 ServicePools m_service_pools;
7c673cae
FG
54 PoolPeers m_pool_peers;
55
56 void read_pool_peers(PoolPeers *pool_peers, PoolNames *pool_names);
57};
58
59} // namespace mirror
60} // namespace rbd
61
62#endif // CEPH_RBD_MIRROR_CLUSTER_WATCHER_H