]> 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 23974/head
authorVaibhav Bhembre <vaibhav@digitalocean.com>
Thu, 31 May 2018 14:35:19 +0000 (10:35 -0400)
committerPrashant D <pdhange@redhat.com>
Fri, 7 Sep 2018 04:20:47 +0000 (00:20 -0400)
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 51ee342e92123eae8f4f327dec479e4cf8507d92..0d7b5d2181115bf0e574b662f74d5df089bc2f8e 100644 (file)
@@ -575,6 +575,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 97b53742b85729d85dd678951bbd7ccb3b7ca7aa..51107c3259521e1bac11c27b783cd2b677930230 100644 (file)
@@ -854,6 +854,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 29a83e7d613e8daf2f8a68c32e09e75dd1103f86..3d767a06b80b71410660df2a32640d1c0ddde486 100644 (file)
@@ -317,6 +317,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)