From 619244d81f5ecb6cd627682bd755e18ba29e7c0c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 9 Mar 2012 00:06:34 -0800 Subject: [PATCH] rgw: implement dump() for encoders Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_access.cc | 15 ++++++++++ src/rgw/rgw_acl.cc | 56 ++++++++++++++++++++++++++++++++++ src/rgw/rgw_cache.cc | 39 ++++++++++++++++++++++++ src/rgw/rgw_common.cc | 66 ++++++++++++++++++++++++++++++++++++++++ src/rgw/rgw_log.cc | 23 ++++++++++++++ src/rgw/rgw_rados.cc | 70 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 269 insertions(+) diff --git a/src/rgw/rgw_access.cc b/src/rgw/rgw_access.cc index 64eb3defeb321..52c7ffc1f44c8 100644 --- a/src/rgw/rgw_access.cc +++ b/src/rgw/rgw_access.cc @@ -18,6 +18,11 @@ void RGWObjManifestPart::generate_test_instances(std::list& void RGWObjManifestPart::dump(Formatter *f) const { + f->open_object_section("loc"); + loc.dump(f); + f->close_section(); + f->dump_unsigned("loc_ofs", loc_ofs); + f->dump_unsigned("size", size); } void RGWObjManifest::generate_test_instances(std::list& o) @@ -27,6 +32,16 @@ void RGWObjManifest::generate_test_instances(std::list& o) void RGWObjManifest::dump(Formatter *f) const { + map::const_iterator iter = objs.begin(); + f->open_array_section("objs"); + for (; iter != objs.end(); ++iter) { + f->dump_unsigned("ofs", iter->first); + f->open_object_section("part"); + iter->second.dump(f); + f->close_section(); + } + f->close_section(); + f->dump_unsigned("obj_size", obj_size); } RGWAccess* RGWAccess::store; diff --git a/src/rgw/rgw_acl.cc b/src/rgw/rgw_acl.cc index 7d8156ef22017..9846df3d77cf1 100644 --- a/src/rgw/rgw_acl.cc +++ b/src/rgw/rgw_acl.cc @@ -5,6 +5,8 @@ #include "include/types.h" +#include "common/Formatter.h" + #include "rgw_acl.h" #include "rgw_user.h" @@ -22,6 +24,7 @@ void ACLPermission::generate_test_instances(list& o) void ACLPermission::dump(Formatter *f) const { + f->dump_int("flags", flags); } void ACLGranteeType::generate_test_instances(list& o) @@ -31,6 +34,7 @@ void ACLGranteeType::generate_test_instances(list& o) void ACLGranteeType::dump(Formatter *f) const { + f->dump_unsigned("type", type); } void ACLGrant::generate_test_instances(list& o) @@ -40,6 +44,19 @@ void ACLGrant::generate_test_instances(list& o) void ACLGrant::dump(Formatter *f) const { + f->open_object_section("type"); + type.dump(f); + f->close_section(); + + f->dump_string("id", id); + f->dump_string("email", email); + + f->open_object_section("permission"); + permission.dump(f); + f->close_section(); + + f->dump_string("name", name); + f->dump_int("group", (int)group); } void RGWAccessControlList::generate_test_instances(list& o) @@ -49,6 +66,37 @@ void RGWAccessControlList::generate_test_instances(list& void RGWAccessControlList::dump(Formatter *f) const { + map::const_iterator acl_user_iter = acl_user_map.begin(); + f->open_array_section("acl_user_map"); + for (; acl_user_iter != acl_user_map.end(); ++acl_user_iter) { + f->open_object_section("entry"); + f->dump_string("user", acl_user_iter->first); + f->dump_int("acl", acl_user_iter->second); + f->close_section(); + } + f->close_section(); + + map::const_iterator acl_group_iter = acl_group_map.begin(); + f->open_array_section("acl_group_map"); + for (; acl_group_iter != acl_group_map.end(); ++acl_group_iter) { + f->open_object_section("entry"); + f->dump_unsigned("group", acl_group_iter->first); + f->dump_int("acl", acl_group_iter->second); + f->close_section(); + } + f->close_section(); + + multimap::const_iterator giter = grant_map.begin(); + f->open_array_section("grant_map"); + for (; giter != grant_map.end(); ++giter) { + f->open_object_section("entry"); + f->dump_string("id", giter->first); + f->open_object_section("grant"); + giter->second.dump(f); + f->close_section(); + f->close_section(); + } + f->close_section(); } void ACLOwner::generate_test_instances(list& o) @@ -58,6 +106,8 @@ void ACLOwner::generate_test_instances(list& o) void ACLOwner::dump(Formatter *f) const { + f->dump_string("id", id); + f->dump_string("display_name", display_name); } void RGWAccessControlPolicy::generate_test_instances(list& o) @@ -68,6 +118,12 @@ void RGWAccessControlPolicy::generate_test_instances(listopen_object_section("acl"); + acl.dump(f); + f->close_section(); + f->open_object_section("owner"); + owner.dump(f); + f->close_section(); } void RGWAccessControlList::_add_grant(ACLGrant *grant) diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index 641733d36c867..cf41ca5480d45 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -14,6 +14,8 @@ void ObjectMetaInfo::generate_test_instances(list& o) void ObjectMetaInfo::dump(Formatter *f) const { + f->dump_unsigned("size", size); + f->dump_stream("mtime") << mtime; } void ObjectCacheInfo::generate_test_instances(list& o) @@ -23,6 +25,34 @@ void ObjectCacheInfo::generate_test_instances(list& o) void ObjectCacheInfo::dump(Formatter *f) const { + f->dump_int("status", status); + f->dump_unsigned("flags", flags); + f->open_object_section("data"); + f->dump_unsigned("length", data.length()); + f->close_section(); + + map::const_iterator iter = xattrs.begin(); + f->open_array_section("xattrs"); + for (; iter != xattrs.end(); ++iter) { + f->dump_string("name", iter->first); + f->open_object_section("value"); + f->dump_unsigned("length", iter->second.length()); + f->close_section(); + } + f->close_section(); + + f->open_array_section("rm_xattrs"); + for (; iter != rm_xattrs.end(); ++iter) { + f->dump_string("name", iter->first); + f->open_object_section("value"); + f->dump_unsigned("length", iter->second.length()); + f->close_section(); + } + f->close_section(); + f->open_object_section("meta"); + meta.dump(f); + f->close_section(); + } void RGWCacheNotifyInfo::generate_test_instances(list& o) @@ -32,6 +62,15 @@ void RGWCacheNotifyInfo::generate_test_instances(list& o) void RGWCacheNotifyInfo::dump(Formatter *f) const { + f->dump_unsigned("op", op); + f->open_object_section("obj"); + obj.dump(f); + f->close_section(); + f->open_object_section("obj_info"); + obj_info.dump(f); + f->close_section(); + f->dump_unsigned("ofs", ofs); + f->dump_string("ns", ns); } int ObjectCache::get(string& name, ObjectCacheInfo& info, uint32_t mask) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 656814da1f855..34effb7908351 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -56,6 +56,9 @@ void RGWAccessKey::generate_test_instances(list& o) void RGWAccessKey::dump(Formatter *f) const { + f->dump_string("id", id); + f->dump_string("key", key); + f->dump_string("subuser", subuser); } void RGWSubUser::generate_test_instances(list& o) @@ -65,6 +68,8 @@ void RGWSubUser::generate_test_instances(list& o) void RGWSubUser::dump(Formatter *f) const { + f->dump_string("name", name); + f->dump_unsigned("perm_mask", perm_mask); } void RGWUserInfo::generate_test_instances(list& o) @@ -74,6 +79,41 @@ void RGWUserInfo::generate_test_instances(list& o) void RGWUserInfo::dump(Formatter *f) const { + f->dump_unsigned("auid", auid); + f->dump_string("user_id", user_id); + f->dump_string("display_name", display_name); + f->dump_string("user_email", user_email); + + map::const_iterator aiter = access_keys.begin(); + f->open_array_section("access_keys"); + for (; aiter != access_keys.end(); ++aiter) { + f->open_object_section("entry"); + f->dump_string("uid", aiter->first); + f->open_object_section("access_key"); + aiter->second.dump(f); + f->close_section(); + f->close_section(); + } + + aiter = swift_keys.begin(); + for (; aiter != swift_keys.end(); ++aiter) { + f->open_object_section("entry"); + f->dump_string("subuser", aiter->first); + f->open_object_section("key"); + aiter->second.dump(f); + f->close_section(); + f->close_section(); + } + map::const_iterator siter = subusers.begin(); + for (; siter != subusers.end(); ++siter) { + f->open_object_section("entry"); + f->dump_string("id", siter->first); + f->open_object_section("subuser"); + siter->second.dump(f); + f->close_section(); + f->close_section(); + } + f->dump_int("suspended", (int)suspended); } void rgw_bucket::generate_test_instances(list& o) @@ -83,6 +123,10 @@ void rgw_bucket::generate_test_instances(list& o) void rgw_bucket::dump(Formatter *f) const { + f->dump_string("name", name); + f->dump_string("pool", pool); + f->dump_string("marker", marker); + f->dump_unsigned("bucket_id", bucket_id); } void RGWBucketInfo::generate_test_instances(list& o) @@ -92,6 +136,11 @@ void RGWBucketInfo::generate_test_instances(list& o) void RGWBucketInfo::dump(Formatter *f) const { + f->open_object_section("bucket"); + bucket.dump(f); + f->close_section(); + f->dump_string("owner", owner); + f->dump_unsigned("flags", flags); } void RGWBucketEnt::generate_test_instances(list& o) @@ -101,6 +150,13 @@ void RGWBucketEnt::generate_test_instances(list& o) void RGWBucketEnt::dump(Formatter *f) const { + f->open_object_section("bucket"); + bucket.dump(f); + f->close_section(); + f->dump_unsigned("size", size); + f->dump_unsigned("size_rounded", size_rounded); + f->dump_stream("mtime") << mtime; + f->dump_unsigned("count", count); } void RGWUploadPartInfo::generate_test_instances(list& o) @@ -110,6 +166,10 @@ void RGWUploadPartInfo::generate_test_instances(list& o) void RGWUploadPartInfo::dump(Formatter *f) const { + f->dump_unsigned("num", num); + f->dump_unsigned("size", size); + f->dump_string("etag", etag); + f->dump_stream("modified") << modified; } void rgw_obj::generate_test_instances(list& o) @@ -119,6 +179,12 @@ void rgw_obj::generate_test_instances(list& o) void rgw_obj::dump(Formatter *f) const { + f->open_object_section("bucket"); + bucket.dump(f); + f->close_section(); + f->dump_string("key", key); + f->dump_string("ns", ns); + f->dump_string("object", object); } diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc index 57f13226ded5d..fcc5d2a776d8f 100644 --- a/src/rgw/rgw_log.cc +++ b/src/rgw/rgw_log.cc @@ -14,6 +14,24 @@ void rgw_log_entry::generate_test_instances(list& o) void rgw_log_entry::dump(Formatter *f) const { + f->dump_string("object_owner", object_owner); + f->dump_string("bucket_owner", bucket_owner); + f->dump_string("bucket", bucket); + f->dump_stream("time") << time; + f->dump_string("remote_addr", remote_addr); + f->dump_string("user", user); + f->dump_string("obj", obj); + f->dump_string("op", op); + f->dump_string("uri", uri); + f->dump_string("http_status", http_status); + f->dump_string("error_code", error_code); + f->dump_unsigned("bytes_sent", bytes_sent); + f->dump_unsigned("bytes_received", bytes_received); + f->dump_unsigned("obj_size", obj_size); + f->dump_stream("total_time") << total_time; + f->dump_string("user_agent", user_agent); + f->dump_string("referrer", referrer); + f->dump_unsigned("bucket_id", bucket_id); } void rgw_intent_log_entry::generate_test_instances(list& o) @@ -23,6 +41,11 @@ void rgw_intent_log_entry::generate_test_instances(list& void rgw_intent_log_entry::dump(Formatter *f) const { + f->open_object_section("obj"); + obj.dump(f); + f->close_section(); + f->dump_stream("op_time") << op_time; + f->dump_unsigned("intent", intent); } static rgw_bucket log_bucket(RGW_LOG_POOL_NAME); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 47e593abd189d..127bea683c783 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -52,6 +52,9 @@ void rgw_bucket_pending_info::generate_test_instances(listdump_int("state", (int)state); + f->dump_stream("timestamp") << timestamp; + f->dump_int("op", (int)op); } void rgw_bucket_dir_entry_meta::generate_test_instances(list& o) @@ -61,6 +64,14 @@ void rgw_bucket_dir_entry_meta::generate_test_instances(listdump_int("category", category); + f->dump_unsigned("size", size); + f->dump_stream("mtime") << mtime; + f->dump_string("etag", etag); + f->dump_string("owner", owner); + f->dump_string("owner_display_name", owner_display_name); + f->dump_string("tag", tag); + f->dump_string("content_type", content_type); } void rgw_bucket_dir_entry::generate_test_instances(list& o) @@ -70,6 +81,23 @@ void rgw_bucket_dir_entry::generate_test_instances(list& void rgw_bucket_dir_entry::dump(Formatter *f) const { + f->dump_string("name", name); + f->dump_unsigned("epoch", epoch); + f->dump_string("locator", locator); + f->dump_int("exists", (int)exists); + f->open_object_section("meta"); + meta.dump(f); + f->close_section(); + + map::const_iterator iter = pending_map.begin(); + f->open_array_section("pending_map"); + for (; iter != pending_map.end(); ++iter) { + f->dump_string("tag", iter->first); + f->open_object_section("info"); + iter->second.dump(f); + f->close_section(); + } + f->close_section(); } void rgw_bucket_category_stats::generate_test_instances(list& o) @@ -79,6 +107,9 @@ void rgw_bucket_category_stats::generate_test_instances(listdump_unsigned("total_size", total_size); + f->dump_unsigned("total_size_rounded", total_size_rounded); + f->dump_unsigned("num_entries", num_entries); } void rgw_bucket_dir_header::generate_test_instances(list& o) @@ -88,6 +119,15 @@ void rgw_bucket_dir_header::generate_test_instances(list void rgw_bucket_dir_header::dump(Formatter *f) const { + map::const_iterator iter = stats.begin(); + f->open_array_section("stats"); + for (; iter != stats.end(); ++iter) { + f->dump_int("category", (int)iter->first); + f->open_object_section("category_stats"); + iter->second.dump(f); + f->close_section(); + } + f->close_section(); } void rgw_bucket_dir::generate_test_instances(list& o) @@ -97,6 +137,18 @@ void rgw_bucket_dir::generate_test_instances(list& o) void rgw_bucket_dir::dump(Formatter *f) const { + f->open_object_section("header"); + header.dump(f); + f->close_section(); + map::const_iterator iter = m.begin(); + f->open_array_section("map"); + for (; iter != m.end(); ++iter) { + f->dump_string("obj", iter->first); + f->open_object_section("dir_entry"); + iter->second.dump(f); + f->close_section(); + } + f->close_section(); } void rgw_cls_obj_prepare_op::generate_test_instances(list& o) @@ -106,6 +158,10 @@ void rgw_cls_obj_prepare_op::generate_test_instances(listdump_int("op", op); + f->dump_string("name", name); + f->dump_string("tag", tag); + f->dump_string("locator", locator); } void rgw_cls_obj_complete_op::generate_test_instances(list& o) @@ -115,6 +171,14 @@ void rgw_cls_obj_complete_op::generate_test_instances(listdump_int("op", (int)op); + f->dump_string("name", name); + f->dump_string("locator", locator); + f->dump_unsigned("epoch", epoch); + f->open_object_section("meta"); + meta.dump(f); + f->close_section(); + f->dump_string("tag", tag); } void rgw_cls_list_op::generate_test_instances(list& o) @@ -124,6 +188,8 @@ void rgw_cls_list_op::generate_test_instances(list& o) void rgw_cls_list_op::dump(Formatter *f) const { + f->dump_string("start_obj", start_obj); + f->dump_unsigned("num_entries", num_entries); } void rgw_cls_list_ret::generate_test_instances(list& o) @@ -133,6 +199,10 @@ void rgw_cls_list_ret::generate_test_instances(list& o) void rgw_cls_list_ret::dump(Formatter *f) const { + f->open_object_section("dir"); + dir.dump(f); + f->close_section(); + f->dump_int("is_truncated", (int)is_truncated); } -- 2.39.5