2 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 // vim: ts=8 sw=2 smarttab
6 * Ceph - scalable distributed file system
8 * Copyright (C) 2019 Red Hat, Inc.
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.
20 #include "rgw/rgw_service.h"
22 #include "svc_meta_be.h"
23 #include "svc_bucket_sync.h"
26 class RGWSI_SysObj_Cache
;
27 class RGWSI_Bucket_SObj
;
30 class RGWChainedCacheImpl
;
32 class RGWSI_Bucket_Sync_SObj_HintIndexManager
;
34 struct rgw_sync_bucket_entity
;
36 class RGWSI_Bucket_Sync_SObj
: public RGWSI_Bucket_Sync
38 struct bucket_sync_policy_cache_entry
{
39 std::shared_ptr
<RGWBucketSyncPolicyHandler
> handler
;
42 unique_ptr
<RGWChainedCacheImpl
<bucket_sync_policy_cache_entry
> > sync_policy_cache
;
44 std::unique_ptr
<RGWSI_Bucket_Sync_SObj_HintIndexManager
> hint_index_mgr
;
46 int do_start() override
;
48 struct optional_zone_bucket
{
49 optional
<rgw_zone_id
> zone
;
50 optional
<rgw_bucket
> bucket
;
52 optional_zone_bucket(const optional
<rgw_zone_id
>& _zone
,
53 const optional
<rgw_bucket
>& _bucket
) : zone(_zone
), bucket(_bucket
) {}
55 bool operator<(const optional_zone_bucket
& ozb
) const {
56 if (zone
< ozb
.zone
) {
59 if (zone
> ozb
.zone
) {
62 return bucket
< ozb
.bucket
;
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
,
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
,
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
,
85 RGWSI_Zone
*zone
{nullptr};
86 RGWSI_SysObj
*sysobj
{nullptr};
87 RGWSI_SysObj_Cache
*cache
{nullptr};
88 RGWSI_Bucket_SObj
*bucket_sobj
{nullptr};
91 RGWSI_Bucket_Sync_SObj(CephContext
*cct
);
92 ~RGWSI_Bucket_Sync_SObj();
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
);
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
,
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
;
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
;