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_service.h"
17 class RGWSI_Notify_ShutdownCB
;
18 struct RGWCacheNotifyInfo
;
20 class RGWSI_Notify
: public RGWServiceInstance
22 friend class RGWWatcher
;
23 friend class RGWSI_Notify_ShutdownCB
;
24 friend class RGWServices_Def
;
30 RGWSI_Zone
*zone_svc
{nullptr};
31 RGWSI_RADOS
*rados_svc
{nullptr};
32 RGWSI_Finisher
*finisher_svc
{nullptr};
34 ceph::shared_mutex watchers_lock
= ceph::make_shared_mutex("watchers_lock");
35 rgw_pool control_pool
;
38 RGWWatcher
**watchers
{nullptr};
39 std::set
<int> watchers_set
;
40 std::vector
<RGWSI_RADOS::Obj
> notify_objs
;
44 double inject_notify_timeout_probability
{0};
45 uint64_t max_notify_retries
= 10;
47 std::string
get_control_oid(int i
);
48 RGWSI_RADOS::Obj
pick_control_obj(const std::string
& key
);
52 std::optional
<int> finisher_handle
;
53 RGWSI_Notify_ShutdownCB
*shutdown_cb
{nullptr};
55 bool finalized
{false};
57 int init_watch(const DoutPrefixProvider
*dpp
, optional_yield y
);
58 void finalize_watch();
60 void init(RGWSI_Zone
*_zone_svc
,
61 RGWSI_RADOS
*_rados_svc
,
62 RGWSI_Finisher
*_finisher_svc
) {
64 rados_svc
= _rados_svc
;
65 finisher_svc
= _finisher_svc
;
67 int do_start(optional_yield
, const DoutPrefixProvider
*dpp
) override
;
68 void shutdown() override
;
70 int unwatch(RGWSI_RADOS::Obj
& obj
, uint64_t watch_handle
);
71 void add_watcher(int i
);
72 void remove_watcher(int i
);
74 int watch_cb(const DoutPrefixProvider
*dpp
,
79 void _set_enabled(bool status
);
80 void set_enabled(bool status
);
82 int robust_notify(const DoutPrefixProvider
*dpp
, RGWSI_RADOS::Obj
& notify_obj
,
83 const RGWCacheNotifyInfo
& bl
, optional_yield y
);
85 void schedule_context(Context
*c
);
87 RGWSI_Notify(CephContext
*cct
): RGWServiceInstance(cct
) {}
89 virtual ~RGWSI_Notify() override
;
94 virtual int watch_cb(const DoutPrefixProvider
*dpp
,
99 virtual void set_enabled(bool status
) = 0;
102 int distribute(const DoutPrefixProvider
*dpp
, const std::string
& key
, const RGWCacheNotifyInfo
& bl
,
105 void register_watch_cb(CB
*cb
);