]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/cephfs_mirror/MirrorWatcher.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPHFS_MIRROR_MIRROR_WATCHER_H
5 #define CEPHFS_MIRROR_MIRROR_WATCHER_H
9 #include "common/ceph_mutex.h"
10 #include "include/Context.h"
11 #include "include/rados/librados.hpp"
22 // watch for notifications via cephfs_mirror object (in metadata
23 // pool). this is used sending keepalived with keepalive payload
24 // being the rados instance address (used by the manager module
25 // to blocklist when needed).
27 class MirrorWatcher
: public Watcher
{
29 static MirrorWatcher
*create(librados::IoCtx
&ioctx
, FSMirror
*fs_mirror
,
30 ContextWQ
*work_queue
) {
31 return new MirrorWatcher(ioctx
, fs_mirror
, work_queue
);
34 MirrorWatcher(librados::IoCtx
&ioctx
, FSMirror
*fs_mirror
,
35 ContextWQ
*work_queue
);
38 void init(Context
*on_finish
);
39 void shutdown(Context
*on_finish
);
41 void handle_notify(uint64_t notify_id
, uint64_t handle
,
42 uint64_t notifier_id
, bufferlist
& bl
) override
;
43 void handle_rewatch_complete(int r
) override
;
45 bool is_blocklisted() {
46 std::scoped_lock
locker(m_lock
);
50 utime_t
get_blocklisted_ts() {
51 std::scoped_lock
locker(m_lock
);
52 return m_blocklisted_ts
;
56 std::scoped_lock
locker(m_lock
);
60 utime_t
get_failed_ts() {
61 std::scoped_lock
locker(m_lock
);
66 librados::IoCtx
&m_ioctx
;
67 FSMirror
*m_fs_mirror
;
68 ContextWQ
*m_work_queue
;
71 std::string m_instance_id
;
73 Context
*m_on_init_finish
= nullptr;
74 Context
*m_on_shutdown_finish
= nullptr;
76 bool m_blocklisted
= false;
77 bool m_failed
= false;
79 utime_t m_blocklisted_ts
;
82 void register_watcher();
83 void handle_register_watcher(int r
);
85 void unregister_watcher();
86 void handle_unregister_watcher(int r
);
92 #endif // CEPHFS_MIRROR_MIRROR_WATCHER_H