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/rgw_service.h"
11 class RGWSI_SyncModules
;
12 class RGWSI_Bucket_Sync
;
19 class RGWZonePlacementInfo
;
21 class RGWBucketSyncPolicyHandler
;
25 struct rgw_sync_policy_info
;
27 class RGWSI_Zone
: public RGWServiceInstance
29 friend struct RGWServices_Def
;
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};
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};
46 std::shared_ptr
<RGWBucketSyncPolicyHandler
> sync_policy_handler
;
47 std::map
<rgw_zone_id
, std::shared_ptr
<RGWBucketSyncPolicyHandler
> > sync_policy_handlers
;
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
;
55 map
<string
, rgw_zone_id
> zone_id_by_name
;
56 map
<rgw_zone_id
, RGWZone
> zone_by_id
;
58 std::unique_ptr
<rgw_sync_policy_info
> sync_policy
;
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
;
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
);
72 int update_placement_map(optional_yield y
);
74 RGWSI_Zone(CephContext
*cct
);
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;
84 std::shared_ptr
<RGWBucketSyncPolicyHandler
> get_sync_policy_handler(std::optional
<rgw_zone_id
> zone
= nullopt
) const;
86 const string
& zone_name() const;
87 const rgw_zone_id
& zone_id() const {
90 uint32_t get_zone_short_id() const;
92 const string
& get_current_period_id() const;
93 bool has_zonegroup_api(const std::string
& api
) const;
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
; }
101 RGWRESTConn
*get_master_conn() {
102 return rest_master_conn
;
105 map
<string
, RGWRESTConn
*>& get_zonegroup_conn_map() {
106 return zonegroup_conn_map
;
109 map
<rgw_zone_id
, RGWRESTConn
*>& get_zone_conn_map() {
110 return zone_conn_map
;
113 std::vector
<const RGWZone
*>& get_data_sync_source_zones() {
114 return data_sync_source_zones
;
117 map
<rgw_zone_id
, RGWRESTConn
*>& get_zone_data_notify_to_map() {
118 return zone_data_notify_to_map
;
121 bool find_zone(const rgw_zone_id
& id
, RGWZone
**zone
);
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
);
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
,
135 int select_bucket_location_by_rule(const rgw_placement_rule
& location_rule
, RGWZonePlacementInfo
*rule_info
, optional_yield y
);
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
);
141 bool is_meta_master() const;
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
);
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
);