// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab ft=cpp #ifndef CEPH_RGW_SERVICE_H #define CEPH_RGW_SERVICE_H #include #include #include #include "common/async/yield_context.h" #include "rgw/rgw_common.h" struct RGWServices_Def; class RGWServiceInstance { friend struct RGWServices_Def; protected: CephContext *cct; enum StartState { StateInit = 0, StateStarting = 1, StateStarted = 2, } start_state{StateInit}; virtual void shutdown() {} virtual int do_start(optional_yield, const DoutPrefixProvider *dpp) { return 0; } public: RGWServiceInstance(CephContext *_cct) : cct(_cct) {} virtual ~RGWServiceInstance() {} int start(optional_yield y, const DoutPrefixProvider *dpp); bool is_started() { return (start_state == StateStarted); } CephContext *ctx() { return cct; } }; class RGWSI_Finisher; class RGWSI_Bucket; class RGWSI_Bucket_SObj; class RGWSI_Bucket_Sync; class RGWSI_Bucket_Sync_SObj; class RGWSI_BucketIndex; class RGWSI_BucketIndex_RADOS; class RGWSI_BILog_RADOS; class RGWSI_Cls; class RGWSI_ConfigKey; class RGWSI_ConfigKey_RADOS; class RGWSI_MDLog; class RGWSI_Meta; class RGWSI_MetaBackend; class RGWSI_MetaBackend_SObj; class RGWSI_MetaBackend_OTP; class RGWSI_Notify; class RGWSI_OTP; class RGWSI_RADOS; class RGWSI_Zone; class RGWSI_ZoneUtils; class RGWSI_Quota; class RGWSI_SyncModules; class RGWSI_SysObj; class RGWSI_SysObj_Core; class RGWSI_SysObj_Cache; class RGWSI_User; class RGWSI_User_RADOS; class RGWDataChangesLog; struct RGWServices_Def { bool can_shutdown{false}; bool has_shutdown{false}; std::unique_ptr finisher; std::unique_ptr bucket_sobj; std::unique_ptr bucket_sync_sobj; std::unique_ptr bi_rados; std::unique_ptr bilog_rados; std::unique_ptr cls; std::unique_ptr config_key_rados; std::unique_ptr mdlog; std::unique_ptr meta; std::unique_ptr meta_be_sobj; std::unique_ptr meta_be_otp; std::unique_ptr notify; std::unique_ptr otp; std::unique_ptr rados; std::unique_ptr zone; std::unique_ptr zone_utils; std::unique_ptr quota; std::unique_ptr sync_modules; std::unique_ptr sysobj; std::unique_ptr sysobj_core; std::unique_ptr sysobj_cache; std::unique_ptr user_rados; std::unique_ptr datalog_rados; RGWServices_Def(); ~RGWServices_Def(); int init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp); void shutdown(); }; struct RGWServices { RGWServices_Def _svc; CephContext *cct; RGWSI_Finisher *finisher{nullptr}; RGWSI_Bucket *bucket{nullptr}; RGWSI_Bucket_SObj *bucket_sobj{nullptr}; RGWSI_Bucket_Sync *bucket_sync{nullptr}; RGWSI_Bucket_Sync_SObj *bucket_sync_sobj{nullptr}; RGWSI_BucketIndex *bi{nullptr}; RGWSI_BucketIndex_RADOS *bi_rados{nullptr}; RGWSI_BILog_RADOS *bilog_rados{nullptr}; RGWSI_Cls *cls{nullptr}; RGWSI_ConfigKey_RADOS *config_key_rados{nullptr}; RGWSI_ConfigKey *config_key{nullptr}; RGWDataChangesLog *datalog_rados{nullptr}; RGWSI_MDLog *mdlog{nullptr}; RGWSI_Meta *meta{nullptr}; RGWSI_MetaBackend *meta_be_sobj{nullptr}; RGWSI_MetaBackend *meta_be_otp{nullptr}; RGWSI_Notify *notify{nullptr}; RGWSI_OTP *otp{nullptr}; RGWSI_RADOS *rados{nullptr}; RGWSI_Zone *zone{nullptr}; RGWSI_ZoneUtils *zone_utils{nullptr}; RGWSI_Quota *quota{nullptr}; RGWSI_SyncModules *sync_modules{nullptr}; RGWSI_SysObj *sysobj{nullptr}; RGWSI_SysObj_Cache *cache{nullptr}; RGWSI_SysObj_Core *core{nullptr}; RGWSI_User *user{nullptr}; int do_init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp); int init(CephContext *cct, bool have_cache, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp) { return do_init(cct, have_cache, false, run_sync, y, dpp); } int init_raw(CephContext *cct, bool have_cache, optional_yield y, const DoutPrefixProvider *dpp) { return do_init(cct, have_cache, true, false, y, dpp); } void shutdown() { _svc.shutdown(); } }; class RGWMetadataManager; class RGWMetadataHandler; class RGWUserCtl; class RGWBucketCtl; class RGWOTPCtl; struct RGWCtlDef { struct _meta { std::unique_ptr mgr; std::unique_ptr bucket; std::unique_ptr bucket_instance; std::unique_ptr user; std::unique_ptr otp; _meta(); ~_meta(); } meta; std::unique_ptr user; std::unique_ptr bucket; std::unique_ptr otp; RGWCtlDef(); ~RGWCtlDef(); int init(RGWServices& svc, const DoutPrefixProvider *dpp); }; struct RGWCtl { CephContext *cct{nullptr}; RGWServices *svc{nullptr}; RGWCtlDef _ctl; struct _meta { RGWMetadataManager *mgr{nullptr}; RGWMetadataHandler *bucket{nullptr}; RGWMetadataHandler *bucket_instance{nullptr}; RGWMetadataHandler *user{nullptr}; RGWMetadataHandler *otp{nullptr}; } meta; RGWUserCtl *user{nullptr}; RGWBucketCtl *bucket{nullptr}; RGWOTPCtl *otp{nullptr}; int init(RGWServices *_svc, const DoutPrefixProvider *dpp); }; #endif