]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: ready rgw_usage_log_entry for extraction via ceph-dencoder 23857/head
authorVaibhav Bhembre <vaibhav@digitalocean.com>
Thu, 31 May 2018 14:35:19 +0000 (10:35 -0400)
committerNathan Cutler <ncutler@suse.com>
Sun, 2 Sep 2018 11:42:22 +0000 (13:42 +0200)
Signed-off-by: Vaibhav Bhembre vaibhav@digitalocean.com
(cherry picked from commit a503cec93853235f2f94dbc53eb307618f5a437a)

src/cls/rgw/cls_rgw_types.cc
src/cls/rgw/cls_rgw_types.h
src/test/encoding/types.h

index c16218a594a690d44592f958736c950206a14618..788058288868c04aa1dcfde56fa7fa53ad8768b0 100644 (file)
@@ -578,6 +578,54 @@ void rgw_bucket_dir::dump(Formatter *f) const
   f->close_section();
 }
 
+void rgw_usage_log_entry::dump(Formatter *f) const
+{
+  f->dump_string("owner", owner.to_str());
+  f->dump_string("payer", payer.to_str());
+  f->dump_string("bucket", bucket);
+  f->dump_unsigned("epoch", epoch);
+
+  f->open_object_section("total_usage");
+  f->dump_unsigned("bytes_sent", total_usage.bytes_sent);
+  f->dump_unsigned("bytes_received", total_usage.bytes_received);
+  f->dump_unsigned("ops", total_usage.ops);
+  f->dump_unsigned("successful_ops", total_usage.successful_ops);
+  f->close_section();
+
+  f->open_array_section("categories");
+  if (usage_map.size() > 0) {
+    map<string, rgw_usage_data>::const_iterator it;
+    for (it = usage_map.begin(); it != usage_map.end(); it++) {
+      const rgw_usage_data& total_usage = it->second;
+      f->open_object_section("entry");
+      f->dump_string("category", it->first.c_str());
+      f->dump_unsigned("bytes_sent", total_usage.bytes_sent);
+      f->dump_unsigned("bytes_received", total_usage.bytes_received);
+      f->dump_unsigned("ops", total_usage.ops);
+      f->dump_unsigned("successful_ops", total_usage.successful_ops);
+      f->close_section();
+    }
+  }
+  f->close_section();
+}
+
+void rgw_usage_log_entry::generate_test_instances(list<rgw_usage_log_entry *> &o)
+{
+  rgw_usage_log_entry *entry = new rgw_usage_log_entry;
+  rgw_usage_data usage_data{1024, 2048};
+  entry->owner = rgw_user("owner");
+  entry->payer = rgw_user("payer");
+  entry->bucket = "bucket";
+  entry->epoch = 1234;
+  entry->total_usage.bytes_sent = usage_data.bytes_sent;
+  entry->total_usage.bytes_received = usage_data.bytes_received;
+  entry->total_usage.ops = usage_data.ops;
+  entry->total_usage.successful_ops = usage_data.successful_ops;
+  entry->usage_map["get_obj"] = usage_data;
+  o.push_back(entry);
+  o.push_back(new rgw_usage_log_entry);
+}
+
 void cls_rgw_reshard_entry::generate_key(const string& tenant, const string& bucket_name, string *key)
 {
   *key = tenant + ":" + bucket_name;
index fa08a48b9a133b504b357c025bd75c81f959916f..e1cfdb645fb0443b40f0cad29b28f828c8cfd23c 100644 (file)
@@ -857,6 +857,10 @@ struct rgw_usage_log_entry {
     usage_map[category].aggregate(data);
     total_usage.aggregate(data);
   }
+
+  void dump(Formatter* f) const;
+  static void generate_test_instances(list<rgw_usage_log_entry*>& o);
+
 };
 WRITE_CLASS_ENCODER(rgw_usage_log_entry)
 
index 9c355068dbf7da9d370796aecdd31193ddbe408e..8e9e8f8e61a2a22e79409bc83351d5868ed6250b 100644 (file)
@@ -324,6 +324,7 @@ TYPE(rgw_bucket_dir)
 TYPE(rgw_bucket_entry_ver)
 TYPE(cls_rgw_obj_key)
 TYPE(rgw_bucket_olh_log_entry)
+TYPE(rgw_usage_log_entry)
 
 #include "cls/rgw/cls_rgw_ops.h"
 TYPE(rgw_cls_obj_prepare_op)