]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: factor get_log_shard_id() out of RGWMetadataLog
authorCasey Bodley <cbodley@redhat.com>
Thu, 11 Feb 2016 16:03:34 +0000 (11:03 -0500)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 18 Feb 2016 22:04:20 +0000 (14:04 -0800)
by using RGWRados::key_to_shard_id(), we can avoid the dependency on
RGWMetadataLog's prefix (and period)

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_metadata.cc
src/rgw/rgw_metadata.h

index 0e213003ba05b92bfa66b49e0fdf567a57dce5e0..e619aa7b6b153bd50d1add62e1beadf5e09c33ec 100644 (file)
@@ -102,19 +102,6 @@ int RGWMetadataLog::add_entry(RGWMetadataHandler *handler, const string& section
   return store->time_log_add(oid, now, section, key, bl);
 }
 
-int RGWMetadataLog::get_log_shard_id(RGWMetadataHandler *handler, const string& section, const string& key)
-{
-  string oid;
-
-  string hash_key;
-  handler->get_hash_key(section, key, hash_key);
-
-  int shard_id;
-  store->shard_name(prefix, cct->_conf->rgw_md_log_max_shards, hash_key, oid, &shard_id);
-
-  return shard_id;
-}
-
 int RGWMetadataLog::store_entries_in_shard(list<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion)
 {
   string oid;
@@ -824,3 +811,15 @@ int RGWMetadataManager::remove_entry(RGWMetadataHandler *handler, string& key, R
   return 0;
 }
 
+int RGWMetadataManager::get_log_shard_id(const string& section,
+                                         const string& key, int *shard_id)
+{
+  RGWMetadataHandler *handler = get_handler(section);
+  if (!handler) {
+    return -EINVAL;
+  }
+  string hash_key;
+  handler->get_hash_key(section, key, hash_key);
+  *shard_id = store->key_to_shard_id(hash_key, cct->_conf->rgw_md_log_max_shards);
+  return 0;
+}
index 5487e53f42b52ae19b70d66eb747e4be24d4df46..2eb458e6a62ba36ee6cc17f071c83b50462897fe 100644 (file)
@@ -166,7 +166,6 @@ public:
       lock("RGWMetaLog::lock") {}
 
   int add_entry(RGWMetadataHandler *handler, const string& section, const string& key, bufferlist& bl);
-  int get_log_shard_id(RGWMetadataHandler *handler, const string& section, const string& key);
   int store_entries_in_shard(list<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion);
 
   struct LogListCtx {
@@ -281,16 +280,7 @@ public:
   int lock_exclusive(string& metadata_key, utime_t duration, string& owner_id);
   int unlock(string& metadata_key, string& owner_id);
 
-  int get_log_shard_id(const string& section, const std::string& period,
-                       const string& key, int *shard_id) {
-    RGWMetadataHandler *handler = get_handler(section);
-    if (!handler) {
-      return -EINVAL;
-    }
-    auto md_log = get_log(period);
-    *shard_id = md_log->get_log_shard_id(handler, section, key);
-    return 0;
-  }
+  int get_log_shard_id(const string& section, const string& key, int *shard_id);
 };
 
 #endif