]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: implement dump() for encoders
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 9 Mar 2012 08:06:34 +0000 (00:06 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 9 Mar 2012 08:06:34 +0000 (00:06 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
src/rgw/rgw_access.cc
src/rgw/rgw_acl.cc
src/rgw/rgw_cache.cc
src/rgw/rgw_common.cc
src/rgw/rgw_log.cc
src/rgw/rgw_rados.cc

index 64eb3defeb321539a9b9020c4e58a2a3b7f2d6c8..52c7ffc1f44c8730f01d06af544865f498016701 100644 (file)
@@ -18,6 +18,11 @@ void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>&
 
 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<RGWObjManifest*>& o)
@@ -27,6 +32,16 @@ void RGWObjManifest::generate_test_instances(std::list<RGWObjManifest*>& o)
 
 void RGWObjManifest::dump(Formatter *f) const
 {
+  map<uint64_t, RGWObjManifestPart>::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;
index 7d8156ef2201723cc9c4671b8eabdf303d514783..9846df3d77cf1ed7e1227196053e4e065f42e2dc 100644 (file)
@@ -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<ACLPermission*>& o)
 
 void ACLPermission::dump(Formatter *f) const
 {
+  f->dump_int("flags", flags);
 }
 
 void ACLGranteeType::generate_test_instances(list<ACLGranteeType*>& o)
@@ -31,6 +34,7 @@ void ACLGranteeType::generate_test_instances(list<ACLGranteeType*>& o)
 
 void ACLGranteeType::dump(Formatter *f) const
 {
+  f->dump_unsigned("type", type);
 }
 
 void ACLGrant::generate_test_instances(list<ACLGrant*>& o)
@@ -40,6 +44,19 @@ void ACLGrant::generate_test_instances(list<ACLGrant*>& 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<RGWAccessControlList*>& o)
@@ -49,6 +66,37 @@ void RGWAccessControlList::generate_test_instances(list<RGWAccessControlList*>&
 
 void RGWAccessControlList::dump(Formatter *f) const
 {
+  map<string, int>::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<uint32_t, int>::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<string, ACLGrant>::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<ACLOwner*>& o)
@@ -58,6 +106,8 @@ void ACLOwner::generate_test_instances(list<ACLOwner*>& 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<RGWAccessControlPolicy*>& o)
@@ -68,6 +118,12 @@ void RGWAccessControlPolicy::generate_test_instances(list<RGWAccessControlPolicy
 
 void RGWAccessControlPolicy::dump(Formatter *f) const
 {
+  f->open_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)
index 641733d36c867073cc4f722fb581fa26906310ea..cf41ca5480d4597891a8bfeff9bed1495c82fc9b 100644 (file)
@@ -14,6 +14,8 @@ void ObjectMetaInfo::generate_test_instances(list<ObjectMetaInfo*>& o)
 
 void ObjectMetaInfo::dump(Formatter *f) const
 {
+  f->dump_unsigned("size", size);
+  f->dump_stream("mtime") << mtime;
 }
 
 void ObjectCacheInfo::generate_test_instances(list<ObjectCacheInfo*>& o)
@@ -23,6 +25,34 @@ void ObjectCacheInfo::generate_test_instances(list<ObjectCacheInfo*>& 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<string, bufferlist>::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<RGWCacheNotifyInfo*>& o)
@@ -32,6 +62,15 @@ void RGWCacheNotifyInfo::generate_test_instances(list<RGWCacheNotifyInfo*>& 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)
index 656814da1f85593299ed9507737818bd3a3ca38d..34effb7908351613fe76d39fc5283208fef3b01e 100644 (file)
@@ -56,6 +56,9 @@ void RGWAccessKey::generate_test_instances(list<RGWAccessKey*>& 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<RGWSubUser*>& o)
@@ -65,6 +68,8 @@ void RGWSubUser::generate_test_instances(list<RGWSubUser*>& 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<RGWUserInfo*>& o)
@@ -74,6 +79,41 @@ void RGWUserInfo::generate_test_instances(list<RGWUserInfo*>& 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<string, RGWAccessKey>::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<string, RGWSubUser>::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<rgw_bucket*>& o)
@@ -83,6 +123,10 @@ void rgw_bucket::generate_test_instances(list<rgw_bucket*>& 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<RGWBucketInfo*>& o)
@@ -92,6 +136,11 @@ void RGWBucketInfo::generate_test_instances(list<RGWBucketInfo*>& 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<RGWBucketEnt*>& o)
@@ -101,6 +150,13 @@ void RGWBucketEnt::generate_test_instances(list<RGWBucketEnt*>& 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<RGWUploadPartInfo*>& o)
@@ -110,6 +166,10 @@ void RGWUploadPartInfo::generate_test_instances(list<RGWUploadPartInfo*>& 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<rgw_obj*>& o)
@@ -119,6 +179,12 @@ void rgw_obj::generate_test_instances(list<rgw_obj*>& 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);
 }
 
 
index 57f13226ded5d85e3b6c3c5b78a3e651f08eabf9..fcc5d2a776d8fde7ca51202717635aa0dc92fb21 100644 (file)
@@ -14,6 +14,24 @@ void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& 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<rgw_intent_log_entry*>& o)
@@ -23,6 +41,11 @@ void rgw_intent_log_entry::generate_test_instances(list<rgw_intent_log_entry*>&
 
 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);
index 47e593abd189d01b7b8a663c0785c6dc9ae47746..127bea683c78315934d560f9f3fc25d63a1f71a4 100644 (file)
@@ -52,6 +52,9 @@ void rgw_bucket_pending_info::generate_test_instances(list<rgw_bucket_pending_in
 
 void rgw_bucket_pending_info::dump(Formatter *f) const
 {
+  f->dump_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<rgw_bucket_dir_entry_meta*>& o)
@@ -61,6 +64,14 @@ void rgw_bucket_dir_entry_meta::generate_test_instances(list<rgw_bucket_dir_entr
 
 void rgw_bucket_dir_entry_meta::dump(Formatter *f) const
 {
+  f->dump_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<rgw_bucket_dir_entry*>& o)
@@ -70,6 +81,23 @@ void rgw_bucket_dir_entry::generate_test_instances(list<rgw_bucket_dir_entry*>&
 
 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<string, struct rgw_bucket_pending_info>::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<rgw_bucket_category_stats*>& o)
@@ -79,6 +107,9 @@ void rgw_bucket_category_stats::generate_test_instances(list<rgw_bucket_category
 
 void rgw_bucket_category_stats::dump(Formatter *f) const
 {
+  f->dump_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<rgw_bucket_dir_header*>& o)
@@ -88,6 +119,15 @@ void rgw_bucket_dir_header::generate_test_instances(list<rgw_bucket_dir_header*>
 
 void rgw_bucket_dir_header::dump(Formatter *f) const
 {
+  map<uint8_t, struct rgw_bucket_category_stats>::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<rgw_bucket_dir*>& o)
@@ -97,6 +137,18 @@ void rgw_bucket_dir::generate_test_instances(list<rgw_bucket_dir*>& o)
 
 void rgw_bucket_dir::dump(Formatter *f) const
 {
+  f->open_object_section("header");
+  header.dump(f);
+  f->close_section();
+  map<string, struct rgw_bucket_dir_entry>::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<rgw_cls_obj_prepare_op*>& o)
@@ -106,6 +158,10 @@ void rgw_cls_obj_prepare_op::generate_test_instances(list<rgw_cls_obj_prepare_op
 
 void rgw_cls_obj_prepare_op::dump(Formatter *f) const
 {
+  f->dump_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<rgw_cls_obj_complete_op*>& o)
@@ -115,6 +171,14 @@ void rgw_cls_obj_complete_op::generate_test_instances(list<rgw_cls_obj_complete_
 
 void rgw_cls_obj_complete_op::dump(Formatter *f) const
 {
+  f->dump_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<rgw_cls_list_op*>& o)
@@ -124,6 +188,8 @@ void rgw_cls_list_op::generate_test_instances(list<rgw_cls_list_op*>& 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<rgw_cls_list_ret*>& o)
@@ -133,6 +199,10 @@ void rgw_cls_list_ret::generate_test_instances(list<rgw_cls_list_ret*>& 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);
 }