]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/cephfs_mirror/InstanceWatcher.h
a0740009605e4ae62c9f67cd3bd7c213808b31fc
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_INSTANCE_WATCHER_H
5 #define CEPHFS_MIRROR_INSTANCE_WATCHER_H
9 #include "common/ceph_mutex.h"
10 #include "include/Context.h"
11 #include "include/rados/librados.hpp"
19 // watch directory update notifications via per daemon rados
20 // object and invoke listener callback.
22 class InstanceWatcher
: public Watcher
{
28 virtual void acquire_directory(std::string_view dir_path
) = 0;
29 virtual void release_directory(std::string_view dir_path
) = 0;
32 static InstanceWatcher
*create(librados::IoCtx
&ioctx
,
33 Listener
&listener
, ContextWQ
*work_queue
) {
34 return new InstanceWatcher(ioctx
, listener
, work_queue
);
37 InstanceWatcher(librados::IoCtx
&ioctx
, Listener
&listener
, ContextWQ
*work_queue
);
40 void init(Context
*on_finish
);
41 void shutdown(Context
*on_finish
);
43 void handle_notify(uint64_t notify_id
, uint64_t handle
,
44 uint64_t notifier_id
, bufferlist
& bl
) override
;
45 void handle_rewatch_complete(int r
) override
;
47 bool is_blocklisted() {
48 std::scoped_lock
locker(m_lock
);
52 utime_t
get_blocklisted_ts() {
53 std::scoped_lock
locker(m_lock
);
54 return m_blocklisted_ts
;
58 std::scoped_lock
locker(m_lock
);
62 utime_t
get_failed_ts() {
63 std::scoped_lock
locker(m_lock
);
68 librados::IoCtx
&m_ioctx
;
70 ContextWQ
*m_work_queue
;
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 create_instance();
83 void handle_create_instance(int r
);
85 void register_watcher();
86 void handle_register_watcher(int r
);
88 void remove_instance();
89 void handle_remove_instance(int r
);
91 void unregister_watcher();
92 void handle_unregister_watcher(int r
);
98 #endif // CEPHFS_MIRROR_INSTANCE_WATCHER_H