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_CLUSTER_WATCHER_H
5 #define CEPH_RBD_MIRROR_CLUSTER_WATCHER_H
11 #include "common/ceph_context.h"
12 #include "common/Mutex.h"
13 #include "common/Timer.h"
14 #include "include/rados/librados.hpp"
16 #include "tools/rbd_mirror/service_daemon/Types.h"
17 #include <unordered_map>
19 namespace librbd { struct ImageCtx; }
24 template <typename> class ServiceDaemon;
27 * Tracks mirroring configuration for pools in a single
30 class ClusterWatcher {
32 typedef std::set<peer_t> Peers;
33 typedef std::map<int64_t, Peers> PoolPeers;
34 typedef std::set<std::string> PoolNames;
36 ClusterWatcher(RadosRef cluster, Mutex &lock,
37 ServiceDaemon<librbd::ImageCtx>* service_daemon);
38 ~ClusterWatcher() = default;
39 ClusterWatcher(const ClusterWatcher&) = delete;
40 ClusterWatcher& operator=(const ClusterWatcher&) = delete;
42 // Caller controls frequency of calls
44 const PoolPeers& get_pool_peers() const;
47 typedef std::unordered_map<int64_t, service_daemon::CalloutId> ServicePools;
51 ServiceDaemon<librbd::ImageCtx>* m_service_daemon;
53 ServicePools m_service_pools;
54 PoolPeers m_pool_peers;
56 void read_pool_peers(PoolPeers *pool_peers, PoolNames *pool_names);
62 #endif // CEPH_RBD_MIRROR_CLUSTER_WATCHER_H