]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/services/svc_zone.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rgw / services / svc_zone.h
CommitLineData
9f95a23c
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab ft=cpp
11fdf7f2 3
9f95a23c 4#pragma once
11fdf7f2
TL
5
6#include "rgw/rgw_service.h"
7
8
9class RGWSI_RADOS;
10class RGWSI_SysObj;
11class RGWSI_SyncModules;
9f95a23c 12class RGWSI_Bucket_Sync;
11fdf7f2
TL
13
14class RGWRealm;
15class RGWZoneGroup;
16class RGWZone;
17class RGWZoneParams;
18class RGWPeriod;
19class RGWZonePlacementInfo;
20
9f95a23c
TL
21class RGWBucketSyncPolicyHandler;
22
11fdf7f2
TL
23class RGWRESTConn;
24
9f95a23c
TL
25struct rgw_sync_policy_info;
26
11fdf7f2
TL
27class 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};
9f95a23c 34 RGWSI_Bucket_Sync *bucket_sync_svc{nullptr};
11fdf7f2
TL
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};
9f95a23c 41 rgw_zone_id cur_zone_id;
11fdf7f2
TL
42 uint32_t zone_short_id{0};
43 bool writeable_zone{false};
9f95a23c
TL
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;
11fdf7f2
TL
48
49 RGWRESTConn *rest_master_conn{nullptr};
9f95a23c 50 map<rgw_zone_id, RGWRESTConn *> zone_conn_map;
81eedcae 51 std::vector<const RGWZone*> data_sync_source_zones;
9f95a23c 52 map<rgw_zone_id, RGWRESTConn *> zone_data_notify_to_map;
11fdf7f2
TL
53 map<string, RGWRESTConn *> zonegroup_conn_map;
54
9f95a23c
TL
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;
11fdf7f2
TL
59
60 void init(RGWSI_SysObj *_sysobj_svc,
f67539c2
TL
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;
11fdf7f2
TL
65 void shutdown() override;
66
f67539c2
TL
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);
11fdf7f2 71
f67539c2 72 int update_placement_map(optional_yield y);
11fdf7f2
TL
73public:
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
9f95a23c
TL
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 }
11fdf7f2
TL
90 uint32_t get_zone_short_id() const;
91
9f95a23c 92 const string& get_current_period_id() const;
11fdf7f2
TL
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);
9f95a23c
TL
98 bool sync_module_supports_writes() const { return writeable_zone; }
99 bool sync_module_exports_data() const { return exports_data; }
11fdf7f2
TL
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
9f95a23c 109 map<rgw_zone_id, RGWRESTConn *>& get_zone_conn_map() {
11fdf7f2
TL
110 return zone_conn_map;
111 }
112
81eedcae
TL
113 std::vector<const RGWZone*>& get_data_sync_source_zones() {
114 return data_sync_source_zones;
11fdf7f2
TL
115 }
116
9f95a23c 117 map<rgw_zone_id, RGWRESTConn *>& get_zone_data_notify_to_map() {
11fdf7f2
TL
118 return zone_data_notify_to_map;
119 }
120
9f95a23c 121 bool find_zone(const rgw_zone_id& id, RGWZone **zone);
11fdf7f2 122
9f95a23c 123 RGWRESTConn *get_zone_conn(const rgw_zone_id& zone_id);
11fdf7f2 124 RGWRESTConn *get_zone_conn_by_name(const string& name);
9f95a23c 125 bool find_zone_id_by_name(const string& name, rgw_zone_id *id);
11fdf7f2
TL
126
127 int select_bucket_placement(const RGWUserInfo& user_info, const string& zonegroup_id,
128 const rgw_placement_rule& rule,
f67539c2
TL
129 rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info, optional_yield y);
130 int select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info, optional_yield y);
11fdf7f2
TL
131 int select_new_bucket_location(const RGWUserInfo& user_info, const string& zonegroup_id,
132 const rgw_placement_rule& rule,
f67539c2
TL
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);
11fdf7f2 136
f67539c2
TL
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);
11fdf7f2
TL
140
141 bool is_meta_master() const;
142
9f95a23c 143 bool need_to_sync() const;
11fdf7f2
TL
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);
f67539c2 154 int list_periods(const string& current_period, list<string>& periods, optional_yield y);
11fdf7f2 155};