]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_bucket_sync_sobj.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / rgw / services / svc_bucket_sync_sobj.h
1
2 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 // vim: ts=8 sw=2 smarttab
4
5 /*
6 * Ceph - scalable distributed file system
7 *
8 * Copyright (C) 2019 Red Hat, Inc.
9 *
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
14 *
15 */
16
17
18 #pragma once
19
20 #include "rgw/rgw_service.h"
21
22 #include "svc_meta_be.h"
23 #include "svc_bucket_sync.h"
24
25 class RGWSI_Zone;
26 class RGWSI_SysObj_Cache;
27 class RGWSI_Bucket_SObj;
28
29 template <class T>
30 class RGWChainedCacheImpl;
31
32 class RGWSI_Bucket_Sync_SObj_HintIndexManager;
33
34 struct rgw_sync_bucket_entity;
35
36 class RGWSI_Bucket_Sync_SObj : public RGWSI_Bucket_Sync
37 {
38 struct bucket_sync_policy_cache_entry {
39 std::shared_ptr<RGWBucketSyncPolicyHandler> handler;
40 };
41
42 unique_ptr<RGWChainedCacheImpl<bucket_sync_policy_cache_entry> > sync_policy_cache;
43
44 std::unique_ptr<RGWSI_Bucket_Sync_SObj_HintIndexManager> hint_index_mgr;
45
46 int do_start() override;
47
48 struct optional_zone_bucket {
49 optional<rgw_zone_id> zone;
50 optional<rgw_bucket> bucket;
51
52 optional_zone_bucket(const optional<rgw_zone_id>& _zone,
53 const optional<rgw_bucket>& _bucket) : zone(_zone), bucket(_bucket) {}
54
55 bool operator<(const optional_zone_bucket& ozb) const {
56 if (zone < ozb.zone) {
57 return true;
58 }
59 if (zone > ozb.zone) {
60 return false;
61 }
62 return bucket < ozb.bucket;
63 }
64 };
65
66 void get_hint_entities(RGWSI_Bucket_X_Ctx& ctx,
67 const std::set<rgw_zone_id>& zone_names,
68 const std::set<rgw_bucket>& buckets,
69 std::set<rgw_sync_bucket_entity> *hint_entities,
70 optional_yield y);
71 int resolve_policy_hints(RGWSI_Bucket_X_Ctx& ctx,
72 rgw_sync_bucket_entity& self_entity,
73 RGWBucketSyncPolicyHandlerRef& handler,
74 RGWBucketSyncPolicyHandlerRef& zone_policy_handler,
75 std::map<optional_zone_bucket, RGWBucketSyncPolicyHandlerRef>& temp_map,
76 optional_yield y);
77 int do_get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
78 std::optional<rgw_zone_id> zone,
79 std::optional<rgw_bucket> _bucket,
80 std::map<optional_zone_bucket, RGWBucketSyncPolicyHandlerRef>& temp_map,
81 RGWBucketSyncPolicyHandlerRef *handler,
82 optional_yield y);
83 public:
84 struct Svc {
85 RGWSI_Zone *zone{nullptr};
86 RGWSI_SysObj *sysobj{nullptr};
87 RGWSI_SysObj_Cache *cache{nullptr};
88 RGWSI_Bucket_SObj *bucket_sobj{nullptr};
89 } svc;
90
91 RGWSI_Bucket_Sync_SObj(CephContext *cct);
92 ~RGWSI_Bucket_Sync_SObj();
93
94 void init(RGWSI_Zone *_zone_svc,
95 RGWSI_SysObj *_sysobj_svc,
96 RGWSI_SysObj_Cache *_cache_svc,
97 RGWSI_Bucket_SObj *_bucket_sobj_svc);
98
99
100 int get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
101 std::optional<rgw_zone_id> zone,
102 std::optional<rgw_bucket> bucket,
103 RGWBucketSyncPolicyHandlerRef *handler,
104 optional_yield y);
105
106 int handle_bi_update(RGWBucketInfo& bucket_info,
107 RGWBucketInfo *orig_bucket_info,
108 optional_yield y) override;
109 int handle_bi_removal(const RGWBucketInfo& bucket_info,
110 optional_yield y) override;
111
112 int get_bucket_sync_hints(const rgw_bucket& bucket,
113 std::set<rgw_bucket> *sources,
114 std::set<rgw_bucket> *dests,
115 optional_yield y) override;
116 };
117