]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Zipper - Move generic get_zonegroup() to Store
authorDaniel Gryniewicz <dang@redhat.com>
Mon, 1 Aug 2022 17:11:36 +0000 (13:11 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Tue, 16 Aug 2022 16:31:27 +0000 (12:31 -0400)
The get_zonegroup() that looks up by ID doesn't belong in the zone.  It
was there because of a conflation of zone as an object an zone as an
interface.  Move it to Store where it belongs.

Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_dbstore.cc
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_filter.cc
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 7625ebd2ead4f8c278c68d58e6c93e81f4cd7ffd..3e0911e8946fa6931991784047141c10bb7add6d 100644 (file)
@@ -532,7 +532,7 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::Store* st
     s->bucket_owner = s->bucket_acl->get_owner();
 
     std::unique_ptr<rgw::sal::ZoneGroup> zonegroup;
-    int r = store->get_zone()->get_zonegroup(s->bucket->get_info().zonegroup, &zonegroup);
+    int r = store->get_zonegroup(s->bucket->get_info().zonegroup, &zonegroup);
     if (!r) {
       s->zonegroup_endpoint = zonegroup->get_endpoint();
       s->zonegroup_name = zonegroup->get_name();
index 6ebb1fc7d043049e74b60d7625b37717bb302545..6be3bbb8f29f9fc41dfbb2b5245e4cce92c4a97d 100644 (file)
@@ -2033,7 +2033,7 @@ void RGWGetBucketLocation_ObjStore_S3::send_response()
   std::unique_ptr<rgw::sal::ZoneGroup> zonegroup;
   string api_name;
 
-  int ret = store->get_zone()->get_zonegroup(s->bucket->get_info().zonegroup, &zonegroup);
+  int ret = store->get_zonegroup(s->bucket->get_info().zonegroup, &zonegroup);
   if (ret >= 0) {
     api_name = zonegroup->get_api_name();
   } else  {
index 190374119c2ea4f965f906e73641b741e67a74a5..9c74f2d5824f42da008a9b73564828a413ca41e5 100644 (file)
@@ -320,6 +320,8 @@ class Store {
     virtual std::string zone_unique_id(uint64_t unique_num) = 0;
     /** Get a unique Swift transaction ID specific to this zone */
     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;
     /** 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 */
@@ -1483,8 +1485,6 @@ class Zone {
     virtual std::unique_ptr<Zone> clone() = 0;
     /** Get info about the zonegroup containing this zone */
     virtual ZoneGroup& get_zonegroup() = 0;
-    /** Get info about a zonegroup by ID */
-    virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) = 0;
     /** Get the ID of this zone */
     virtual const rgw_zone_id& get_id() = 0;
     /** Get the name of this zone */
index 1ee859215242eb4eaba00acd300c8fa75c1f8eff..78a1a93fc3649f5c29e891ab474e609dcf9bb413 100644 (file)
@@ -540,17 +540,6 @@ namespace rgw::sal {
     return *zonegroup;
   }
 
-  int DBZone::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zg)
-  {
-    /* XXX: for now only one zonegroup supported */
-    ZoneGroup* group = new DBZoneGroup(store, std::make_unique<RGWZoneGroup>());
-    if (!group)
-      return -ENOMEM;
-
-    zg->reset(group);
-    return 0;
-  }
-
   const RGWZoneParams& DBZone::get_rgw_params()
   {
     return *zone_params;
@@ -1757,6 +1746,17 @@ namespace rgw::sal {
     return "";
   }
 
+  int DBStore::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zg)
+  {
+    /* XXX: for now only one zonegroup supported */
+    ZoneGroup* group = new DBZoneGroup(this, std::make_unique<RGWZoneGroup>());
+    if (!group)
+      return -ENOMEM;
+
+    zg->reset(group);
+    return 0;
+  }
+
   int DBStore::cluster_stat(RGWClusterStat& stats)
   {
     return 0;
index 259c8e6caa6024eb9f5899ddfc0364586aed516a..c61f86db0963e1a5cb828fd93bd9e4df2a7cfc87 100644 (file)
@@ -333,7 +333,6 @@ protected:
        return std::make_unique<DBZone>(store);
       }
       virtual ZoneGroup& get_zonegroup() override;
-      virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
       const RGWZoneParams& get_rgw_params();
       virtual const rgw_zone_id& get_id() override;
       virtual const std::string& get_name() const override;
@@ -794,6 +793,7 @@ public:
       virtual Zone* get_zone() { return &zone; }
       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 cluster_stat(RGWClusterStat& stats) override;
       virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
       virtual std::unique_ptr<Completions> get_completions(void) override;
index de2aa5f86b6c25b3a586fc0696b723a0b3f8abeb..23354f92ceae752eb74abc09474f99d0ed5d69d7 100644 (file)
@@ -65,21 +65,6 @@ int FilterZoneGroup::get_placement_tier(const rgw_placement_rule& rule,
   return 0;
 }
 
-int FilterZone::get_zonegroup(const std::string& id,
-                             std::unique_ptr<ZoneGroup>* zonegroup)
-{
-  std::unique_ptr<ZoneGroup> ngz;
-  int ret;
-
-  ret = next->get_zonegroup(id, &ngz);
-  if (ret != 0)
-    return ret;
-
-  ZoneGroup* zg = new FilterZoneGroup(std::move(ngz));
-  zonegroup->reset(zg);
-  return 0;
-}
-
 int FilterStore::initialize(CephContext *cct, const DoutPrefixProvider *dpp)
 {
   zone = std::make_unique<FilterZone>(next->get_zone()->clone());
@@ -232,6 +217,21 @@ std::string FilterStore::zone_unique_trans_id(uint64_t unique_num)
   return next->zone_unique_trans_id(unique_num);
 }
 
+int FilterStore::get_zonegroup(const std::string& id,
+                              std::unique_ptr<ZoneGroup>* zonegroup)
+{
+  std::unique_ptr<ZoneGroup> ngz;
+  int ret;
+
+  ret = next->get_zonegroup(id, &ngz);
+  if (ret != 0)
+    return ret;
+
+  ZoneGroup* zg = new FilterZoneGroup(std::move(ngz));
+  zonegroup->reset(zg);
+  return 0;
+}
+
 int FilterStore::cluster_stat(RGWClusterStat& stats)
 {
   return next->cluster_stat(stats);
index 01e347a8d021d6bcfbabf9a5d96155dd91a12b05..6b02dd1a41dc374da17ee7baaa8a67b89fa93021 100644 (file)
@@ -105,7 +105,6 @@ public:
   virtual ZoneGroup& get_zonegroup() override {
       return *group.get();
   }
-  virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
   virtual const rgw_zone_id& get_id() override {
       return next->get_id();
   }
@@ -186,6 +185,7 @@ public:
   virtual Zone* get_zone() override { return zone.get(); }
   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 cluster_stat(RGWClusterStat& stats) override;
   virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
   virtual std::unique_ptr<Completions> get_completions(void) override;
index ba4feef16ac31e6cd6bd8100fcc70238dcc14a21..28c111d8dd3b684d43a6c8bcf144ff44f2a1ed01 100644 (file)
@@ -899,16 +899,6 @@ ZoneGroup& MotrZone::get_zonegroup()
   return zonegroup;
 }
 
-int MotrZone::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* group)
-{
-  /* XXX: for now only one zonegroup supported */
-  ZoneGroup* zg;
-  zg = new MotrZoneGroup(store, zonegroup.get_group());
-
-  group->reset(zg);
-  return 0;
-}
-
 const rgw_zone_id& MotrZone::get_id()
 {
   return cur_zone_id;
@@ -2955,6 +2945,16 @@ std::string MotrStore::zone_unique_trans_id(const uint64_t unique_num)
   return "";
 }
 
+int MotrStore::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* group)
+{
+  /* XXX: for now only one zonegroup supported */
+  ZoneGroup* zg;
+  zg = new MotrZoneGroup(this, zone.zonegroup.get_group());
+
+  group->reset(zg);
+  return 0;
+}
+
 int MotrStore::cluster_stat(RGWClusterStat& stats)
 {
   return 0;
index 9f35d68f85c6370902f92e133eab699f2b29faae..6ab7b4187561ea1ff5b2e2c9d8b5a481f64b2739 100644 (file)
@@ -453,7 +453,6 @@ class MotrZone : public StoreZone {
       return std::make_unique<MotrZone>(store);
     }
     virtual ZoneGroup& get_zonegroup() override;
-    virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
     virtual const rgw_zone_id& get_id() override;
     virtual const std::string& get_name() const override;
     virtual bool is_writeable() override;
@@ -936,6 +935,7 @@ class MotrStore : public StoreStore {
     virtual Zone* get_zone() { return &zone; }
     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 cluster_stat(RGWClusterStat& stats) override;
     virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
     virtual std::unique_ptr<Completions> get_completions(void) override;
index c063467a2c81a7fec730c1ec95af511d3e003e13..ea93511d0839cff36afa2bb0abd1ac584c407eb6 100644 (file)
@@ -1183,6 +1183,23 @@ std::string RadosStore::zone_unique_trans_id(const uint64_t unique_num)
   return svc()->zone_utils->unique_trans_id(unique_num);
 }
 
+int RadosStore::get_zonegroup(const std::string& id,
+                             std::unique_ptr<ZoneGroup>* zonegroup)
+{
+  ZoneGroup* zg;
+  RGWZoneGroup rzg;
+  int r = svc()->zone->get_zonegroup(id, rzg);
+  if (r < 0)
+    return r;
+
+  zg = new RadosZoneGroup(this, rzg);
+  if (!zg)
+    return -ENOMEM;
+
+  zonegroup->reset(zg);
+  return 0;
+}
+
 int RadosStore::cluster_stat(RGWClusterStat& stats)
 {
   rados_cluster_stat_t rados_stats;
@@ -2943,22 +2960,6 @@ int RadosZoneGroup::get_placement_tier(const rgw_placement_rule& rule,
   return 0;
 }
 
-int RadosZone::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup)
-{
-  ZoneGroup* zg;
-  RGWZoneGroup rzg;
-  int r = store->svc()->zone->get_zonegroup(id, rzg);
-  if (r < 0)
-    return r;
-
-  zg = new RadosZoneGroup(store, rzg);
-  if (!zg)
-    return -ENOMEM;
-
-  zonegroup->reset(zg);
-  return 0;
-}
-
 const rgw_zone_id& RadosZone::get_id()
 {
   return store->svc()->zone->zone_id();
index e6965571ce408e93e054c3991cb8e599c30f797c..e9413e6f4269c9a83c47cb6b746968157ba2e8d2 100644 (file)
@@ -103,7 +103,6 @@ class RadosZone : public StoreZone {
       return std::make_unique<RadosZone>(store, group->clone());
     }
     virtual ZoneGroup& get_zonegroup() override { return *(group.get()); }
-    virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
     virtual const rgw_zone_id& get_id() override;
     virtual const std::string& get_name() const override;
     virtual bool is_writeable() override;
@@ -155,6 +154,7 @@ class RadosStore : public StoreStore {
     virtual Zone* get_zone() { return zone.get(); }
     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 cluster_stat(RGWClusterStat& stats) override;
     virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
     virtual std::unique_ptr<Completions> get_completions(void) override;