From 9b0bf845bde44545b4c2d5dc6a6e6bbd7022e40a Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 19 Aug 2016 05:31:09 -0700 Subject: [PATCH] rgw: es sync module, store custom metadata Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync_module_es.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index 3e74f488266ee..b1b1e26d59e0e 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -35,8 +35,10 @@ struct es_obj_metadata { void dump(Formatter *f) const { map out_attrs; + map custom_meta; RGWAccessControlPolicy policy; set 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(); } -- 2.39.5