1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
#pragma once
#include "rgw_service.h"
class RGWSI_RADOS;
class RGWSI_SysObj;
class RGWSI_SyncModules;
class RGWSI_Bucket_Sync;
class RGWRealm;
class RGWZoneGroup;
class RGWZone;
class RGWZoneParams;
class RGWPeriod;
class RGWZonePlacementInfo;
class RGWBucketSyncPolicyHandler;
class RGWRESTConn;
struct rgw_sync_policy_info;
class RGWSI_Zone : public RGWServiceInstance
{
friend struct RGWServices_Def;
RGWSI_SysObj *sysobj_svc{nullptr};
RGWSI_RADOS *rados_svc{nullptr};
RGWSI_SyncModules *sync_modules_svc{nullptr};
RGWSI_Bucket_Sync *bucket_sync_svc{nullptr};
RGWRealm *realm{nullptr};
RGWZoneGroup *zonegroup{nullptr};
RGWZone *zone_public_config{nullptr}; /* external zone params, e.g., entrypoints, log flags, etc. */
RGWZoneParams *zone_params{nullptr}; /* internal zone params, e.g., rados pools */
RGWPeriod *current_period{nullptr};
rgw_zone_id cur_zone_id;
uint32_t zone_short_id{0};
bool writeable_zone{false};
bool exports_data{false};
std::shared_ptr<RGWBucketSyncPolicyHandler> sync_policy_handler;
std::map<rgw_zone_id, std::shared_ptr<RGWBucketSyncPolicyHandler> > sync_policy_handlers;
RGWRESTConn *rest_master_conn{nullptr};
std::map<rgw_zone_id, RGWRESTConn *> zone_conn_map;
std::vector<const RGWZone*> data_sync_source_zones;
std::map<rgw_zone_id, RGWRESTConn *> zone_data_notify_to_map;
std::map<std::string, RGWRESTConn *> zonegroup_conn_map;
std::map<std::string, rgw_zone_id> zone_id_by_name;
std::map<rgw_zone_id, RGWZone> zone_by_id;
std::unique_ptr<rgw_sync_policy_info> sync_policy;
void init(RGWSI_SysObj *_sysobj_svc,
RGWSI_RADOS *_rados_svc,
RGWSI_SyncModules *_sync_modules_svc,
RGWSI_Bucket_Sync *_bucket_sync_svc);
int do_start(optional_yield y, const DoutPrefixProvider *dpp) override;
void shutdown() override;
int init_zg_from_period(const DoutPrefixProvider *dpp, optional_yield y);
int init_zg_from_local(const DoutPrefixProvider *dpp, optional_yield y);
int update_placement_map(const DoutPrefixProvider *dpp, optional_yield y);
int create_default_zg(const DoutPrefixProvider *dpp, optional_yield y);
int init_default_zone(const DoutPrefixProvider *dpp, optional_yield y);
int search_realm_with_zone(const DoutPrefixProvider *dpp,
const rgw_zone_id& zid,
RGWRealm *prealm,
RGWPeriod *pperiod,
RGWZoneGroup *pzonegroup,
bool *pfound,
optional_yield y);
public:
RGWSI_Zone(CephContext *cct);
~RGWSI_Zone();
const RGWZoneParams& get_zone_params() const;
const RGWPeriod& get_current_period() const;
const RGWRealm& get_realm() const;
const RGWZoneGroup& get_zonegroup() const;
int get_zonegroup(const std::string& id, RGWZoneGroup& zonegroup) const;
const RGWZone& get_zone() const;
std::shared_ptr<RGWBucketSyncPolicyHandler> get_sync_policy_handler(std::optional<rgw_zone_id> zone = std::nullopt) const;
const std::string& zone_name() const;
const rgw_zone_id& zone_id() const {
return cur_zone_id;
}
uint32_t get_zone_short_id() const;
const std::string& get_current_period_id() const;
bool has_zonegroup_api(const std::string& api) const;
bool zone_is_writeable();
bool zone_syncs_from(const RGWZone& target_zone, const RGWZone& source_zone) const;
bool zone_syncs_from(const RGWZone& source_zone) const;
bool get_redirect_zone_endpoint(std::string *endpoint);
bool sync_module_supports_writes() const { return writeable_zone; }
bool sync_module_exports_data() const { return exports_data; }
RGWRESTConn *get_master_conn() {
return rest_master_conn;
}
std::map<std::string, RGWRESTConn *>& get_zonegroup_conn_map() {
return zonegroup_conn_map;
}
std::map<rgw_zone_id, RGWRESTConn *>& get_zone_conn_map() {
return zone_conn_map;
}
std::vector<const RGWZone*>& get_data_sync_source_zones() {
return data_sync_source_zones;
}
std::map<rgw_zone_id, RGWRESTConn *>& get_zone_data_notify_to_map() {
return zone_data_notify_to_map;
}
RGWZone* find_zone(const rgw_zone_id& id);
RGWRESTConn *get_zone_conn(const rgw_zone_id& zone_id);
RGWRESTConn *get_zone_conn_by_name(const std::string& name);
bool find_zone_id_by_name(const std::string& name, rgw_zone_id *id);
int select_bucket_placement(const DoutPrefixProvider *dpp, const RGWUserInfo& user_info, const std::string& zonegroup_id,
const rgw_placement_rule& rule,
rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info, optional_yield y);
int select_legacy_bucket_placement(const DoutPrefixProvider *dpp, RGWZonePlacementInfo *rule_info, optional_yield y);
int select_new_bucket_location(const DoutPrefixProvider *dpp, const RGWUserInfo& user_info, const std::string& zonegroup_id,
const rgw_placement_rule& rule,
rgw_placement_rule *pselected_rule_name, RGWZonePlacementInfo *rule_info,
optional_yield y);
int select_bucket_location_by_rule(const DoutPrefixProvider *dpp, const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info, optional_yield y);
int add_bucket_placement(const DoutPrefixProvider *dpp, const rgw_pool& new_pool, optional_yield y);
int remove_bucket_placement(const DoutPrefixProvider *dpp, const rgw_pool& old_pool, optional_yield y);
int list_placement_set(const DoutPrefixProvider *dpp, std::set<rgw_pool>& names, optional_yield y);
bool is_meta_master() const;
bool need_to_sync() const;
bool need_to_log_data() const;
bool need_to_log_metadata() const;
bool can_reshard() const;
bool is_syncing_bucket_meta(const rgw_bucket& bucket);
int list_zonegroups(const DoutPrefixProvider *dpp, std::list<std::string>& zonegroups);
int list_regions(const DoutPrefixProvider *dpp, std::list<std::string>& regions);
int list_zones(const DoutPrefixProvider *dpp, std::list<std::string>& zones);
int list_realms(const DoutPrefixProvider *dpp, std::list<std::string>& realms);
int list_periods(const DoutPrefixProvider *dpp, std::list<std::string>& periods);
int list_periods(const DoutPrefixProvider *dpp, const std::string& current_period, std::list<std::string>& periods, optional_yield y);
};
|