1 #ifndef CEPH_RGW_SYNC_MODULE_H
2 #define CEPH_RGW_SYNC_MODULE_H
4 #include "rgw_common.h"
5 #include "rgw_coroutine.h"
8 class RGWRemoteDataLog;
10 struct rgw_bucket_entry_owner;
14 class RGWDataSyncModule {
16 RGWDataSyncModule() {}
17 virtual ~RGWDataSyncModule() {}
19 virtual void init(RGWDataSyncEnv *sync_env, uint64_t instance_id) {}
21 virtual RGWCoroutine *init_sync(RGWDataSyncEnv *sync_env) {
25 virtual RGWCoroutine *sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, uint64_t versioned_epoch, rgw_zone_set *zones_trace) = 0;
26 virtual RGWCoroutine *remove_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime,
27 bool versioned, uint64_t versioned_epoch, rgw_zone_set *zones_trace) = 0;
28 virtual RGWCoroutine *create_delete_marker(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime,
29 rgw_bucket_entry_owner& owner, bool versioned, uint64_t versioned_epoch, rgw_zone_set *zones_trace) = 0;
34 class RGWSyncModuleInstance {
36 RGWSyncModuleInstance() {}
37 virtual ~RGWSyncModuleInstance() {}
38 virtual RGWDataSyncModule *get_data_handler() = 0;
39 virtual RGWRESTMgr *get_rest_filter(int dialect, RGWRESTMgr *orig) {
44 typedef std::shared_ptr<RGWSyncModuleInstance> RGWSyncModuleInstanceRef;
50 virtual ~RGWSyncModule() {}
52 virtual bool supports_data_export() = 0;
53 virtual int create_instance(CephContext *cct, map<string, string, ltstr_nocase>& config, RGWSyncModuleInstanceRef *instance) = 0;
56 typedef std::shared_ptr<RGWSyncModule> RGWSyncModuleRef;
59 class RGWSyncModulesManager {
62 map<string, RGWSyncModuleRef> modules;
64 RGWSyncModulesManager() : lock("RGWSyncModulesManager") {}
66 void register_module(const string& name, RGWSyncModuleRef& module, bool is_default = false) {
67 Mutex::Locker l(lock);
68 modules[name] = module;
70 modules[string()] = module;
74 bool get_module(const string& name, RGWSyncModuleRef *module) {
75 Mutex::Locker l(lock);
76 auto iter = modules.find(name);
77 if (iter == modules.end()) {
80 *module = iter->second;
85 int supports_data_export(const string& name) {
86 RGWSyncModuleRef module;
87 if (!get_module(name, &module)) {
91 return module.get()->supports_data_export();
94 int create_instance(CephContext *cct, const string& name, map<string, string, ltstr_nocase>& config, RGWSyncModuleInstanceRef *instance) {
95 RGWSyncModuleRef module;
96 if (!get_module(name, &module)) {
100 return module.get()->create_instance(cct, config, instance);
104 class RGWStatRemoteObjCBCR : public RGWCoroutine {
106 RGWDataSyncEnv *sync_env;
108 RGWBucketInfo bucket_info;
111 ceph::real_time mtime;
113 map<string, bufferlist> attrs;
115 RGWStatRemoteObjCBCR(RGWDataSyncEnv *_sync_env,
116 RGWBucketInfo& _bucket_info, rgw_obj_key& _key);
117 ~RGWStatRemoteObjCBCR() override {}
119 void set_result(ceph::real_time& _mtime,
121 map<string, bufferlist>&& _attrs) {
124 attrs = std::move(_attrs);
128 class RGWCallStatRemoteObjCR : public RGWCoroutine {
129 ceph::real_time mtime;
131 map<string, bufferlist> attrs;
134 RGWDataSyncEnv *sync_env;
136 RGWBucketInfo bucket_info;
140 RGWCallStatRemoteObjCR(RGWDataSyncEnv *_sync_env,
141 RGWBucketInfo& _bucket_info, rgw_obj_key& _key);
143 ~RGWCallStatRemoteObjCR() override {}
145 int operate() override;
147 virtual RGWStatRemoteObjCBCR *allocate_callback() {
152 void rgw_register_sync_modules(RGWSyncModulesManager *modules_manager);