1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
6 #include "rgw/rgw_service.h"
17 class RGWSI_Notify_ShutdownCB
;
19 class RGWSI_Notify
: public RGWServiceInstance
21 friend class RGWWatcher
;
22 friend class RGWSI_Notify_ShutdownCB
;
23 friend class RGWServices_Def
;
29 RGWSI_Zone
*zone_svc
{nullptr};
30 RGWSI_RADOS
*rados_svc
{nullptr};
31 RGWSI_Finisher
*finisher_svc
{nullptr};
33 ceph::shared_mutex watchers_lock
= ceph::make_shared_mutex("watchers_lock");
34 rgw_pool control_pool
;
37 RGWWatcher
**watchers
{nullptr};
38 std::set
<int> watchers_set
;
39 vector
<RGWSI_RADOS::Obj
> notify_objs
;
43 double inject_notify_timeout_probability
{0};
44 unsigned max_notify_retries
{0};
46 string
get_control_oid(int i
);
47 RGWSI_RADOS::Obj
pick_control_obj(const string
& key
);
51 std::optional
<int> finisher_handle
;
52 RGWSI_Notify_ShutdownCB
*shutdown_cb
{nullptr};
54 bool finalized
{false};
56 int init_watch(optional_yield y
);
57 void finalize_watch();
59 void init(RGWSI_Zone
*_zone_svc
,
60 RGWSI_RADOS
*_rados_svc
,
61 RGWSI_Finisher
*_finisher_svc
) {
63 rados_svc
= _rados_svc
;
64 finisher_svc
= _finisher_svc
;
66 int do_start(optional_yield
) override
;
67 void shutdown() override
;
69 int unwatch(RGWSI_RADOS::Obj
& obj
, uint64_t watch_handle
);
70 void add_watcher(int i
);
71 void remove_watcher(int i
);
73 int watch_cb(uint64_t notify_id
,
77 void _set_enabled(bool status
);
78 void set_enabled(bool status
);
80 int robust_notify(RGWSI_RADOS::Obj
& notify_obj
, bufferlist
& bl
,
83 void schedule_context(Context
*c
);
85 RGWSI_Notify(CephContext
*cct
): RGWServiceInstance(cct
) {}
91 virtual int watch_cb(uint64_t notify_id
,
95 virtual void set_enabled(bool status
) = 0;
98 int distribute(const string
& key
, bufferlist
& bl
, optional_yield y
);
100 void register_watch_cb(CB
*cb
);