]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rename RGWBucketStats to RGWStorageStats
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 10 Jan 2014 05:37:34 +0000 (21:37 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 24 Jan 2014 18:28:49 +0000 (10:28 -0800)
make it more generic, will be reused for user's stats.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_common.h
src/rgw/rgw_quota.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_log.cc

index b739fcd7ef4bc388a9fc95a3eca92ea4241ac5e1..2532fb6cce89fba32a927e2c22b0b18d75b9781c 100644 (file)
@@ -478,13 +478,13 @@ static void show_user_info(RGWUserInfo& info, Formatter *formatter)
   cout << std::endl;
 }
 
-static void dump_bucket_usage(map<RGWObjCategory, RGWBucketStats>& stats, Formatter *formatter)
+static void dump_bucket_usage(map<RGWObjCategory, RGWStorageStats>& stats, Formatter *formatter)
 {
-  map<RGWObjCategory, RGWBucketStats>::iterator iter;
+  map<RGWObjCategory, RGWStorageStats>::iterator iter;
 
   formatter->open_object_section("usage");
   for (iter = stats.begin(); iter != stats.end(); ++iter) {
-    RGWBucketStats& s = iter->second;
+    RGWStorageStats& s = iter->second;
     const char *cat_name = rgw_obj_category_name(iter->first);
     formatter->open_object_section(cat_name);
     formatter->dump_int("size_kb", s.num_kb);
@@ -504,7 +504,7 @@ int bucket_stats(rgw_bucket& bucket, Formatter *formatter)
   if (r < 0)
     return r;
 
-  map<RGWObjCategory, RGWBucketStats> stats;
+  map<RGWObjCategory, RGWStorageStats> stats;
   uint64_t bucket_ver, master_ver;
   string max_marker;
   int ret = store->get_bucket_stats(bucket, &bucket_ver, &master_ver, stats, &max_marker);
index 10afb70c5d4e34f45038c00e98deb5c098546976..3e7a44e15a42c2fc955aaaea98bf30b97ba768f8 100644 (file)
@@ -314,7 +314,7 @@ int rgw_remove_object(RGWRados *store, const string& bucket_owner, rgw_bucket& b
 int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& bucket, bool delete_children)
 {
   int ret;
-  map<RGWObjCategory, RGWBucketStats> stats;
+  map<RGWObjCategory, RGWStorageStats> stats;
   std::vector<RGWObjEnt> objs;
   std::string prefix, delim, marker, ns;
   map<string, bool> common_prefixes;
@@ -547,13 +547,13 @@ static void dump_bucket_index(map<string, RGWObjEnt> result,  Formatter *f)
    }
 }
 
-static void dump_bucket_usage(map<RGWObjCategory, RGWBucketStats>& stats, Formatter *formatter)
+static void dump_bucket_usage(map<RGWObjCategory, RGWStorageStats>& stats, Formatter *formatter)
 {
-  map<RGWObjCategory, RGWBucketStats>::iterator iter;
+  map<RGWObjCategory, RGWStorageStats>::iterator iter;
 
   formatter->open_object_section("usage");
   for (iter = stats.begin(); iter != stats.end(); ++iter) {
-    RGWBucketStats& s = iter->second;
+    RGWStorageStats& s = iter->second;
     const char *cat_name = rgw_obj_category_name(iter->first);
     formatter->open_object_section(cat_name);
     formatter->dump_int("size_kb", s.num_kb);
@@ -564,8 +564,8 @@ static void dump_bucket_usage(map<RGWObjCategory, RGWBucketStats>& stats, Format
   formatter->close_section();
 }
 
-static void dump_index_check(map<RGWObjCategory, RGWBucketStats> existing_stats,
-        map<RGWObjCategory, RGWBucketStats> calculated_stats,
+static void dump_index_check(map<RGWObjCategory, RGWStorageStats> existing_stats,
+        map<RGWObjCategory, RGWStorageStats> calculated_stats,
         Formatter *formatter)
 {
   formatter->open_object_section("check_result");
@@ -704,8 +704,8 @@ int RGWBucket::check_object_index(RGWBucketAdminOpState& op_state,
 
 
 int RGWBucket::check_index(RGWBucketAdminOpState& op_state,
-        map<RGWObjCategory, RGWBucketStats>& existing_stats,
-        map<RGWObjCategory, RGWBucketStats>& calculated_stats,
+        map<RGWObjCategory, RGWStorageStats>& existing_stats,
+        map<RGWObjCategory, RGWStorageStats>& calculated_stats,
         std::string *err_msg)
 {
   rgw_bucket bucket = op_state.get_bucket();
@@ -820,8 +820,8 @@ int RGWBucketAdminOp::check_index(RGWRados *store, RGWBucketAdminOpState& op_sta
 {
   int ret;
   map<string, RGWObjEnt> result;
-  map<RGWObjCategory, RGWBucketStats> existing_stats;
-  map<RGWObjCategory, RGWBucketStats> calculated_stats;
+  map<RGWObjCategory, RGWStorageStats> existing_stats;
+  map<RGWObjCategory, RGWStorageStats> calculated_stats;
   list<std::string> objs_to_unlink;
 
   RGWBucket bucket;
@@ -883,7 +883,7 @@ static int bucket_stats(RGWRados *store, std::string&  bucket_name, Formatter *f
 {
   RGWBucketInfo bucket_info;
   rgw_bucket bucket;
-  map<RGWObjCategory, RGWBucketStats> stats;
+  map<RGWObjCategory, RGWStorageStats> stats;
 
   time_t mtime;
   int r = store->get_bucket_info(NULL, bucket_name, bucket_info, &mtime);
index 61b533c5a80e4e875abf389613ad0f848ed8494e..cc941a595c0e04d0e7b192f3f5ba298228e427b7 100644 (file)
@@ -200,8 +200,8 @@ public:
           map<string, RGWObjEnt> result, std::string *err_msg = NULL);
 
   int check_index(RGWBucketAdminOpState& op_state,
-          map<RGWObjCategory, RGWBucketStats>& existing_stats,
-          map<RGWObjCategory, RGWBucketStats>& calculated_stats,
+          map<RGWObjCategory, RGWStorageStats>& existing_stats,
+          map<RGWObjCategory, RGWStorageStats>& calculated_stats,
           std::string *err_msg = NULL);
 
   int remove(RGWBucketAdminOpState& op_state, std::string *err_msg = NULL);
index 4c98e81f8ac743f4255b45316084e39fb439ca2e..cc797d66209c8c11876d9bd3cd61a7f433d98c05 100644 (file)
@@ -784,14 +784,14 @@ struct RGWBucketEntryPoint
 };
 WRITE_CLASS_ENCODER(RGWBucketEntryPoint)
 
-struct RGWBucketStats
+struct RGWStorageStats
 {
   RGWObjCategory category;
   uint64_t num_kb;
   uint64_t num_kb_rounded;
   uint64_t num_objects;
 
-  RGWBucketStats() : num_kb(0), num_kb_rounded(0), num_objects(0) {}
+  RGWStorageStats() : num_kb(0), num_kb_rounded(0), num_objects(0) {}
 };
 
 struct req_state;
index 2b292df5a48e761ea7f9ad4a912063649fb37261..5c16c7895d16eefbef323a2ea9f06c5e59a70f8e 100644 (file)
@@ -25,7 +25,7 @@
 
 
 struct RGWQuotaBucketStats {
-  RGWBucketStats stats;
+  RGWStorageStats stats;
   utime_t expiration;
   utime_t async_refresh_time;
 };
@@ -35,7 +35,7 @@ class RGWBucketStatsCache {
   lru_map<rgw_bucket, RGWQuotaBucketStats> stats_map;
   RefCountedWaitObject *async_refcount;
 
-  int fetch_bucket_totals(rgw_bucket& bucket, RGWBucketStats& stats);
+  int fetch_bucket_totals(rgw_bucket& bucket, RGWStorageStats& stats);
 
 public:
   RGWBucketStatsCache(RGWRados *_store) : store(_store), stats_map(store->ctx()->_conf->rgw_bucket_quota_cache_size) {
@@ -45,17 +45,17 @@ public:
     async_refcount->put_wait(); /* wait for all pending async requests to complete */
   }
 
-  int get_bucket_stats(rgw_bucket& bucket, RGWBucketStats& stats, RGWQuotaInfo& quota);
+  int get_bucket_stats(rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota);
   void adjust_bucket_stats(const string& bucket_owner, rgw_bucket& bucket, int objs_delta, uint64_t added_bytes, uint64_t removed_bytes);
 
-  bool can_use_cached_stats(RGWQuotaInfo& quota, RGWBucketStats& stats);
+  bool can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& stats);
 
-  void set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWBucketStats& stats);
+  void set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWStorageStats& stats);
   int async_refresh(rgw_bucket& bucket, RGWQuotaBucketStats& qs);
-  void async_refresh_response(rgw_bucket& bucket, RGWBucketStats& stats);
+  void async_refresh_response(rgw_bucket& bucket, RGWStorageStats& stats);
 };
 
-bool RGWBucketStatsCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWBucketStats& cached_stats)
+bool RGWBucketStatsCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& cached_stats)
 {
   if (quota.max_size_kb >= 0) {
     if (quota.max_size_soft_threshold < 0) {
@@ -84,25 +84,25 @@ bool RGWBucketStatsCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWBucketSta
   return true;
 }
 
-int RGWBucketStatsCache::fetch_bucket_totals(rgw_bucket& bucket, RGWBucketStats& stats)
+int RGWBucketStatsCache::fetch_bucket_totals(rgw_bucket& bucket, RGWStorageStats& stats)
 {
   RGWBucketInfo bucket_info;
 
   uint64_t bucket_ver;
   uint64_t master_ver;
 
-  map<RGWObjCategory, RGWBucketStats> bucket_stats;
+  map<RGWObjCategory, RGWStorageStats> bucket_stats;
   int r = store->get_bucket_stats(bucket, &bucket_ver, &master_ver, bucket_stats, NULL);
   if (r < 0) {
     ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket.name << dendl;
     return r;
   }
 
-  stats = RGWBucketStats();
+  stats = RGWStorageStats();
 
-  map<RGWObjCategory, RGWBucketStats>::iterator iter;
+  map<RGWObjCategory, RGWStorageStats>::iterator iter;
   for (iter = bucket_stats.begin(); iter != bucket_stats.end(); ++iter) {
-    RGWBucketStats& s = iter->second;
+    RGWStorageStats& s = iter->second;
     stats.num_kb += s.num_kb;
     stats.num_kb_rounded += s.num_kb_rounded;
     stats.num_objects += s.num_objects;
@@ -126,7 +126,7 @@ public:
 int AsyncRefreshHandler::init_fetch()
 {
   ldout(store->ctx(), 20) << "initiating async quota refresh for bucket=" << bucket << dendl;
-  map<RGWObjCategory, RGWBucketStats> bucket_stats;
+  map<RGWObjCategory, RGWStorageStats> bucket_stats;
   int r = store->get_bucket_stats_async(bucket, this);
   if (r < 0) {
     ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket.name << dendl;
@@ -145,11 +145,11 @@ void AsyncRefreshHandler::handle_response(int r)
     return; /* nothing to do here */
   }
 
-  RGWBucketStats bs;
+  RGWStorageStats bs;
 
-  map<RGWObjCategory, RGWBucketStats>::iterator iter;
+  map<RGWObjCategory, RGWStorageStats>::iterator iter;
   for (iter = stats->begin(); iter != stats->end(); ++iter) {
-    RGWBucketStats& s = iter->second;
+    RGWStorageStats& s = iter->second;
     bs.num_kb += s.num_kb;
     bs.num_kb_rounded += s.num_kb_rounded;
     bs.num_objects += s.num_objects;
@@ -197,7 +197,7 @@ int RGWBucketStatsCache::async_refresh(rgw_bucket& bucket, RGWQuotaBucketStats&
   return 0;
 }
 
-void RGWBucketStatsCache::async_refresh_response(rgw_bucket& bucket, RGWBucketStats& stats)
+void RGWBucketStatsCache::async_refresh_response(rgw_bucket& bucket, RGWStorageStats& stats)
 {
   ldout(store->ctx(), 20) << "async stats refresh response for bucket=" << bucket << dendl;
 
@@ -210,7 +210,7 @@ void RGWBucketStatsCache::async_refresh_response(rgw_bucket& bucket, RGWBucketSt
   async_refcount->put();
 }
 
-void RGWBucketStatsCache::set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWBucketStats& stats)
+void RGWBucketStatsCache::set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWStorageStats& stats)
 {
   qs.stats = stats;
   qs.expiration = ceph_clock_now(store->ctx());
@@ -221,7 +221,7 @@ void RGWBucketStatsCache::set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs,
   stats_map.add(bucket, qs);
 }
 
-int RGWBucketStatsCache::get_bucket_stats(rgw_bucket& bucket, RGWBucketStats& stats, RGWQuotaInfo& quota) {
+int RGWBucketStatsCache::get_bucket_stats(rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota) {
   RGWQuotaBucketStats qs;
   utime_t now = ceph_clock_now(store->ctx());
   if (stats_map.find(bucket, qs)) {
@@ -289,7 +289,7 @@ public:
       return 0;
     }
 
-    RGWBucketStats stats;
+    RGWStorageStats stats;
 
     int ret = stats_cache.get_bucket_stats(bucket, stats, bucket_quota);
     if (ret < 0)
index c56d994a57a1268b76bf7e783d4ec52a361844b7..6784ea9ed725c895baf7d9da1425eb8a5fa7730b 100644 (file)
@@ -3121,12 +3121,12 @@ int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx,
   return 0;
 }
 
-static void translate_raw_stats(rgw_bucket_dir_header& header, map<RGWObjCategory, RGWBucketStats>& stats)
+static void translate_raw_stats(rgw_bucket_dir_header& header, map<RGWObjCategory, RGWStorageStats>& stats)
 {
   map<uint8_t, struct rgw_bucket_category_stats>::iterator iter = header.stats.begin();
   for (; iter != header.stats.end(); ++iter) {
     RGWObjCategory category = (RGWObjCategory)iter->first;
-    RGWBucketStats& s = stats[category];
+    RGWStorageStats& s = stats[category];
     struct rgw_bucket_category_stats& header_stats = iter->second;
     s.category = (RGWObjCategory)iter->first;
     s.num_kb = ((header_stats.total_size + 1023) / 1024);
@@ -3136,8 +3136,8 @@ static void translate_raw_stats(rgw_bucket_dir_header& header, map<RGWObjCategor
 }
 
 int RGWRados::bucket_check_index(rgw_bucket& bucket,
-                                map<RGWObjCategory, RGWBucketStats> *existing_stats,
-                                map<RGWObjCategory, RGWBucketStats> *calculated_stats)
+                                map<RGWObjCategory, RGWStorageStats> *existing_stats,
+                                map<RGWObjCategory, RGWStorageStats> *calculated_stats)
 {
   librados::IoCtx index_ctx;
   string oid;
@@ -4655,7 +4655,7 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
   return 0;
 }
 
-int RGWRados::get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWBucketStats>& stats,
+int RGWRados::get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWStorageStats>& stats,
                                string *max_marker)
 {
   rgw_bucket_dir_header header;
@@ -4682,7 +4682,7 @@ class RGWGetBucketStatsContext : public RGWGetDirHeader_CB {
 public:
   RGWGetBucketStatsContext(RGWGetBucketStats_CB *_cb) : cb(_cb) {}
   void handle_response(int r, rgw_bucket_dir_header& header) {
-    map<RGWObjCategory, RGWBucketStats> stats;
+    map<RGWObjCategory, RGWStorageStats> stats;
 
     if (r >= 0) {
       translate_raw_stats(header, stats);
index 1c66d49a555d479289fb66d2d24a6a300b411d4a..028102f08b8f62d3ea8adb90f0bb0e083240ce77 100644 (file)
@@ -773,14 +773,14 @@ protected:
   rgw_bucket bucket;
   uint64_t bucket_ver;
   uint64_t master_ver;
-  map<RGWObjCategory, RGWBucketStats> *stats;
+  map<RGWObjCategory, RGWStorageStats> *stats;
   string max_marker;
 public:
   RGWGetBucketStats_CB(rgw_bucket& _bucket) : bucket(_bucket), stats(NULL) {}
   virtual ~RGWGetBucketStats_CB() {}
   virtual void handle_response(int r) = 0;
   virtual void set_response(uint64_t _bucket_ver, uint64_t _master_ver,
-                            map<RGWObjCategory, RGWBucketStats> *_stats,
+                            map<RGWObjCategory, RGWStorageStats> *_stats,
                             const string &_max_marker) {
     bucket_ver = _bucket_ver;
     master_ver = _master_ver;
@@ -1328,7 +1328,7 @@ public:
   }
 
   int decode_policy(bufferlist& bl, ACLOwner *owner);
-  int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWBucketStats>& stats,
+  int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWStorageStats>& stats,
                        string *max_marker);
   int get_bucket_stats_async(rgw_bucket& bucket, RGWGetBucketStats_CB *cb);
   void get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj);
@@ -1414,8 +1414,8 @@ public:
   int defer_gc(void *ctx, rgw_obj& obj);
 
   int bucket_check_index(rgw_bucket& bucket,
-                         map<RGWObjCategory, RGWBucketStats> *existing_stats,
-                         map<RGWObjCategory, RGWBucketStats> *calculated_stats);
+                         map<RGWObjCategory, RGWStorageStats> *existing_stats,
+                         map<RGWObjCategory, RGWStorageStats> *calculated_stats);
   int bucket_rebuild_index(rgw_bucket& bucket);
   int remove_objs_from_index(rgw_bucket& bucket, list<string>& oid_list);
 
index 2de424fb6e598ed32a1196777d87e3cb11ee0d27..9f32fc9ebd3f96a0ded857ab4b14da3f47fdea54 100644 (file)
@@ -379,7 +379,7 @@ void RGWOp_BILog_Info::execute() {
       return;
     }
   }
-  map<RGWObjCategory, RGWBucketStats> stats;
+  map<RGWObjCategory, RGWStorageStats> stats;
   int ret =  store->get_bucket_stats(bucket_info.bucket, &bucket_ver, &master_ver, stats, &max_marker);
   if (ret < 0 && ret != -ENOENT) {
     http_ret = ret;