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"
9 #include "rgw/rgw_zone.h"
11 #define dout_subsys ceph_subsys_rgw
13 class RGW_MB_Handler_Module_OTP
: public RGWSI_MBSObj_Handler_Module
{
17 RGW_MB_Handler_Module_OTP(RGWSI_Zone
*_zone_svc
) : RGWSI_MBSObj_Handler_Module("otp"),
18 zone_svc(_zone_svc
) {}
20 void get_pool_and_oid(const string
& key
, rgw_pool
*pool
, string
*oid
) override
{
22 *pool
= zone_svc
->get_zone_params().otp_pool
;
30 const string
& get_oid_prefix() override
{
34 bool is_valid_oid(const string
& oid
) override
{
38 string
key_to_oid(const string
& key
) override
{
42 string
oid_to_key(const string
& oid
) override
{
47 RGWSI_OTP::RGWSI_OTP(CephContext
*cct
): RGWServiceInstance(cct
) {
50 RGWSI_OTP::~RGWSI_OTP() {
53 void RGWSI_OTP::init(RGWSI_Zone
*_zone_svc
,
54 RGWSI_Meta
*_meta_svc
,
55 RGWSI_MetaBackend
*_meta_be_svc
)
60 svc
.meta_be
= _meta_be_svc
;
63 int RGWSI_OTP::do_start(optional_yield
, const DoutPrefixProvider
*dpp
)
65 /* create first backend handler for bucket entrypoints */
67 RGWSI_MetaBackend_Handler
*_otp_be_handler
;
69 int r
= svc
.meta
->create_be_handler(RGWSI_MetaBackend::Type::MDBE_OTP
, &_otp_be_handler
);
71 ldout(ctx(), 0) << "ERROR: failed to create be handler: r=" << r
<< dendl
;
75 be_handler
= _otp_be_handler
;
77 RGWSI_MetaBackend_Handler_OTP
*otp_be_handler
= static_cast<RGWSI_MetaBackend_Handler_OTP
*>(_otp_be_handler
);
79 auto otp_be_module
= new RGW_MB_Handler_Module_OTP(svc
.zone
);
80 be_module
.reset(otp_be_module
);
81 otp_be_handler
->set_module(otp_be_module
);
86 int RGWSI_OTP::read_all(RGWSI_OTP_BE_Ctx
& ctx
,
88 otp_devices_list_t
*devices
,
90 RGWObjVersionTracker
*objv_tracker
,
91 optional_yield y
, const DoutPrefixProvider
*dpp
)
93 RGWSI_MBOTP_GetParams params
;
94 params
.pdevices
= devices
;
95 params
.pmtime
= pmtime
;
97 int ret
= svc
.meta_be
->get_entry(ctx
.get(), key
, params
, objv_tracker
, y
, dpp
);
105 int RGWSI_OTP::read_all(RGWSI_OTP_BE_Ctx
& ctx
,
107 otp_devices_list_t
*devices
,
109 RGWObjVersionTracker
*objv_tracker
,
111 const DoutPrefixProvider
*dpp
)
122 int RGWSI_OTP::store_all(const DoutPrefixProvider
*dpp
,
123 RGWSI_OTP_BE_Ctx
& ctx
,
125 const otp_devices_list_t
& devices
,
127 RGWObjVersionTracker
*objv_tracker
,
130 RGWSI_MBOTP_PutParams params
;
131 params
.mtime
= mtime
;
132 params
.devices
= devices
;
134 int ret
= svc
.meta_be
->put_entry(dpp
, ctx
.get(), key
, params
, objv_tracker
, y
);
142 int RGWSI_OTP::store_all(const DoutPrefixProvider
*dpp
,
143 RGWSI_OTP_BE_Ctx
& ctx
,
145 const otp_devices_list_t
& devices
,
147 RGWObjVersionTracker
*objv_tracker
,
150 return store_all(dpp
, ctx
,
158 int RGWSI_OTP::remove_all(const DoutPrefixProvider
*dpp
,
159 RGWSI_OTP_BE_Ctx
& ctx
,
161 RGWObjVersionTracker
*objv_tracker
,
164 RGWSI_MBOTP_RemoveParams params
;
166 int ret
= svc
.meta_be
->remove_entry(dpp
, ctx
.get(), key
, params
, objv_tracker
, y
);
174 int RGWSI_OTP::remove_all(const DoutPrefixProvider
*dpp
,
175 RGWSI_OTP_BE_Ctx
& ctx
,
177 RGWObjVersionTracker
*objv_tracker
,
180 return remove_all(dpp
,ctx
,