]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: es sync module, store custom metadata
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 19 Aug 2016 12:31:09 +0000 (05:31 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 7 Oct 2016 17:31:23 +0000 (10:31 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_sync_module_es.cc

index 3e74f488266ee8333b1e83a563f55fbe2981f84e..b1b1e26d59e0e3c5a078d7e8965db3e8d72e03a1 100644 (file)
@@ -35,8 +35,10 @@ struct es_obj_metadata {
 
   void dump(Formatter *f) const {
     map<string, string> out_attrs;
+    map<string, string> custom_meta;
     RGWAccessControlPolicy policy;
     set<string> permissions;
+
     for (auto i : attrs) {
       const string& attr_name = i.first;
       string name;
@@ -46,6 +48,12 @@ struct es_obj_metadata {
         continue;
       }
 
+      if (attr_name.compare(0, sizeof(RGW_ATTR_META_PREFIX) - 1, RGW_ATTR_META_PREFIX) == 0) {
+        name = attr_name.substr(sizeof(RGW_ATTR_META_PREFIX) - 1);
+        custom_meta[name] = string(val.c_str(), (val.length() > 0 ? val.length() - 1 : 0));
+        continue;
+      }
+
       name = attr_name.substr(sizeof(RGW_ATTR_PREFIX) - 1);
 
       if (name == "acl") {
@@ -91,6 +99,13 @@ struct es_obj_metadata {
     for (auto i : out_attrs) {
       ::encode_json(i.first.c_str(), i.second, f);
     }
+    if (!custom_meta.empty()) {
+      f->open_object_section("custom");
+      for (auto i : custom_meta) {
+        ::encode_json(i.first.c_str(), i.second, f);
+      }
+      f->close_section();
+    }
     f->close_section();
   }