From: Casey Bodley Date: Thu, 11 Feb 2016 16:03:34 +0000 (-0500) Subject: rgw: factor get_log_shard_id() out of RGWMetadataLog X-Git-Tag: v10.1.0~354^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=988133019ab4f96fde0bd847d91ed392b592530b;p=ceph.git rgw: factor get_log_shard_id() out of RGWMetadataLog by using RGWRados::key_to_shard_id(), we can avoid the dependency on RGWMetadataLog's prefix (and period) Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 0e213003ba05..e619aa7b6b15 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -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& 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; +} diff --git a/src/rgw/rgw_metadata.h b/src/rgw/rgw_metadata.h index 5487e53f42b5..2eb458e6a62b 100644 --- a/src/rgw/rgw_metadata.h +++ b/src/rgw/rgw_metadata.h @@ -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& 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