}
class RGWArchiveBucketMetadataHandler : public RGWBucketMetadataHandler {
-
public:
-
- int remove_by_metakey(RGWRados *store, string& metadata_key) override {
-
- ldout(store->ctx(), 0) << "SKIP: bucket removal is not allowed on archive zone: " << metadata_key << " ... proceeding to rename" << dendl;
-
- string type;
- string entry;
- store->meta_mgr->parse_metadata_key(metadata_key, type, entry);
-
- RGWMetadataObject *obj;
- int ret = get(store, entry, &obj);
- if (ret < 0) {
- return ret;
- }
-
- RGWBucketEntryPoint be;
- RGWObjectCtx obj_ctx(store);
- RGWObjVersionTracker objv_tracker;
- objv_tracker.read_version = obj->get_version();
-
- delete obj;
+ int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override {
+ ldout(store->ctx(), 0) << "SKIP: bucket removal is not allowed on archive zone: bucket:" << entry << " ... proceeding to rename" << dendl;
string tenant_name, bucket_name;
parse_bucket(entry, &tenant_name, &bucket_name);
real_time mtime;
- ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &objv_tracker, &mtime, NULL);
+ RGWBucketEntryPoint be;
+ RGWObjectCtx obj_ctx(store);
+ int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &objv_tracker, &mtime, NULL);
if (ret < 0) {
return ret;
}
RGWBucketEntryMetadataObject *be_mdo = new RGWBucketEntryMetadataObject(be, objv_tracker.read_version, mtime);
+ string metadata_key = string("bucket:") + entry;
+
JSONFormatter f(false);
f.open_object_section("metadata_info");
encode_json("key", metadata_key + archive_zone_suffix, &f);
/* idempotent */
return 0;
}
-
};
class RGWBucketInstanceMetadataHandler : public RGWMetadataHandler {
};
class RGWArchiveBucketInstanceMetadataHandler : public RGWBucketInstanceMetadataHandler {
-
public:
- int remove_by_metakey(RGWRados *store, string& metadata_key) override {
- ldout(store->ctx(), 0) << "SKIP: bucket instance removal is not allowed on archive zone: " << metadata_key << dendl;
- return 0;
- }
-
+ int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override {
+ ldout(store->ctx(), 0) << "SKIP: bucket instance removal is not allowed on archive zone: bucket.instance:" << entry << dendl;
+ return 0;
+ }
};
+RGWMetadataHandler *RGWBucketMetaHandlerAllocator::alloc() {
+ return new RGWBucketMetadataHandler;
+}
+
+RGWMetadataHandler *RGWBucketInstanceMetaHandlerAllocator::alloc() {
+ return new RGWBucketInstanceMetadataHandler;
+}
+
+RGWMetadataHandler *RGWArchiveBucketMetaHandlerAllocator::alloc() {
+ return new RGWArchiveBucketMetadataHandler;
+}
+
+RGWMetadataHandler *RGWArchiveBucketInstanceMetaHandlerAllocator::alloc() {
+ return new RGWArchiveBucketInstanceMetadataHandler;
+}
+
void rgw_bucket_init(RGWMetadataManager *mm)
{
- if (mm->get_store()->get_zone().tier_type == "archive") {
- bucket_meta_handler = new RGWArchiveBucketMetadataHandler;
- bucket_instance_meta_handler = new RGWArchiveBucketInstanceMetadataHandler;
+ auto sync_module = mm->get_store()->get_sync_module();
+ if (sync_module) {
+ bucket_meta_handler = sync_module->alloc_bucket_meta_handler();
+ bucket_instance_meta_handler = sync_module->alloc_bucket_instance_meta_handler();
} else {
- bucket_meta_handler = new RGWBucketMetadataHandler;
- bucket_instance_meta_handler = new RGWBucketInstanceMetadataHandler;
+ bucket_meta_handler = RGWBucketMetaHandlerAllocator::alloc();
+ bucket_instance_meta_handler = RGWBucketInstanceMetaHandlerAllocator::alloc();
}
mm->register_handler(bucket_meta_handler);
mm->register_handler(bucket_instance_meta_handler);
WRITE_CLASS_ENCODER(RGWUserBuckets)
class RGWMetadataManager;
+class RGWMetadataHandler;
+
+class RGWBucketMetaHandlerAllocator {
+public:
+ static RGWMetadataHandler *alloc();
+};
+
+class RGWBucketInstanceMetaHandlerAllocator {
+public:
+ static RGWMetadataHandler *alloc();
+};
+
+class RGWArchiveBucketMetaHandlerAllocator {
+public:
+ static RGWMetadataHandler *alloc();
+};
+
+class RGWArchiveBucketInstanceMetaHandlerAllocator {
+public:
+ static RGWMetadataHandler *alloc();
+};
extern void rgw_bucket_init(RGWMetadataManager *mm);
/**
RGWDataSyncModule *get_data_handler() override {
return &data_handler;
}
+ RGWMetadataHandler *alloc_bucket_meta_handler() override {
+ return RGWArchiveBucketMetaHandlerAllocator::alloc();
+ }
+ RGWMetadataHandler *alloc_bucket_instance_meta_handler() override {
+ return RGWArchiveBucketInstanceMetaHandlerAllocator::alloc();
+ }
};
int RGWArchiveSyncModule::create_instance(CephContext *cct, const JSONFormattable& config, RGWSyncModuleInstanceRef *instance)
return objv;
}
-int RGWMetadataHandler::remove_by_metakey(RGWRados *store, string& metadata_key) {
- string entry;
- string type;
- store->meta_mgr->parse_metadata_key(metadata_key, type, entry);
-
- RGWMetadataObject *obj;
- int ret = get(store, entry, &obj);
- if (ret < 0) {
- return ret;
- }
- RGWObjVersionTracker objv_tracker;
- objv_tracker.read_version = obj->get_version();
- delete obj;
-
- return remove(store, entry, objv_tracker);
-}
-
class RGWMetadataTopHandler : public RGWMetadataHandler {
struct iter_data {
set<string> sections;
virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override {}
int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override { return -ENOTSUP; }
- int remove_by_metakey(RGWRados *store, string& metadata_key) override { return -ENOTSUP; }
int list_keys_init(RGWRados *store, const string& marker, void **phandle) override {
iter_data *data = new iter_data;
return ret;
}
- return handler->remove_by_metakey(store, metadata_key);
+ RGWMetadataObject *obj;
+ ret = handler->get(store, entry, &obj);
+ if (ret < 0) {
+ return ret;
+ }
+ RGWObjVersionTracker objv_tracker;
+ objv_tracker.read_version = obj->get_version();
+ delete obj;
+
+ return handler->remove(store, entry, objv_tracker);
}
int RGWMetadataManager::lock_exclusive(string& metadata_key, timespan duration, string& owner_id) {
virtual int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
real_time mtime, JSONObj *obj, sync_type_t type) = 0;
virtual int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) = 0;
- virtual int remove_by_metakey(RGWRados *store, string& metadata_key);
virtual int list_keys_init(RGWRados *store, const string& marker, void **phandle) = 0;
virtual int list_keys_next(void *handle, int max, list<string>& keys, bool *truncated) = 0;
#include "rgw_cr_rados.h"
#include "rgw_sync_module.h"
#include "rgw_data_sync.h"
+#include "rgw_bucket.h"
#include "rgw_sync_module_log.h"
#include "rgw_sync_module_es.h"
#define dout_subsys ceph_subsys_rgw
+RGWMetadataHandler *RGWSyncModuleInstance::alloc_bucket_meta_handler()
+{
+ return RGWBucketMetaHandlerAllocator::alloc();
+}
+
+RGWMetadataHandler *RGWSyncModuleInstance::alloc_bucket_instance_meta_handler()
+{
+ return RGWBucketInstanceMetaHandlerAllocator::alloc();
+}
+
RGWStatRemoteObjCBCR::RGWStatRemoteObjCBCR(RGWDataSyncEnv *_sync_env,
RGWBucketInfo& _bucket_info, rgw_obj_key& _key) : RGWCoroutine(_sync_env->cct),
sync_env(_sync_env),
};
class RGWRESTMgr;
+class RGWMetadataHandler;
class RGWSyncModuleInstance {
public:
virtual bool supports_user_writes() {
return false;
}
+ virtual RGWMetadataHandler *alloc_bucket_meta_handler();
+ virtual RGWMetadataHandler *alloc_bucket_instance_meta_handler();
};
typedef std::shared_ptr<RGWSyncModuleInstance> RGWSyncModuleInstanceRef;