]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: encode total usage for backwards compatibility
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 7 Sep 2012 23:44:28 +0000 (16:44 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 7 Sep 2012 23:44:28 +0000 (16:44 -0700)
Adding the encoding of the total usage allows us to
make the format change backwards compatible.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/cls/rgw/cls_rgw_types.h

index 5dbc6168ad5a75f64ff94a416736258326e6c237..5320ce6035118c55b25d178bdc650263be1b1e0b 100644 (file)
@@ -239,16 +239,21 @@ struct rgw_usage_log_entry {
   string owner;
   string bucket;
   uint64_t epoch;
+  rgw_usage_data total_usage; /* this one is kept for backwards compatibility */
   map<string, rgw_usage_data> usage_map;
 
   rgw_usage_log_entry() {}
   rgw_usage_log_entry(string& o, string& b) : owner(o), bucket(b) {}
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(2, 2, bl);
+    ENCODE_START(2, 1, bl);
     ::encode(owner, bl);
     ::encode(bucket, bl);
     ::encode(epoch, bl);
+    ::encode(total_usage.bytes_sent, bl);
+    ::encode(total_usage.bytes_received, bl);
+    ::encode(total_usage.ops, bl);
+    ::encode(total_usage.successful_ops, bl);
     ::encode(usage_map, bl);
     ENCODE_FINISH(bl);
   }
@@ -259,13 +264,12 @@ struct rgw_usage_log_entry {
     ::decode(owner, bl);
     ::decode(bucket, bl);
     ::decode(epoch, bl);
+    ::decode(total_usage.bytes_sent, bl);
+    ::decode(total_usage.bytes_received, bl);
+    ::decode(total_usage.ops, bl);
+    ::decode(total_usage.successful_ops, bl);
     if (struct_v < 2) {
-      rgw_usage_data usage_data;
-      ::decode(usage_data.bytes_sent, bl);
-      ::decode(usage_data.bytes_received, bl);
-      ::decode(usage_data.ops, bl);
-      ::decode(usage_data.successful_ops, bl);
-      usage_map[""] = usage_data;
+      usage_map[""] = total_usage;
     } else {
       ::decode(usage_map, bl);
     }
@@ -297,6 +301,7 @@ struct rgw_usage_log_entry {
 
   void add(const string& category, const rgw_usage_data& data) {
     usage_map[category].aggregate(data);
+    total_usage.aggregate(data);
   }
 };
 WRITE_CLASS_ENCODER(rgw_usage_log_entry)