]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_sync_module_log.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_sync_module_log.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #include "rgw_common.h"
5 #include "rgw_coroutine.h"
6 #include "rgw_cr_rados.h"
7 #include "rgw_sync_module.h"
8 #include "rgw_data_sync.h"
9 #include "rgw_sync_module_log.h"
10
11 #define dout_subsys ceph_subsys_rgw
12
13 using namespace std;
14
15 class RGWLogStatRemoteObjCBCR : public RGWStatRemoteObjCBCR {
16 public:
17 RGWLogStatRemoteObjCBCR(RGWDataSyncCtx *_sc,
18 rgw_bucket& _src_bucket, rgw_obj_key& _key) : RGWStatRemoteObjCBCR(_sc, _src_bucket, _key) {}
19 int operate(const DoutPrefixProvider *dpp) override {
20 ldpp_dout(dpp, 0) << "SYNC_LOG: stat of remote obj: z=" << sc->source_zone
21 << " b=" << src_bucket << " k=" << key << " size=" << size << " mtime=" << mtime
22 << " attrs=" << attrs << dendl;
23 return set_cr_done();
24 }
25
26 };
27
28 class RGWLogStatRemoteObjCR : public RGWCallStatRemoteObjCR {
29 public:
30 RGWLogStatRemoteObjCR(RGWDataSyncCtx *_sc,
31 rgw_bucket& _src_bucket, rgw_obj_key& _key) : RGWCallStatRemoteObjCR(_sc, _src_bucket, _key) {
32 }
33
34 ~RGWLogStatRemoteObjCR() override {}
35
36 RGWStatRemoteObjCBCR *allocate_callback() override {
37 return new RGWLogStatRemoteObjCBCR(sc, src_bucket, key);
38 }
39 };
40
41 class RGWLogDataSyncModule : public RGWDataSyncModule {
42 string prefix;
43 public:
44 explicit RGWLogDataSyncModule(const string& _prefix) : prefix(_prefix) {}
45
46 RGWCoroutine *sync_object(const DoutPrefixProvider *dpp, RGWDataSyncCtx *sc, rgw_bucket_sync_pipe& sync_pipe, rgw_obj_key& key, std::optional<uint64_t> versioned_epoch, rgw_zone_set *zones_trace) override {
47 ldpp_dout(dpp, 0) << prefix << ": SYNC_LOG: sync_object: b=" << sync_pipe.info.source_bs.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch.value_or(0) << dendl;
48 return new RGWLogStatRemoteObjCR(sc, sync_pipe.info.source_bs.bucket, key);
49 }
50 RGWCoroutine *remove_object(const DoutPrefixProvider *dpp, RGWDataSyncCtx *sc, rgw_bucket_sync_pipe& sync_pipe, rgw_obj_key& key, real_time& mtime, bool versioned, uint64_t versioned_epoch, rgw_zone_set *zones_trace) override {
51 ldpp_dout(dpp, 0) << prefix << ": SYNC_LOG: rm_object: b=" << sync_pipe.info.source_bs.bucket << " k=" << key << " mtime=" << mtime << " versioned=" << versioned << " versioned_epoch=" << versioned_epoch << dendl;
52 return NULL;
53 }
54 RGWCoroutine *create_delete_marker(const DoutPrefixProvider *dpp, RGWDataSyncCtx *sc, rgw_bucket_sync_pipe& sync_pipe, rgw_obj_key& key, real_time& mtime,
55 rgw_bucket_entry_owner& owner, bool versioned, uint64_t versioned_epoch, rgw_zone_set *zones_trace) override {
56 ldpp_dout(dpp, 0) << prefix << ": SYNC_LOG: create_delete_marker: b=" << sync_pipe.info.source_bs.bucket << " k=" << key << " mtime=" << mtime
57 << " versioned=" << versioned << " versioned_epoch=" << versioned_epoch << dendl;
58 return NULL;
59 }
60 };
61
62 class RGWLogSyncModuleInstance : public RGWSyncModuleInstance {
63 RGWLogDataSyncModule data_handler;
64 public:
65 explicit RGWLogSyncModuleInstance(const string& prefix) : data_handler(prefix) {}
66 RGWDataSyncModule *get_data_handler() override {
67 return &data_handler;
68 }
69 };
70
71 int RGWLogSyncModule::create_instance(const DoutPrefixProvider *dpp, CephContext *cct, const JSONFormattable& config, RGWSyncModuleInstanceRef *instance) {
72 string prefix = config["prefix"];
73 instance->reset(new RGWLogSyncModuleInstance(prefix));
74 return 0;
75 }
76