From 162c683d45a641ba94711e830ba8e4a03f76a7df Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 19 Aug 2016 02:19:29 -0700 Subject: [PATCH] rgw: es sync module, store object attrs Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync_module_es.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index ceb2b056963..10fa43afcfc 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -31,11 +31,35 @@ struct es_obj_metadata { size(_size), attrs(std::move(_attrs)) {} void dump(Formatter *f) const { - f->open_object_section("meta"); - ::encode_json("bucket", bucket_info.bucket.name, f); + map out_attrs; + for (auto i : attrs) { + const string& attr_name = i.first; + string name; + bufferlist& val = i.second; + + if (attr_name.compare(0, sizeof(RGW_ATTR_PREFIX) - 1, RGW_ATTR_PREFIX) != 0) { + continue; + } + + name = attr_name.substr(sizeof(RGW_ATTR_PREFIX) - 1); + + if (name == "acl") { + } else { + if (name != "pg_ver" && + name != "source_zone" && + name != "idtag") { + out_attrs[name] = string(val.c_str(), (val.length() > 0 ? val.length() - 1 : 0)); + } + } + } ::encode_json("name", key.name, f); ::encode_json("instance", key.instance, f); + f->open_object_section("meta"); + ::encode_json("bucket", bucket_info.bucket.name, f); ::encode_json("size", size, f); + for (auto i : out_attrs) { + ::encode_json(i.first.c_str(), i.second, f); + } f->close_section(); } -- 2.47.3