From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/rgw/rgw_main.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 src/rgw/rgw_main.h (limited to 'src/rgw/rgw_main.h') diff --git a/src/rgw/rgw_main.h b/src/rgw/rgw_main.h new file mode 100644 index 000000000..bbe514351 --- /dev/null +++ b/src/rgw/rgw_main.h @@ -0,0 +1,134 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2022 Red Hat, Inc + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include +#include +#include +#include "rgw_common.h" +#include "rgw_rest.h" +#include "rgw_frontend.h" +#include "rgw_period_pusher.h" +#include "rgw_realm_reloader.h" +#include "rgw_ldap.h" +#include "rgw_lua.h" +#include "rgw_dmclock_scheduler_ctx.h" +#include "rgw_ratelimit.h" + + +class RGWPauser : public RGWRealmReloader::Pauser { + std::vector pausers; + +public: + ~RGWPauser() override = default; + + void add_pauser(Pauser* pauser) { + pausers.push_back(pauser); + } + + void pause() override { + std::for_each(pausers.begin(), pausers.end(), [](Pauser* p){p->pause();}); + } + void resume(rgw::sal::Driver* driver) override { + std::for_each(pausers.begin(), pausers.end(), [driver](Pauser* p){p->resume(driver);}); + } + +}; + +namespace rgw { + +namespace lua { class Background; } + +class RGWLib; +class AppMain { + /* several components should be initalized only if librgw is + * also serving HTTP */ + bool have_http_frontend{false}; + bool nfs{false}; + + std::vector fes; + std::vector fe_configs; + std::multimap fe_map; + std::unique_ptr ldh; + OpsLogSink* olog; + RGWREST rest; + std::unique_ptr lua_background; + std::unique_ptr implicit_tenant_context; + std::unique_ptr sched_ctx; + std::unique_ptr ratelimiter; + std::map service_map_meta; + // wow, realm reloader has a lot of parts + std::unique_ptr reloader; + std::unique_ptr pusher; + std::unique_ptr fe_pauser; + std::unique_ptr realm_watcher; + std::unique_ptr rgw_pauser; + DoutPrefixProvider* dpp; + RGWProcessEnv env; + +public: + AppMain(DoutPrefixProvider* dpp) + : dpp(dpp) + {} + + void shutdown(std::function finalize_async_signals + = []() { /* nada */}); + + rgw::sal::Driver* get_driver() { + return env.driver; + } + + rgw::LDAPHelper* get_ldh() { + return ldh.get(); + } + + void init_frontends1(bool nfs = false); + void init_numa(); + void init_storage(); + void init_perfcounters(); + void init_http_clients(); + void cond_init_apis(); + void init_ldap(); + void init_opslog(); + int init_frontends2(RGWLib* rgwlib = nullptr); + void init_tracepoints(); + void init_notification_endpoints(); + void init_lua(); + + bool have_http() { + return have_http_frontend; + } + + static OpsLogFile* ops_log_file; +}; /* AppMain */ +} // namespace rgw + +static inline RGWRESTMgr *set_logging(RGWRESTMgr* mgr) +{ + mgr->set_logging(true); + return mgr; +} + +static inline RGWRESTMgr *rest_filter(rgw::sal::Driver* driver, int dialect, RGWRESTMgr* orig) +{ + RGWSyncModuleInstanceRef sync_module = driver->get_sync_module(); + if (sync_module) { + return sync_module->get_rest_filter(dialect, orig); + } else { + return orig; + } +} + -- cgit v1.2.3