1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
7 #include "svc_meta_be_sobj.h"
11 #define dout_subsys ceph_subsys_rgw
15 class RGW_MB_Handler_Module_OTP
: public RGWSI_MBSObj_Handler_Module
{
19 RGW_MB_Handler_Module_OTP(RGWSI_Zone
*_zone_svc
) : RGWSI_MBSObj_Handler_Module("otp"),
20 zone_svc(_zone_svc
) {}
22 void get_pool_and_oid(const string
& key
, rgw_pool
*pool
, string
*oid
) override
{
24 *pool
= zone_svc
->get_zone_params().otp_pool
;
32 const string
& get_oid_prefix() override
{
36 bool is_valid_oid(const string
& oid
) override
{
40 string
key_to_oid(const string
& key
) override
{
44 string
oid_to_key(const string
& oid
) override
{
49 RGWSI_OTP::RGWSI_OTP(CephContext
*cct
): RGWServiceInstance(cct
) {
52 RGWSI_OTP::~RGWSI_OTP() {
55 void RGWSI_OTP::init(RGWSI_Zone
*_zone_svc
,
56 RGWSI_Meta
*_meta_svc
,
57 RGWSI_MetaBackend
*_meta_be_svc
)
62 svc
.meta_be
= _meta_be_svc
;
65 int RGWSI_OTP::do_start(optional_yield
, const DoutPrefixProvider
*dpp
)
67 /* create first backend handler for bucket entrypoints */
69 RGWSI_MetaBackend_Handler
*_otp_be_handler
;
71 int r
= svc
.meta
->create_be_handler(RGWSI_MetaBackend::Type::MDBE_OTP
, &_otp_be_handler
);
73 ldout(ctx(), 0) << "ERROR: failed to create be handler: r=" << r
<< dendl
;
77 be_handler
= _otp_be_handler
;
79 RGWSI_MetaBackend_Handler_OTP
*otp_be_handler
= static_cast<RGWSI_MetaBackend_Handler_OTP
*>(_otp_be_handler
);
81 auto otp_be_module
= new RGW_MB_Handler_Module_OTP(svc
.zone
);
82 be_module
.reset(otp_be_module
);
83 otp_be_handler
->set_module(otp_be_module
);
88 int RGWSI_OTP::read_all(RGWSI_OTP_BE_Ctx
& ctx
,
90 otp_devices_list_t
*devices
,
92 RGWObjVersionTracker
*objv_tracker
,
93 optional_yield y
, const DoutPrefixProvider
*dpp
)
95 RGWSI_MBOTP_GetParams params
;
96 params
.pdevices
= devices
;
97 params
.pmtime
= pmtime
;
99 int ret
= svc
.meta_be
->get_entry(ctx
.get(), key
, params
, objv_tracker
, y
, dpp
);
107 int RGWSI_OTP::read_all(RGWSI_OTP_BE_Ctx
& ctx
,
109 otp_devices_list_t
*devices
,
111 RGWObjVersionTracker
*objv_tracker
,
113 const DoutPrefixProvider
*dpp
)
124 int RGWSI_OTP::store_all(const DoutPrefixProvider
*dpp
,
125 RGWSI_OTP_BE_Ctx
& ctx
,
127 const otp_devices_list_t
& devices
,
129 RGWObjVersionTracker
*objv_tracker
,
132 RGWSI_MBOTP_PutParams params
;
133 params
.mtime
= mtime
;
134 params
.devices
= devices
;
136 int ret
= svc
.meta_be
->put_entry(dpp
, ctx
.get(), key
, params
, objv_tracker
, y
);
144 int RGWSI_OTP::store_all(const DoutPrefixProvider
*dpp
,
145 RGWSI_OTP_BE_Ctx
& ctx
,
147 const otp_devices_list_t
& devices
,
149 RGWObjVersionTracker
*objv_tracker
,
152 return store_all(dpp
, ctx
,
160 int RGWSI_OTP::remove_all(const DoutPrefixProvider
*dpp
,
161 RGWSI_OTP_BE_Ctx
& ctx
,
163 RGWObjVersionTracker
*objv_tracker
,
166 RGWSI_MBOTP_RemoveParams params
;
168 int ret
= svc
.meta_be
->remove_entry(dpp
, ctx
.get(), key
, params
, objv_tracker
, y
);
176 int RGWSI_OTP::remove_all(const DoutPrefixProvider
*dpp
,
177 RGWSI_OTP_BE_Ctx
& ctx
,
179 RGWObjVersionTracker
*objv_tracker
,
182 return remove_all(dpp
,ctx
,