]>
Commit | Line | Data |
---|---|---|
eafe8130 | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
20effc67 | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
eafe8130 TL |
3 | |
4 | #pragma once | |
5 | ||
6 | #include <string> | |
7 | #include "common/ceph_time.h" | |
9f95a23c | 8 | #include "include/common_fwd.h" |
eafe8130 | 9 | #include "rgw_notify_event_type.h" |
f67539c2 TL |
10 | #include "common/async/yield_context.h" |
11 | #include "cls/2pc_queue/cls_2pc_queue_types.h" | |
12 | #include "rgw_pubsub.h" | |
eafe8130 TL |
13 | |
14 | // forward declarations | |
9f95a23c | 15 | namespace rgw::sal { |
20effc67 | 16 | class RadosStore; |
f67539c2 | 17 | class RGWObject; |
9f95a23c | 18 | } |
f67539c2 | 19 | |
eafe8130 | 20 | class RGWRados; |
9f95a23c | 21 | struct rgw_obj_key; |
eafe8130 TL |
22 | |
23 | namespace rgw::notify { | |
24 | ||
f67539c2 TL |
25 | // initialize the notification manager |
26 | // notification manager is dequeing the 2-phase-commit queues | |
27 | // and send the notifications to the endpoints | |
20effc67 | 28 | bool init(CephContext* cct, rgw::sal::RadosStore* store, const DoutPrefixProvider *dpp); |
f67539c2 TL |
29 | |
30 | // shutdown the notification manager | |
31 | void shutdown(); | |
32 | ||
33 | // create persistent delivery queue for a topic (endpoint) | |
34 | // this operation also add a topic name to the common (to all RGWs) list of all topics | |
35 | int add_persistent_topic(const std::string& topic_name, optional_yield y); | |
36 | ||
37 | // remove persistent delivery queue for a topic (endpoint) | |
38 | // this operation also remove the topic name from the common (to all RGWs) list of all topics | |
39 | int remove_persistent_topic(const std::string& topic_name, optional_yield y); | |
40 | ||
41 | // struct holding reservation information | |
42 | // populated in the publish_reserve call | |
43 | // then used to commit or abort the reservation | |
44 | struct reservation_t { | |
45 | struct topic_t { | |
20effc67 TL |
46 | topic_t(const std::string& _configurationId, const rgw_pubsub_topic& _cfg, |
47 | cls_2pc_reservation::id_t _res_id) : | |
48 | configurationId(_configurationId), cfg(_cfg), res_id(_res_id) {} | |
f67539c2 | 49 | |
20effc67 TL |
50 | std::string configurationId; |
51 | rgw_pubsub_topic cfg; | |
f67539c2 TL |
52 | // res_id is reset after topic is committed/aborted |
53 | cls_2pc_reservation::id_t res_id; | |
54 | }; | |
55 | ||
20effc67 | 56 | const DoutPrefixProvider* dpp; |
f67539c2 | 57 | std::vector<topic_t> topics; |
20effc67 | 58 | rgw::sal::RadosStore* const store; |
f67539c2 TL |
59 | const req_state* const s; |
60 | size_t size; | |
20effc67 TL |
61 | RGWObjectCtx* obj_ctx; |
62 | rgw::sal::Object* const object; | |
63 | rgw::sal::Object* const src_object; // may differ from object | |
64 | rgw::sal::Bucket* const bucket; | |
522d829b | 65 | const std::string* const object_name; |
20effc67 TL |
66 | boost::optional<RGWObjTags&> tagset; |
67 | meta_map_t x_meta_map; // metadata cached by value | |
68 | std::string user_id; | |
69 | std::string user_tenant; | |
70 | std::string req_id; | |
71 | optional_yield yield; | |
72 | ||
73 | /* ctor for rgw_op callers */ | |
74 | reservation_t(const DoutPrefixProvider* _dpp, | |
75 | rgw::sal::RadosStore* _store, | |
76 | req_state* _s, | |
77 | rgw::sal::Object* _object, | |
78 | rgw::sal::Object* _src_object, | |
79 | const std::string* _object_name); | |
80 | ||
81 | /* ctor for non-request caller (e.g., lifecycle) */ | |
82 | reservation_t(const DoutPrefixProvider* _dpp, | |
83 | rgw::sal::RadosStore* _store, | |
84 | RGWObjectCtx* _obj_ctx, | |
85 | rgw::sal::Object* _object, | |
86 | rgw::sal::Object* _src_object, | |
87 | rgw::sal::Bucket* _bucket, | |
88 | std::string& _user_id, | |
89 | std::string& _user_tenant, | |
90 | std::string& _req_id, | |
91 | optional_yield y); | |
f67539c2 TL |
92 | |
93 | // dtor doing resource leak guarding | |
94 | // aborting the reservation if not already committed or aborted | |
95 | ~reservation_t(); | |
96 | }; | |
97 | ||
98 | // create a reservation on the 2-phase-commit queue | |
20effc67 TL |
99 | int publish_reserve(const DoutPrefixProvider *dpp, |
100 | EventType event_type, | |
101 | reservation_t& reservation, | |
102 | const RGWObjTags* req_tags); | |
f67539c2 TL |
103 | |
104 | // commit the reservation to the queue | |
20effc67 | 105 | int publish_commit(rgw::sal::Object* obj, |
9f95a23c | 106 | uint64_t size, |
eafe8130 TL |
107 | const ceph::real_time& mtime, |
108 | const std::string& etag, | |
20effc67 | 109 | const std::string& version, |
eafe8130 | 110 | EventType event_type, |
b3b6e05e TL |
111 | reservation_t& reservation, |
112 | const DoutPrefixProvider *dpp); | |
f67539c2 TL |
113 | |
114 | // cancel the reservation | |
b3b6e05e | 115 | int publish_abort(const DoutPrefixProvider *dpp, reservation_t& reservation); |
eafe8130 TL |
116 | |
117 | } | |
118 |