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 RGWCoroutine
*sync_object(RGWDataSyncEnv
*sync_env
, RGWBucketInfo
& bucket_info
, rgw_obj_key
& key
, uint64_t versioned_epoch
) = 0;
20 virtual RGWCoroutine
*remove_object(RGWDataSyncEnv
*sync_env
, RGWBucketInfo
& bucket_info
, rgw_obj_key
& key
, real_time
& mtime
,
21 bool versioned
, uint64_t versioned_epoch
) = 0;
22 virtual RGWCoroutine
*create_delete_marker(RGWDataSyncEnv
*sync_env
, RGWBucketInfo
& bucket_info
, rgw_obj_key
& key
, real_time
& mtime
,
23 rgw_bucket_entry_owner
& owner
, bool versioned
, uint64_t versioned_epoch
) = 0;
26 class RGWSyncModuleInstance
{
28 RGWSyncModuleInstance() {}
29 virtual ~RGWSyncModuleInstance() {}
30 virtual RGWDataSyncModule
*get_data_handler() = 0;
33 typedef std::shared_ptr
<RGWSyncModuleInstance
> RGWSyncModuleInstanceRef
;
39 virtual ~RGWSyncModule() {}
41 virtual bool supports_data_export() = 0;
42 virtual int create_instance(CephContext
*cct
, map
<string
, string
>& config
, RGWSyncModuleInstanceRef
*instance
) = 0;
45 typedef std::shared_ptr
<RGWSyncModule
> RGWSyncModuleRef
;
48 class RGWSyncModulesManager
{
51 map
<string
, RGWSyncModuleRef
> modules
;
53 RGWSyncModulesManager() : lock("RGWSyncModulesManager") {}
55 void register_module(const string
& name
, RGWSyncModuleRef
& module
, bool is_default
= false) {
56 Mutex::Locker
l(lock
);
57 modules
[name
] = module
;
59 modules
[string()] = module
;
63 bool get_module(const string
& name
, RGWSyncModuleRef
*module
) {
64 Mutex::Locker
l(lock
);
65 auto iter
= modules
.find(name
);
66 if (iter
== modules
.end()) {
69 *module
= iter
->second
;
74 int supports_data_export(const string
& name
) {
75 RGWSyncModuleRef module
;
76 if (!get_module(name
, &module
)) {
80 return module
.get()->supports_data_export();
83 int create_instance(CephContext
*cct
, const string
& name
, map
<string
, string
>& config
, RGWSyncModuleInstanceRef
*instance
) {
84 RGWSyncModuleRef module
;
85 if (!get_module(name
, &module
)) {
89 return module
.get()->create_instance(cct
, config
, instance
);
93 class RGWStatRemoteObjCBCR
: public RGWCoroutine
{
95 RGWDataSyncEnv
*sync_env
;
97 RGWBucketInfo bucket_info
;
100 ceph::real_time mtime
;
102 map
<string
, bufferlist
> attrs
;
104 RGWStatRemoteObjCBCR(RGWDataSyncEnv
*_sync_env
,
105 RGWBucketInfo
& _bucket_info
, rgw_obj_key
& _key
);
106 ~RGWStatRemoteObjCBCR() override
{}
108 void set_result(ceph::real_time
& _mtime
,
110 map
<string
, bufferlist
>&& _attrs
) {
113 attrs
= std::move(_attrs
);
117 class RGWCallStatRemoteObjCR
: public RGWCoroutine
{
118 ceph::real_time mtime
;
120 map
<string
, bufferlist
> attrs
;
123 RGWDataSyncEnv
*sync_env
;
125 RGWBucketInfo bucket_info
;
129 RGWCallStatRemoteObjCR(RGWDataSyncEnv
*_sync_env
,
130 RGWBucketInfo
& _bucket_info
, rgw_obj_key
& _key
);
132 ~RGWCallStatRemoteObjCR() override
{}
134 int operate() override
;
136 virtual RGWStatRemoteObjCBCR
*allocate_callback() {
141 void rgw_register_sync_modules(RGWSyncModulesManager
*modules_manager
);