]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/cephfs_mirror/InstanceWatcher.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_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
);
53 std::scoped_lock
locker(m_lock
);
58 librados::IoCtx
&m_ioctx
;
60 ContextWQ
*m_work_queue
;
63 Context
*m_on_init_finish
= nullptr;
64 Context
*m_on_shutdown_finish
= nullptr;
66 bool m_blocklisted
= false;
67 bool m_failed
= false;
69 void create_instance();
70 void handle_create_instance(int r
);
72 void register_watcher();
73 void handle_register_watcher(int r
);
75 void remove_instance();
76 void handle_remove_instance(int r
);
78 void unregister_watcher();
79 void handle_unregister_watcher(int r
);
85 #endif // CEPHFS_MIRROR_INSTANCE_WATCHER_H