]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_realm_watcher.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef RGW_REALM_WATCHER_H
5 #define RGW_REALM_WATCHER_H
7 #include "include/rados/librados.hpp"
8 #include "include/assert.h"
9 #include "common/Timer.h"
10 #include "common/Cond.h"
15 enum class RGWRealmNotify
{
19 WRITE_RAW_ENCODER(RGWRealmNotify
);
22 * RGWRealmWatcher establishes a watch on the current RGWRealm's control object,
23 * and forwards notifications to registered observers.
25 class RGWRealmWatcher
: public librados::WatchCtx2
{
28 * Watcher is an interface that allows the RGWRealmWatcher to pass
29 * notifications on to other interested objects.
33 virtual ~Watcher() = default;
35 virtual void handle_notify(RGWRealmNotify type
,
36 bufferlist::iterator
& p
) = 0;
39 RGWRealmWatcher(CephContext
* cct
, RGWRealm
& realm
);
40 ~RGWRealmWatcher() override
;
42 /// register a watcher for the given notification type
43 void add_watcher(RGWRealmNotify type
, Watcher
& watcher
);
45 /// respond to realm notifications by calling the appropriate watcher
46 void handle_notify(uint64_t notify_id
, uint64_t cookie
,
47 uint64_t notifier_id
, bufferlist
& bl
) override
;
49 /// reestablish the watch if it gets disconnected
50 void handle_error(uint64_t cookie
, int err
) override
;
53 CephContext
*const cct
;
55 /// keep a separate Rados client whose lifetime is independent of RGWRados
56 /// so that we don't miss notifications during realm reconfiguration
57 librados::Rados rados
;
58 librados::IoCtx pool_ctx
;
59 uint64_t watch_handle
;
60 std::string watch_oid
;
62 int watch_start(RGWRealm
& realm
);
66 std::map
<RGWRealmNotify
, Watcher
&> watchers
;
69 #endif // RGW_REALM_WATCHER_H