]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_lib_frontend.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
4 #ifndef RGW_LIB_FRONTEND_H
5 #define RGW_LIB_FRONTEND_H
7 #include <boost/container/flat_map.hpp>
14 class RGWLibProcess
: public RGWProcess
{
15 RGWAccessKey access_key
;
17 std::condition_variable cv
;
21 typedef flat_map
<RGWLibFS
*, RGWLibFS
*> FSMAP
;
24 using lock_guard
= std::lock_guard
<std::mutex
>;
25 using unique_lock
= std::unique_lock
<std::mutex
>;
28 RGWLibProcess(CephContext
* cct
, RGWProcessEnv
* pe
, int num_threads
,
29 RGWFrontendConfig
* _conf
) :
30 RGWProcess(cct
, pe
, num_threads
, _conf
), gen(0), shutdown(false) {}
37 for (const auto& fs
: mounted_fs
) {
43 void register_fs(RGWLibFS
* fs
) {
44 lock_guard
guard(mtx
);
45 mounted_fs
.insert(FSMAP::value_type(fs
, fs
));
49 void unregister_fs(RGWLibFS
* fs
) {
50 lock_guard
guard(mtx
);
51 FSMAP::iterator it
= mounted_fs
.find(fs
);
52 if (it
!= mounted_fs
.end()) {
58 void enqueue_req(RGWLibRequest
* req
) {
60 lsubdout(g_ceph_context
, rgw
, 10)
61 << __func__
<< " enqueue request req="
62 << hex
<< req
<< dec
<< dendl
;
68 /* "regular" requests */
69 void handle_request(const DoutPrefixProvider
*dpp
, RGWRequest
* req
) override
; // async handler, deletes req
70 int process_request(RGWLibRequest
* req
);
71 int process_request(RGWLibRequest
* req
, RGWLibIO
* io
);
72 void set_access_key(RGWAccessKey
& key
) { access_key
= key
; }
74 /* requests w/continue semantics */
75 int start_request(RGWLibContinuedReq
* req
);
76 int finish_request(RGWLibContinuedReq
* req
);
77 }; /* RGWLibProcess */
79 class RGWLibFrontend
: public RGWProcessFrontend
{
81 RGWLibFrontend(RGWProcessEnv
& pe
, RGWFrontendConfig
*_conf
)
82 : RGWProcessFrontend(pe
, _conf
) {}
86 void stop() override
{
87 RGWProcessFrontend::stop();
88 get_process()->stop();
91 RGWLibProcess
* get_process() {
92 return static_cast<RGWLibProcess
*>(pprocess
);
95 inline void enqueue_req(RGWLibRequest
* req
) {
96 static_cast<RGWLibProcess
*>(pprocess
)->enqueue_req(req
); // async
99 inline int execute_req(RGWLibRequest
* req
) {
100 return static_cast<RGWLibProcess
*>(pprocess
)->process_request(req
); // !async
103 inline int start_req(RGWLibContinuedReq
* req
) {
104 return static_cast<RGWLibProcess
*>(pprocess
)->start_request(req
);
107 inline int finish_req(RGWLibContinuedReq
* req
) {
108 return static_cast<RGWLibProcess
*>(pprocess
)->finish_request(req
);
111 }; /* RGWLibFrontend */
113 } /* namespace rgw */
115 #endif /* RGW_LIB_FRONTEND_H */