]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Zipper - Remove a number of casts from rgw_admin 47788/head
authorDaniel Gryniewicz <dang@redhat.com>
Wed, 17 Aug 2022 16:25:45 +0000 (12:25 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Wed, 31 Aug 2022 13:44:01 +0000 (09:44 -0400)
There are still a ton of casts to RadosStore in rgw_admin.  Remove the
easy ones.  Many of the rest represent actual operations that are
specific to RadosStore, and need to be split out.

Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_dbstore.cc
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_filter.h
src/rgw/rgw_sal_motr.cc
src/rgw/rgw_sal_motr.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h

index 843c890539351fc86adbf8eb6807a79745a5e884..4702ee30f2f57262edb17e0eb19fb3d3647f4e44 100644 (file)
@@ -1188,7 +1188,7 @@ static void show_reshard_status(
 class StoreDestructor {
   rgw::sal::Store* store;
 public:
-  explicit StoreDestructor(rgw::sal::RadosStore* _s) : store(_s) {}
+  explicit StoreDestructor(rgw::sal::Store* _s) : store(_s) {}
   ~StoreDestructor() {
     StoreManager::close_storage(store);
     rgw_http_client_cleanup();
@@ -2100,12 +2100,12 @@ static int do_period_pull(RGWRESTConn *remote_conn, const string& url,
   return 0;
 }
 
-static int read_current_period_id(rgw::sal::RadosStore* store, const std::string& realm_id,
+static int read_current_period_id(rgw::sal::Store* store, const std::string& realm_id,
                                   const std::string& realm_name,
                                   std::string* period_id)
 {
   RGWRealm realm(realm_id, realm_name);
-  int ret = realm.init(dpp(), g_ceph_context, store->svc()->sysobj, null_yield);
+  int ret = realm.init(dpp(), g_ceph_context, static_cast<rgw::sal::RadosStore*>(store)->svc()->sysobj, null_yield);
   if (ret < 0) {
     std::cerr << "failed to read realm: " << cpp_strerror(-ret) << std::endl;
     return ret;
@@ -2492,9 +2492,9 @@ static void sync_status(Formatter *formatter)
     const rgw_zone_id& source_id = iter.first;
     string source_str = "source: ";
     string s = source_str + source_id.id;
-    RGWZone *sz;
-    if ((sz = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(source_id))) {
-      s += string(" (") + sz->name + ")";
+    std::unique_ptr<rgw::sal::Zone> sz;
+    if (store->get_zone()->get_zonegroup().get_zone_by_id(source_id.id, &sz) == 0) {
+      s += string(" (") + sz->get_name() + ")";
     }
     data_status.push_back(s);
     get_data_sync_status(source_id, data_status, source_str.size());
@@ -2674,16 +2674,14 @@ static void get_hint_entities(const std::set<rgw_zone_id>& zones, const std::set
 
 static rgw_zone_id resolve_zone_id(const string& s)
 {
-  rgw_zone_id result;
-
-  RGWZone *zone;
-  if ((zone = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(s))) {
+  std::unique_ptr<rgw::sal::Zone> zone;
+  int ret = store->get_zone()->get_zonegroup().get_zone_by_id(s, &zone);
+  if (ret < 0)
+    ret = store->get_zone()->get_zonegroup().get_zone_by_name(s, &zone);
+  if (ret < 0)
     return rgw_zone_id(s);
-  }
-  if (static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone_id_by_name(s, &result)) {
-    return result;
-  }
-  return rgw_zone_id(s);
+
+  return rgw_zone_id(zone->get_id());
 }
 
 rgw_zone_id validate_zone_id(const rgw_zone_id& zone_id)
@@ -2695,7 +2693,7 @@ static int sync_info(std::optional<rgw_zone_id> opt_target_zone, std::optional<r
 {
   rgw_zone_id zone_id = opt_target_zone.value_or(store->get_zone()->get_id());
 
-  auto zone_policy_handler = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_sync_policy_handler(zone_id);
+  auto zone_policy_handler = store->get_zone()->get_sync_policy_handler();
 
   RGWBucketSyncPolicyHandlerRef bucket_handler;
 
@@ -2804,7 +2802,7 @@ static int sync_info(std::optional<rgw_zone_id> opt_target_zone, std::optional<r
   return 0;
 }
 
-static int bucket_sync_info(rgw::sal::RadosStore* store, const RGWBucketInfo& info,
+static int bucket_sync_info(rgw::sal::Store* store, const RGWBucketInfo& info,
                               std::ostream& out)
 {
   const rgw::sal::ZoneGroup& zonegroup = store->get_zone()->get_zonegroup();
@@ -2842,7 +2840,7 @@ static int bucket_sync_info(rgw::sal::RadosStore* store, const RGWBucketInfo& in
   return 0;
 }
 
-static int bucket_sync_status(rgw::sal::RadosStore* store, const RGWBucketInfo& info,
+static int bucket_sync_status(rgw::sal::Store* store, const RGWBucketInfo& info,
                               const rgw_zone_id& source_zone_id,
                              std::optional<rgw_bucket>& opt_source_bucket,
                               std::ostream& out)
@@ -2878,21 +2876,26 @@ static int bucket_sync_status(rgw::sal::RadosStore* store, const RGWBucketInfo&
   set<rgw_zone_id> zone_ids;
 
   if (!source_zone_id.empty()) {
-    auto z = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_zonegroup().zones.find(source_zone_id);
-    if (z == static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_zonegroup().zones.end()) {
+    std::unique_ptr<rgw::sal::Zone> zone;
+    int ret = store->get_zone()->get_zonegroup().get_zone_by_id(source_zone_id.id, &zone);
+    if (ret < 0) {
       ldpp_dout(dpp(), -1) << "Source zone not found in zonegroup "
           << zonegroup.get_name() << dendl;
       return -EINVAL;
     }
     auto c = zone_conn_map.find(source_zone_id);
     if (c == zone_conn_map.end()) {
-      ldpp_dout(dpp(), -1) << "No connection to zone " << z->second.name << dendl;
+      ldpp_dout(dpp(), -1) << "No connection to zone " << zone->get_name() << dendl;
       return -EINVAL;
     }
     zone_ids.insert(source_zone_id);
   } else {
-    for (const auto& entry : static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_zonegroup().zones) {
-      zone_ids.insert(entry.second.id);
+    std::list<std::string> ids;
+    int ret = store->get_zone()->get_zonegroup().list_zones(ids);
+    if (ret == 0) {
+      for (const auto& entry : ids) {
+       zone_ids.insert(entry);
+      }
     }
   }
 
@@ -2913,7 +2916,7 @@ static int bucket_sync_status(rgw::sal::RadosStore* store, const RGWBucketInfo&
        continue;
       }
       if (pipe.source.zone.value_or(rgw_zone_id()) == z->second.id) {
-       bucket_source_sync_status(dpp(), store, static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_zone(), z->second,
+       bucket_source_sync_status(dpp(), static_cast<rgw::sal::RadosStore*>(store), static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_zone(), z->second,
                                  c->second,
                                  info, pipe,
                                  width, out);
@@ -2976,7 +2979,7 @@ static int check_pool_support_omap(const rgw_pool& pool)
   return 0;
 }
 
-int check_reshard_bucket_params(rgw::sal::RadosStore* store,
+int check_reshard_bucket_params(rgw::sal::Store* store,
                                const string& bucket_name,
                                const string& tenant,
                                const string& bucket_id,
@@ -3087,10 +3090,6 @@ static int trim_sync_error_log(int shard_id, const string& marker, int delay_ms)
   // unreachable
 }
 
-const string& get_tier_type(rgw::sal::RadosStore* store) {
-  return store->svc()->zone->get_zone().tier_type;
-}
-
 static bool symmetrical_flow_opt(const string& opt)
 {
   return (opt == "symmetrical" || opt == "symmetric");
@@ -3229,9 +3228,13 @@ void resolve_zone_id_opt(std::optional<string>& zone_name, std::optional<rgw_zon
     return;
   }
   zone_id.emplace();
-  if (!static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone_id_by_name(*zone_name, &(*zone_id))) {
+  std::unique_ptr<rgw::sal::Zone> zone;
+  int ret = store->get_zone()->get_zonegroup().get_zone_by_name(*zone_name, &zone);
+  if (ret < 0) {
     cerr << "WARNING: cannot find source zone id for name=" << *zone_name << std::endl;
     zone_id = rgw_zone_id(*zone_name);
+  } else {
+    zone_id->id = zone->get_id();
   }
 }
 void resolve_zone_ids_opt(std::optional<vector<string> >& names, std::optional<vector<rgw_zone_id> >& ids)
@@ -3242,9 +3245,13 @@ void resolve_zone_ids_opt(std::optional<vector<string> >& names, std::optional<v
   ids.emplace();
   for (auto& name : *names) {
     rgw_zone_id zid;
-    if (!static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone_id_by_name(name, &zid)) {
+    std::unique_ptr<rgw::sal::Zone> zone;
+    int ret = store->get_zone()->get_zonegroup().get_zone_by_name(name, &zone);
+    if (ret < 0) {
       cerr << "WARNING: cannot find source zone id for name=" << name << std::endl;
       zid = rgw_zone_id(name);
+    } else {
+      zid.id = zone->get_id();
     }
     ids->push_back(zid);
   }
@@ -3266,9 +3273,9 @@ class JSONFormatter_PrettyZone : public JSONFormatter {
     void encode_json(const char *name, const void *pval, ceph::Formatter *f) const override {
       auto zone_id = *(static_cast<const rgw_zone_id *>(pval));
       string zone_name;
-      RGWZone *zone;
-      if ((zone = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(zone_id))) {
-        zone_name = zone->name;
+      std::unique_ptr<rgw::sal::Zone> zone;
+      if (store->get_zone()->get_zonegroup().get_zone_by_id(zone_id.id, &zone) == 0) {
+        zone_name = zone->get_name();
       } else {
         cerr << "WARNING: cannot find zone name for id=" << zone_id << std::endl;
         zone_name = zone_id.id;
@@ -4473,9 +4480,12 @@ int main(int argc, const char **argv)
   }
 
   if (!source_zone_name.empty()) {
-    if (!static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone_id_by_name(source_zone_name, &source_zone)) {
+    std::unique_ptr<rgw::sal::Zone> zone;
+    if (store->get_zone()->get_zonegroup().get_zone_by_name(source_zone_name, &zone) < 0) {
       cerr << "WARNING: cannot find source zone id for name=" << source_zone_name << std::endl;
       source_zone = source_zone_name;
+    } else {
+      source_zone.id = zone->get_id();
     }
   }
 
@@ -4492,7 +4502,7 @@ int main(int argc, const char **argv)
 
   oath_init();
 
-  StoreDestructor store_destructor(static_cast<rgw::sal::RadosStore*>(store));
+  StoreDestructor store_destructor(store);
 
   if (raw_storage_op) {
     try_to_resolve_local_entities(realm_id, realm_name,
@@ -4552,7 +4562,7 @@ int main(int argc, const char **argv)
       break;
     case OPT::PERIOD_GET_CURRENT:
       {
-        int ret = read_current_period_id(static_cast<rgw::sal::RadosStore*>(store), realm_id, realm_name, &period_id);
+        int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
        if (ret < 0) {
          return -ret;
        }
@@ -4902,7 +4912,7 @@ int main(int argc, const char **argv)
       break;
     case OPT::REALM_LIST_PERIODS:
       {
-        int ret = read_current_period_id(static_cast<rgw::sal::RadosStore*>(store), realm_id, realm_name, &period_id);
+        int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
        if (ret < 0) {
          return -ret;
        }
@@ -5919,7 +5929,7 @@ int main(int argc, const char **argv)
     case OPT::ZONE_LIST:
       {
        list<string> zones;
-       int ret = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->list_zones(dpp(), zones);
+       int ret = store->list_all_zones(dpp(), zones);
        if (ret < 0) {
          cerr << "failed to list zones: " << cpp_strerror(-ret) << std::endl;
          return -ret;
@@ -7826,7 +7836,7 @@ next:
   }
 
   if (opt_cmd == OPT::BUCKET_RESHARD) {
-    int ret = check_reshard_bucket_params(static_cast<rgw::sal::RadosStore*>(store),
+    int ret = check_reshard_bucket_params(store,
                                          bucket_name,
                                          tenant,
                                          bucket_id,
@@ -7877,7 +7887,7 @@ next:
   }
 
   if (opt_cmd == OPT::RESHARD_ADD) {
-    int ret = check_reshard_bucket_params(static_cast<rgw::sal::RadosStore*>(store),
+    int ret = check_reshard_bucket_params(store,
                                          bucket_name,
                                          tenant,
                                          bucket_id,
@@ -8450,9 +8460,7 @@ next:
     RGWStorageStats stats(omit_utilized_stats);
     ceph::real_time last_stats_sync;
     ceph::real_time last_stats_update;
-    int ret = static_cast<rgw::sal::RadosStore*>(store)->ctl()->user->read_stats(dpp(), user->get_id(), &stats, null_yield,
-                                                                                &last_stats_sync,
-                                                                                &last_stats_update);
+    int ret = user->read_stats(dpp(), null_yield, &stats, &last_stats_sync, &last_stats_update);
     if (ret < 0) {
       if (ret == -ENOENT) { /* in case of ENOENT */
         cerr << "User has not been initialized or user does not exist" << std::endl;
@@ -8583,7 +8591,7 @@ next:
     int i = (specified_shard_id ? shard_id : 0);
 
     if (period_id.empty()) {
-      int ret = read_current_period_id(static_cast<rgw::sal::RadosStore*>(store), realm_id, realm_name, &period_id);
+      int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
       if (ret < 0) {
         return -ret;
       }
@@ -8628,7 +8636,7 @@ next:
     int i = (specified_shard_id ? shard_id : 0);
 
     if (period_id.empty()) {
-      int ret = read_current_period_id(static_cast<rgw::sal::RadosStore*>(store), realm_id, realm_name, &period_id);
+      int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
       if (ret < 0) {
         return -ret;
       }
@@ -9035,7 +9043,7 @@ next:
     if (ret < 0) {
       return -ret;
     }
-    bucket_sync_info(static_cast<rgw::sal::RadosStore*>(store), bucket->get_info(), std::cout);
+    bucket_sync_info(store, bucket->get_info(), std::cout);
   }
 
   if (opt_cmd == OPT::BUCKET_SYNC_STATUS) {
@@ -9047,7 +9055,7 @@ next:
     if (ret < 0) {
       return -ret;
     }
-    bucket_sync_status(static_cast<rgw::sal::RadosStore*>(store), bucket->get_info(), source_zone, opt_source_bucket, std::cout);
+    bucket_sync_status(store, bucket->get_info(), source_zone, opt_source_bucket, std::cout);
   }
 
   if (opt_cmd == OPT::BUCKET_SYNC_MARKERS) {
@@ -10280,7 +10288,7 @@ next:
   }
 
   if (opt_cmd == OPT::PUBSUB_SUB_GET) {
-    if (get_tier_type(static_cast<rgw::sal::RadosStore*>(store)) != "pubsub") {
+    if (store->get_zone()->get_tier_type() != "pubsub") {
       cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
       return EINVAL;
     }
@@ -10304,7 +10312,7 @@ next:
   }
 
  if (opt_cmd == OPT::PUBSUB_SUB_RM) {
-    if (get_tier_type(static_cast<rgw::sal::RadosStore*>(store)) != "pubsub") {
+    if (store->get_zone()->get_tier_type() != "pubsub") {
       cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
       return EINVAL;
     }
@@ -10324,7 +10332,7 @@ next:
   }
 
  if (opt_cmd == OPT::PUBSUB_SUB_PULL) {
-    if (get_tier_type(static_cast<rgw::sal::RadosStore*>(store)) != "pubsub") {
+    if (store->get_zone()->get_tier_type() != "pubsub") {
       cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
       return EINVAL;
     }
@@ -10349,7 +10357,7 @@ next:
  }
 
  if (opt_cmd == OPT::PUBSUB_EVENT_RM) {
-    if (get_tier_type(static_cast<rgw::sal::RadosStore*>(store)) != "pubsub") {
+    if (store->get_zone()->get_tier_type() != "pubsub") {
       cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
       return EINVAL;
     }
@@ -10458,7 +10466,7 @@ next:
       cerr << "ERROR: lua package name was not provided (via --package)" << std::endl;
       return EINVAL;
     }
-    const auto rc = rgw::lua::add_package(dpp(), static_cast<rgw::sal::RadosStore*>(store), null_yield, *script_package, bool(allow_compilation));
+    const auto rc = rgw::lua::add_package(dpp(), store, null_yield, *script_package, bool(allow_compilation));
     if (rc < 0) {
       cerr << "ERROR: failed to add lua package: " << script_package << " .error: " << rc << std::endl;
       return -rc;
@@ -10475,7 +10483,7 @@ next:
       cerr << "ERROR: lua package name was not provided (via --package)" << std::endl;
       return EINVAL;
     }
-    const auto rc = rgw::lua::remove_package(dpp(), static_cast<rgw::sal::RadosStore*>(store), null_yield, *script_package);
+    const auto rc = rgw::lua::remove_package(dpp(), store, null_yield, *script_package);
     if (rc == -ENOENT) {
       cerr << "WARNING: package " << script_package << " did not exists or already removed" << std::endl;
       return 0;
@@ -10493,7 +10501,7 @@ next:
   if (opt_cmd == OPT::SCRIPT_PACKAGE_LIST) {
 #ifdef WITH_RADOSGW_LUA_PACKAGES
     rgw::lua::packages_t packages;
-    const auto rc = rgw::lua::list_packages(dpp(), static_cast<rgw::sal::RadosStore*>(store), null_yield, packages);
+    const auto rc = rgw::lua::list_packages(dpp(), store, null_yield, packages);
     if (rc == -ENOENT) {
       std::cout << "no lua packages in allowlist" << std::endl;
     } else if (rc < 0) {
index e6669479719e62d82d0c20be4a67754000d0b68c..46280e66623978fe13ee93f536c9b58d69b586cf 100644 (file)
@@ -316,6 +316,8 @@ class Store {
     virtual std::string zone_unique_trans_id(const uint64_t unique_num) = 0;
     /** Lookup a zonegroup by ID */
     virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) = 0;
+    /** List all zones in all zone groups by ID */
+    virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) = 0;
     /** Get statistics about the cluster represented by this Store */
     virtual int cluster_stat(RGWClusterStat& stats) = 0;
     /** Get a @a Lifecycle object. Used to manage/run lifecycle transitions */
@@ -1467,6 +1469,8 @@ public:
   virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) = 0;
   /** Get a zone by Name */
   virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) = 0;
+  /** List zones in zone group by ID */
+  virtual int list_zones(std::list<std::string>& zone_ids) = 0;
   /** Clone a copy of this zonegroup. */
   virtual std::unique_ptr<ZoneGroup> clone() = 0;
 };
@@ -1505,6 +1509,8 @@ class Zone {
     virtual const std::string& get_realm_id() = 0;
     /** Get the tier type for the zone */
     virtual const std::string_view get_tier_type() = 0;
+    /** Get a handler for zone sync policy. */
+    virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() = 0;
 };
 
 /**
index 970f3edbde5ad488d8bf9649a1ee5521cce67b31..e8f39b43243e8323abcdcaa46b21f4ff8120383b 100644 (file)
@@ -597,6 +597,11 @@ namespace rgw::sal {
     return realm->get_id();
   }
 
+  RGWBucketSyncPolicyHandlerRef DBZone::get_sync_policy_handler()
+  {
+    return nullptr;
+  }
+
   std::unique_ptr<LuaManager> DBStore::get_lua_manager()
   {
     return std::make_unique<DBLuaManager>(this);
@@ -1751,6 +1756,13 @@ namespace rgw::sal {
     return 0;
   }
 
+  int DBStore::list_all_zones(const DoutPrefixProvider* dpp,
+                             std::list<std::string>& zone_ids)
+  {
+    zone_ids.push_back(zone.get_id());
+    return 0;
+  }
+
   int DBStore::cluster_stat(RGWClusterStat& stats)
   {
     return 0;
index 7f10ba7e75a4ca332802009147c0425b75b91745..85c320432bb6b76236be8c2ccdab1e1a0b3e4fcb 100644 (file)
@@ -296,6 +296,10 @@ protected:
     virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override {
       return -1;
     }
+    virtual int list_zones(std::list<std::string>& zone_ids) override {
+      zone_ids.clear();
+      return 0;
+    }
     virtual std::unique_ptr<ZoneGroup> clone() override {
       std::unique_ptr<RGWZoneGroup>zg = std::make_unique<RGWZoneGroup>(*group.get());
       return std::make_unique<DBZoneGroup>(store, std::move(zg));
@@ -349,6 +353,7 @@ protected:
       virtual const std::string& get_realm_name() override;
       virtual const std::string& get_realm_id() override;
       virtual const std::string_view get_tier_type() override { return "rgw"; }
+      virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() override;
   };
 
   class DBLuaManager : public StoreLuaManager {
@@ -791,6 +796,7 @@ public:
       virtual std::string zone_unique_id(uint64_t unique_num) override;
       virtual std::string zone_unique_trans_id(const uint64_t unique_num) override;
       virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
+      virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override;
       virtual int cluster_stat(RGWClusterStat& stats) override;
       virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
       virtual std::unique_ptr<Completions> get_completions(void) override;
index d64952a3d5bb063d69999aa1e3cdd667883f63ba..a422d2b4c23610d3c7ae4cb9adadffaeb8f3d4bd 100644 (file)
@@ -81,6 +81,8 @@ public:
   virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier) override;
   virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override;
   virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override;
+  virtual int list_zones(std::list<std::string>& zone_ids) override
+    { return next->list_zones(zone_ids); }
   virtual std::unique_ptr<ZoneGroup> clone() override {
     std::unique_ptr<ZoneGroup> nzg = next->clone();
     return std::make_unique<FilterZoneGroup>(std::move(nzg));
@@ -137,6 +139,9 @@ public:
   virtual const std::string_view get_tier_type() override {
       return next->get_tier_type();
   }
+  virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() override {
+    return next->get_sync_policy_handler();
+  }
 };
 
 class FilterStore : public Store {
@@ -188,6 +193,9 @@ public:
   virtual std::string zone_unique_id(uint64_t unique_num) override;
   virtual std::string zone_unique_trans_id(const uint64_t unique_num) override;
   virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
+  virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override {
+    return next->list_all_zones(dpp, zone_ids);
+  }
   virtual int cluster_stat(RGWClusterStat& stats) override;
   virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
   virtual std::unique_ptr<Completions> get_completions(void) override;
index d4b91faaf4aded29a89c864b0c523de34e9fb46b..a40b1ac896be2b8b17b619f59d7917d5bbe65885 100644 (file)
@@ -2949,6 +2949,13 @@ int MotrStore::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>*
   return 0;
 }
 
+int MotrStore::list_all_zones(const DoutPrefixProvider* dpp,
+                            std::list<std::string>& zone_ids)
+{
+  zone_ids.push_back(zone.get_id());
+    return 0;
+}
+
 int MotrStore::cluster_stat(RGWClusterStat& stats)
 {
   return 0;
index 91e45d5e5cc3e418e15ecf12bf7ed426a92157a2..b773d0eab102ff71ed229cf9824b51ceb72daad9 100644 (file)
@@ -409,6 +409,10 @@ public:
   virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override {
     return -1;
   }
+  virtual int list_zones(std::list<std::string>& zone_ids) override {
+    zone_ids.clear();
+    return 0;
+  }
   const RGWZoneGroup& get_group() { return group; }
   virtual std::unique_ptr<ZoneGroup> clone() override {
     return std::make_unique<MotrZoneGroup>(store, group);
@@ -467,6 +471,7 @@ class MotrZone : public StoreZone {
     virtual const std::string& get_realm_name() { return realm->get_name(); }
     virtual const std::string& get_realm_id() { return realm->get_id(); }
     virtual const std::string_view get_tier_type() { return "rgw"; }
+    virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() { return nullptr; }
     friend class MotrStore;
 };
 
@@ -932,6 +937,7 @@ class MotrStore : public StoreStore {
     virtual std::string zone_unique_id(uint64_t unique_num) override;
     virtual std::string zone_unique_trans_id(const uint64_t unique_num) override;
     virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
+    virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override;
     virtual int cluster_stat(RGWClusterStat& stats) override;
     virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
     virtual std::unique_ptr<Completions> get_completions(void) override;
index 25d01dc8b37376a50940b1e60e83b2f99f5c7c03..79b3915e5660283a7acba5ebfb92a3f03f3cee04 100644 (file)
@@ -1232,6 +1232,11 @@ int RadosStore::get_zonegroup(const std::string& id,
   return 0;
 }
 
+int RadosStore::list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids)
+{
+  return svc()->zone->list_zones(dpp, zone_ids);
+}
+
 int RadosStore::cluster_stat(RGWClusterStat& stats)
 {
   rados_cluster_stat_t rados_stats;
@@ -3019,6 +3024,15 @@ int RadosZoneGroup::get_zone_by_name(const std::string& name, std::unique_ptr<Zo
   return 0;
 }
 
+int RadosZoneGroup::list_zones(std::list<std::string>& zone_ids)
+{
+  for (const auto& entry : group.zones)
+    {
+      zone_ids.push_back(entry.second.id);
+    }
+  return 0;
+}
+
 std::unique_ptr<Zone> RadosZone::clone()
 {
   if (local_zone)
@@ -3093,6 +3107,11 @@ const std::string_view RadosZone::get_tier_type()
   return rgw_zone.id;
 }
 
+RGWBucketSyncPolicyHandlerRef RadosZone::get_sync_policy_handler()
+{
+  return store->svc()->zone->get_sync_policy_handler(get_id());
+}
+
 RadosLuaManager::RadosLuaManager(RadosStore* _s) : 
   store(_s),
   pool((store->svc() && store->svc()->zone) ? store->svc()->zone->get_zone_params().log_pool : rgw_pool())
index 91677d838d7a77fb893fb7c98a8c9b57efed49e6..d183d68d755d2aca183bbfeffc789a77fe10914e 100644 (file)
@@ -87,6 +87,7 @@ public:
   virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier);
   virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override;
   virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override;
+  virtual int list_zones(std::list<std::string>& zone_ids) override;
   virtual std::unique_ptr<ZoneGroup> clone() override {
     return std::make_unique<RadosZoneGroup>(store, group);
   }
@@ -115,7 +116,8 @@ class RadosZone : public StoreZone {
     virtual const RGWAccessKey& get_system_key() override;
     virtual const std::string& get_realm_name() override;
     virtual const std::string& get_realm_id() override;
-       virtual const std::string_view get_tier_type() override;
+    virtual const std::string_view get_tier_type() override;
+    virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() override;
 };
 
 class RadosStore : public StoreStore {
@@ -158,6 +160,7 @@ class RadosStore : public StoreStore {
     virtual std::string zone_unique_id(uint64_t unique_num) override;
     virtual std::string zone_unique_trans_id(const uint64_t unique_num) override;
     virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
+    virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override;
     virtual int cluster_stat(RGWClusterStat& stats) override;
     virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
     virtual std::unique_ptr<Completions> get_completions(void) override;