]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_main.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rgw / rgw_main.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 /*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2022 Red Hat, Inc
8 *
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.
13 *
14 */
15
16 #pragma once
17
18 #include <vector>
19 #include <map>
20 #include <string>
21 #include "rgw_common.h"
22 #include "rgw_rest.h"
23 #include "rgw_frontend.h"
24 #include "rgw_period_pusher.h"
25 #include "rgw_realm_reloader.h"
26 #include "rgw_ldap.h"
27 #include "rgw_lua.h"
28 #include "rgw_dmclock_scheduler_ctx.h"
29 #include "rgw_ratelimit.h"
30
31
32 class RGWPauser : public RGWRealmReloader::Pauser {
33 std::vector<Pauser*> pausers;
34
35 public:
36 ~RGWPauser() override = default;
37
38 void add_pauser(Pauser* pauser) {
39 pausers.push_back(pauser);
40 }
41
42 void pause() override {
43 std::for_each(pausers.begin(), pausers.end(), [](Pauser* p){p->pause();});
44 }
45 void resume(rgw::sal::Driver* driver) override {
46 std::for_each(pausers.begin(), pausers.end(), [driver](Pauser* p){p->resume(driver);});
47 }
48
49 };
50
51 namespace rgw {
52
53 namespace lua { class Background; }
54
55 class RGWLib;
56 class AppMain {
57 /* several components should be initalized only if librgw is
58 * also serving HTTP */
59 bool have_http_frontend{false};
60 bool nfs{false};
61
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;
66 OpsLogSink* olog;
67 RGWREST rest;
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;
80 RGWProcessEnv env;
81
82 public:
83 AppMain(DoutPrefixProvider* dpp)
84 : dpp(dpp)
85 {}
86
87 void shutdown(std::function<void(void)> finalize_async_signals
88 = []() { /* nada */});
89
90 rgw::sal::Driver* get_driver() {
91 return env.driver;
92 }
93
94 rgw::LDAPHelper* get_ldh() {
95 return ldh.get();
96 }
97
98 void init_frontends1(bool nfs = false);
99 void init_numa();
100 void init_storage();
101 void init_perfcounters();
102 void init_http_clients();
103 void cond_init_apis();
104 void init_ldap();
105 void init_opslog();
106 int init_frontends2(RGWLib* rgwlib = nullptr);
107 void init_tracepoints();
108 void init_notification_endpoints();
109 void init_lua();
110
111 bool have_http() {
112 return have_http_frontend;
113 }
114
115 static OpsLogFile* ops_log_file;
116 }; /* AppMain */
117 } // namespace rgw
118
119 static inline RGWRESTMgr *set_logging(RGWRESTMgr* mgr)
120 {
121 mgr->set_logging(true);
122 return mgr;
123 }
124
125 static inline RGWRESTMgr *rest_filter(rgw::sal::Driver* driver, int dialect, RGWRESTMgr* orig)
126 {
127 RGWSyncModuleInstanceRef sync_module = driver->get_sync_module();
128 if (sync_module) {
129 return sync_module->get_rest_filter(dialect, orig);
130 } else {
131 return orig;
132 }
133 }
134