]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add compression_type field to RGWZonePlacementInfo
authorCasey Bodley <cbodley@redhat.com>
Wed, 30 Nov 2016 14:45:14 +0000 (09:45 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 1 Dec 2016 01:06:13 +0000 (20:06 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_json_enc.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 12f25e1742f44975fd110191108c9b19a32fb4ea..ca4b1e372037ba77a5f5810cbf37648e73c65b60 100644 (file)
@@ -881,6 +881,7 @@ void RGWZonePlacementInfo::dump(Formatter *f) const
   encode_json("data_pool", data_pool, f);
   encode_json("data_extra_pool", data_extra_pool, f);
   encode_json("index_type", (uint32_t)index_type, f);
+  encode_json("compression", compression_type, f);
 }
 
 void RGWZonePlacementInfo::decode_json(JSONObj *obj)
@@ -891,6 +892,7 @@ void RGWZonePlacementInfo::decode_json(JSONObj *obj)
   uint32_t it;
   JSONDecoder::decode_json("index_type", it, obj);
   index_type = (RGWBucketIndexType)it;
+  JSONDecoder::decode_json("compression", compression_type, obj);
 }
 
 void RGWZoneParams::decode_json(JSONObj *obj)
index c6fb5cf36e16363a9725acffd79a8525673a0c71..979bea54b9cd28f370784091ad3afaecdd910ac2 100644 (file)
@@ -1654,6 +1654,17 @@ int RGWZoneParams::set_as_default(bool exclusive)
   return RGWSystemMetaObj::set_as_default(exclusive);
 }
 
+const string& RGWZoneParams::get_compression_type(const string& placement_rule) const
+{
+  static const std::string NONE{"none"};
+  auto p = placement_pools.find(placement_rule);
+  if (p == placement_pools.end()) {
+    return NONE;
+  }
+  const auto& type = p->second.compression_type;
+  return !type.empty() ? type : NONE;
+}
+
 void RGWPeriodMap::encode(bufferlist& bl) const {
   ENCODE_START(2, 1, bl);
   ::encode(id, bl);
index 3d44e8673c369a35e5943f4710bb54e286122792..32856a20aaea8b08a670815eea743f7e18302078 100644 (file)
@@ -933,20 +933,22 @@ struct RGWZonePlacementInfo {
   string data_pool;
   string data_extra_pool; /* if not set we should use data_pool */
   RGWBucketIndexType index_type;
+  std::string compression_type;
 
   RGWZonePlacementInfo() : index_type(RGWBIType_Normal) {}
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(5, 1, bl);
+    ENCODE_START(6, 1, bl);
     ::encode(index_pool, bl);
     ::encode(data_pool, bl);
     ::encode(data_extra_pool, bl);
     ::encode((uint32_t)index_type, bl);
+    ::encode(compression_type, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-    DECODE_START(5, bl);
+    DECODE_START(6, bl);
     ::decode(index_pool, bl);
     ::decode(data_pool, bl);
     if (struct_v >= 4) {
@@ -957,6 +959,9 @@ struct RGWZonePlacementInfo {
       ::decode(it, bl);
       index_type = (RGWBucketIndexType)it;
     }
+    if (struct_v >= 6) {
+      ::decode(compression_type, bl);
+    }
     DECODE_FINISH(bl);
   }
   const string& get_data_extra_pool() {
@@ -1013,6 +1018,8 @@ struct RGWZoneParams : RGWSystemMetaObj {
   int create_default(bool old_format = false);
   int create(bool exclusive = true);
   int fix_pool_names();
+
+  const string& get_compression_type(const string& placement_rule) const;
   
   void encode(bufferlist& bl) const {
     ENCODE_START(8, 1, bl);