blob: a418898f555ef91a5798b410598501e06c0a43ea (
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
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPHFS_MIRROR_CLUSTER_WATCHER_H
#define CEPHFS_MIRROR_CLUSTER_WATCHER_H
#include <map>
#include "common/ceph_mutex.h"
#include "common/async/context_pool.h"
#include "messages/MFSMap.h"
#include "msg/Dispatcher.h"
#include "Types.h"
class MonClient;
namespace cephfs {
namespace mirror {
class ServiceDaemon;
// watch peer changes for filesystems via FSMap updates
class ClusterWatcher : public Dispatcher {
public:
struct Listener {
virtual ~Listener() {
}
virtual void handle_mirroring_enabled(const FilesystemSpec &spec) = 0;
virtual void handle_mirroring_disabled(const Filesystem &filesystem) = 0;
virtual void handle_peers_added(const Filesystem &filesystem, const Peer &peer) = 0;
virtual void handle_peers_removed(const Filesystem &filesystem, const Peer &peer) = 0;
};
ClusterWatcher(CephContext *cct, MonClient *monc, ServiceDaemon *service_daemon,
Listener &listener);
~ClusterWatcher();
bool ms_can_fast_dispatch_any() const override {
return true;
}
bool ms_can_fast_dispatch2(const cref_t<Message> &m) const override;
void ms_fast_dispatch2(const ref_t<Message> &m) override;
bool ms_dispatch2(const ref_t<Message> &m) override;
void ms_handle_connect(Connection *c) override {
}
bool ms_handle_reset(Connection *c) override {
return false;
}
void ms_handle_remote_reset(Connection *c) override {
}
bool ms_handle_refused(Connection *c) override {
return false;
}
int init();
void shutdown();
private:
ceph::mutex m_lock = ceph::make_mutex("cephfs::mirror::cluster_watcher");
MonClient *m_monc;
ServiceDaemon *m_service_daemon;
Listener &m_listener;
bool m_stopping = false;
std::map<Filesystem, Peers> m_filesystem_peers;
void handle_fsmap(const cref_t<MFSMap> &m);
};
} // namespace mirror
} // namespace cephfs
#endif // CEPHFS_MIRROR_CLUSTER_WATCHER_H
|