1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2022 Red Hat, Inc
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
21 #include "rgw_common.h"
23 #include "rgw_frontend.h"
24 #include "rgw_period_pusher.h"
25 #include "rgw_realm_reloader.h"
28 #include "rgw_dmclock_scheduler_ctx.h"
29 #include "rgw_ratelimit.h"
32 class RGWPauser
: public RGWRealmReloader::Pauser
{
33 std::vector
<Pauser
*> pausers
;
36 ~RGWPauser() override
= default;
38 void add_pauser(Pauser
* pauser
) {
39 pausers
.push_back(pauser
);
42 void pause() override
{
43 std::for_each(pausers
.begin(), pausers
.end(), [](Pauser
* p
){p
->pause();});
45 void resume(rgw::sal::Driver
* driver
) override
{
46 std::for_each(pausers
.begin(), pausers
.end(), [driver
](Pauser
* p
){p
->resume(driver
);});
53 namespace lua
{ class Background
; }
57 /* several components should be initalized only if librgw is
58 * also serving HTTP */
59 bool have_http_frontend
{false};
62 std::vector
<RGWFrontend
*> fes
;
63 std::vector
<RGWFrontendConfig
*> fe_configs
;
64 std::multimap
<string
, RGWFrontendConfig
*> fe_map
;
65 std::unique_ptr
<rgw::LDAPHelper
> ldh
;
68 std::unique_ptr
<rgw::lua::Background
> lua_background
;
69 std::unique_ptr
<rgw::auth::ImplicitTenants
> implicit_tenant_context
;
70 std::unique_ptr
<rgw::dmclock::SchedulerCtx
> sched_ctx
;
71 std::unique_ptr
<ActiveRateLimiter
> ratelimiter
;
72 std::map
<std::string
, std::string
> service_map_meta
;
73 // wow, realm reloader has a lot of parts
74 std::unique_ptr
<RGWRealmReloader
> reloader
;
75 std::unique_ptr
<RGWPeriodPusher
> pusher
;
76 std::unique_ptr
<RGWFrontendPauser
> fe_pauser
;
77 std::unique_ptr
<RGWRealmWatcher
> realm_watcher
;
78 std::unique_ptr
<RGWPauser
> rgw_pauser
;
79 DoutPrefixProvider
* dpp
;
83 AppMain(DoutPrefixProvider
* dpp
)
87 void shutdown(std::function
<void(void)> finalize_async_signals
88 = []() { /* nada */});
90 rgw::sal::Driver
* get_driver() {
94 rgw::LDAPHelper
* get_ldh() {
98 void init_frontends1(bool nfs
= false);
101 void init_perfcounters();
102 void init_http_clients();
103 void cond_init_apis();
106 int init_frontends2(RGWLib
* rgwlib
= nullptr);
107 void init_tracepoints();
108 void init_notification_endpoints();
112 return have_http_frontend
;
115 static OpsLogFile
* ops_log_file
;
119 static inline RGWRESTMgr
*set_logging(RGWRESTMgr
* mgr
)
121 mgr
->set_logging(true);
125 static inline RGWRESTMgr
*rest_filter(rgw::sal::Driver
* driver
, int dialect
, RGWRESTMgr
* orig
)
127 RGWSyncModuleInstanceRef sync_module
= driver
->get_sync_module();
129 return sync_module
->get_rest_filter(dialect
, orig
);