}
int add_entry(const string& hash_key, const string& section, const string& key, bufferlist& bl);
+ int get_shard_id(const string& hash_key, int *shard_id);
int store_entries_in_shard(list<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion);
struct LogListCtx {
return svc.cls->timelog.add(oid, now, section, key, bl, null_yield);
}
+int RGWMetadataLog::get_shard_id(const string& hash_key, int *shard_id)
+{
+ string oid;
+
+ rgw_shard_name(prefix, cct->_conf->rgw_md_log_max_shards, hash_key, oid, shard_id);
+ return 0;
+}
+
int RGWMetadataLog::store_entries_in_shard(list<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion)
{
string oid;
});
}
+int RGWMetadataHandler_GenericMetaBE::get_shard_id(const string& entry, int *shard_id)
+{
+ return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) {
+ return op->get_shard_id(entry, shard_id);
+ });
+}
+
int RGWMetadataHandler_GenericMetaBE::list_keys_init(const string& marker, void **phandle)
{
std::unique_ptr<RGWSI_MetaBackend_Handler::Op> op(be_handler->alloc_op());
return handler->remove(entry, objv_tracker);
}
+int RGWMetadataManager::get_shard_id(const string& section, const string& entry, int *shard_id)
+{
+ RGWMetadataHandler *handler = get_handler(section);
+ if (!handler) {
+ return -EINVAL;
+ }
+
+ return handler->get_shard_id(entry, shard_id);
+}
+
struct list_keys_handle {
void *handle;
RGWMetadataHandler *handler;
virtual string get_marker(void *handle) = 0;
+ virtual int get_shard_id(const string& entry, int *shard_id) {
+ *shard_id = 0;
+ return 0;
+ }
virtual int attach(RGWMetadataManager *manager);
};
int put(string& entry, RGWMetadataObject *obj, RGWObjVersionTracker& objv_tracker, RGWMDLogSyncType type) override;
int remove(string& entry, RGWObjVersionTracker& objv_tracker) override;
+ int get_shard_id(const string& entry, int *shard_id) override;
+
int list_keys_init(const std::string& marker, void **phandle) override;
int list_keys_next(void *handle, int max, std::list<string>& keys, bool *truncated) override;
void list_keys_complete(void *handle) override;
void get_sections(list<string>& sections);
void parse_metadata_key(const string& metadata_key, string& type, string& entry);
+
+ int get_shard_id(const string& section, const string& key, int *shard_id);
};
class RGWMetadataHandlerPut_SObj : public RGWMetadataHandler_GenericMetaBE::Put
string s = *sections_iter + ":" + *iter;
int shard_id;
RGWRados *store = sync_env->store;
- int ret = store->ctl.meta.mgr->get_log_shard_id(*sections_iter, *iter, &shard_id);
+ int ret = store->ctl.meta.mgr->get_shard_id(*sections_iter, *iter, &shard_id);
if (ret < 0) {
tn->log(0, SSTR("ERROR: could not determine shard id for " << *sections_iter << ":" << *iter));
ret_status = ret;
return current_log->add_entry(hash_key, section, key, bl);
}
+int RGWSI_MDLog::get_shard_id(const string& hash_key, int *shard_id)
+{
+ ceph_assert(current_log); // must have called init()
+ return current_log->get_shard_id(hash_key, shard_id);
+}
+
int RGWSI_MDLog::pull_period(const std::string& period_id, RGWPeriod& period)
{
return period_puller->pull(period_id, period);
int add_entry(const string& hash_key, const string& section, const string& key, bufferlist& bl);
+ int get_shard_id(const string& hash_key, int *shard_id);
+
RGWPeriodHistory *get_period_history() {
return period_history.get();
}
virtual int call(std::function<int(RGWSI_MetaBackend::Context *)> f) = 0;
+ virtual int get_shard_id(RGWSI_MetaBackend::Context *ctx,
+ const std::string& key,
+ int *shard_id) = 0;
+
/* higher level */
virtual int get(Context *ctx,
const std::string& key,
int list_get_marker(string *marker) {
return be->list_get_marker(be_ctx, marker);
}
+
+ int get_shard_id(const std::string& key, int *shard_id) {
+ return be->get_shard_id(be_ctx, key, shard_id);
+ }
};
class Op_ManagedCtx : public Op {
return RGWSI_MetaBackend::post_modify(ctx, key, log_data, objv_tracker, ret, y);
}
+int RGWSI_MetaBackend_SObj::get_shard_id(RGWSI_MetaBackend::Context *_ctx,
+ const std::string& key,
+ int *shard_id)
+{
+ auto ctx = static_cast<Context_SObj *>(_ctx);
+ *shard_id = mdlog_svc->get_shard_id(ctx->module->get_hash_key(key), shard_id);
+ return 0;
+}
+
int RGWSI_MetaBackend_SObj::call(std::function<int(RGWSI_MetaBackend::Context *)> f)
{
RGWSI_MetaBackend_SObj::Context_SObj ctx(sysobj_svc);
int list_get_marker(RGWSI_MetaBackend::Context *ctx,
string *marker) override;
+ int get_shard_id(RGWSI_MetaBackend::Context *ctx,
+ const std::string& key,
+ int *shard_id) override;
+
int call(std::function<int(RGWSI_MetaBackend::Context *)> f) override;
};