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