]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_sync_module.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rgw / rgw_sync_module.cc
1 #include "rgw_common.h"
2 #include "rgw_coroutine.h"
3 #include "rgw_cr_rados.h"
4 #include "rgw_sync_module.h"
5 #include "rgw_data_sync.h"
6 #include "rgw_boost_asio_yield.h"
7
8 #include "rgw_sync_module_log.h"
9 #include "rgw_sync_module_es.h"
10
11 #define dout_subsys ceph_subsys_rgw
12
13 RGWStatRemoteObjCBCR::RGWStatRemoteObjCBCR(RGWDataSyncEnv *_sync_env,
14 RGWBucketInfo& _bucket_info, rgw_obj_key& _key) : RGWCoroutine(_sync_env->cct),
15 sync_env(_sync_env),
16 bucket_info(_bucket_info), key(_key) {
17 }
18
19 RGWCallStatRemoteObjCR::RGWCallStatRemoteObjCR(RGWDataSyncEnv *_sync_env,
20 RGWBucketInfo& _bucket_info, rgw_obj_key& _key) : RGWCoroutine(_sync_env->cct),
21 sync_env(_sync_env),
22 bucket_info(_bucket_info), key(_key) {
23 }
24
25 int RGWCallStatRemoteObjCR::operate() {
26 reenter(this) {
27 yield {
28 call(new RGWStatRemoteObjCR(sync_env->async_rados, sync_env->store,
29 sync_env->source_zone,
30 bucket_info, key, &mtime, &size, &attrs));
31 }
32 if (retcode < 0) {
33 ldout(sync_env->cct, 0) << "RGWStatRemoteObjCR() returned " << retcode << dendl;
34 return set_cr_error(retcode);
35 }
36 ldout(sync_env->cct, 20) << "stat of remote obj: z=" << sync_env->source_zone
37 << " b=" << bucket_info.bucket << " k=" << key << " size=" << size << " mtime=" << mtime
38 << " attrs=" << attrs << dendl;
39 yield {
40 RGWStatRemoteObjCBCR *cb = allocate_callback();
41 if (cb) {
42 cb->set_result(mtime, size, std::move(attrs));
43 call(cb);
44 }
45 }
46 if (retcode < 0) {
47 ldout(sync_env->cct, 0) << "RGWStatRemoteObjCR() callback returned " << retcode << dendl;
48 return set_cr_error(retcode);
49 }
50 return set_cr_done();
51 }
52 return 0;
53 }
54
55 void rgw_register_sync_modules(RGWSyncModulesManager *modules_manager)
56 {
57 RGWSyncModuleRef default_module(std::make_shared<RGWDefaultSyncModule>());
58 modules_manager->register_module("rgw", default_module, true);
59
60 RGWSyncModuleRef log_module(std::make_shared<RGWLogSyncModule>());
61 modules_manager->register_module("log", log_module);
62
63 RGWSyncModuleRef es_module(std::make_shared<RGWElasticSyncModule>());
64 modules_manager->register_module("elasticsearch", es_module);
65 }