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