From c8e5d5e2adf0e4b2e307d054272bd1e2d00f27d2 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 12 Feb 2019 16:32:06 -0800 Subject: [PATCH] rgw: header cleanup: remove code from rgw_rados.h Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin_user.h | 4 +- src/rgw/rgw_cache.h | 4 +- src/rgw/rgw_pubsub.cc | 20 +++++++++ src/rgw/rgw_pubsub.h | 21 +++------ src/rgw/rgw_rados.cc | 1 + src/rgw/rgw_rados.h | 62 -------------------------- src/rgw/rgw_sync_trace.cc | 1 + src/rgw/rgw_trim_datalog.cc | 1 + src/rgw/rgw_worker.h | 89 +++++++++++++++++++++++++++++++++++++ 9 files changed, 122 insertions(+), 81 deletions(-) create mode 100644 src/rgw/rgw_worker.h diff --git a/src/rgw/rgw_admin_user.h b/src/rgw/rgw_admin_user.h index 68f8167f1fd..3aaabdf0c01 100644 --- a/src/rgw/rgw_admin_user.h +++ b/src/rgw/rgw_admin_user.h @@ -19,7 +19,7 @@ #include #include "common/config.h" -#include "rgw_rados.h" +class RGWRados; namespace rgw { @@ -35,7 +35,7 @@ namespace rgw { } int init(); - int init(vector& args); + int init(std::vector& args); int stop(); }; } diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index b0696237fe6..e726de474f4 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -4,7 +4,6 @@ #ifndef CEPH_RGWCACHE_H #define CEPH_RGWCACHE_H -#include "rgw_rados.h" #include #include #include @@ -13,6 +12,9 @@ #include "include/ceph_assert.h" #include "common/RWLock.h" +#include "cls/version/cls_version_types.h" +#include "rgw_common.h" + enum { UPDATE_OBJ, REMOVE_OBJ, diff --git a/src/rgw/rgw_pubsub.cc b/src/rgw/rgw_pubsub.cc index f2bc613c10e..5ca5635fb4d 100644 --- a/src/rgw/rgw_pubsub.cc +++ b/src/rgw/rgw_pubsub.cc @@ -8,6 +8,7 @@ #include "rgw_xml.h" #include "rgw_arn.h" #include "rgw_pubsub_push.h" +#include "rgw_rados.h" #define dout_subsys ceph_subsys_rgw @@ -161,6 +162,25 @@ void rgw_pubsub_sub_config::dump(Formatter *f) const encode_json("s3_id", s3_id, f); } +RGWUserPubSub::RGWUserPubSub(RGWRados *_store, const rgw_user& _user) : store(_store), + user(_user), + obj_ctx(store->svc.sysobj->init_obj_ctx()) +{ + get_user_meta_obj(&user_meta_obj); +} + +void RGWUserPubSub::get_user_meta_obj(rgw_raw_obj *obj) const { + *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, user_meta_oid()); +} + +void RGWUserPubSub::get_bucket_meta_obj(const rgw_bucket& bucket, rgw_raw_obj *obj) const { + *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, bucket_meta_oid(bucket)); +} + +void RGWUserPubSub::get_sub_meta_obj(const string& name, rgw_raw_obj *obj) const { + *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sub_meta_oid(name)); +} + int RGWUserPubSub::remove(const rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker) { int ret = rgw_delete_system_obj(store, obj.pool, obj.oid, objv_tracker); diff --git a/src/rgw/rgw_pubsub.h b/src/rgw/rgw_pubsub.h index 72773b404e7..a40d5bc2f94 100644 --- a/src/rgw/rgw_pubsub.h +++ b/src/rgw/rgw_pubsub.h @@ -6,6 +6,7 @@ #include "rgw_tools.h" #include "rgw_zone.h" +#include "rgw_rados.h" #include "services/svc_sys_obj.h" class XMLObj; @@ -450,11 +451,7 @@ class RGWUserPubSub int write_user_topics(const rgw_pubsub_user_topics& topics, RGWObjVersionTracker *objv_tracker); public: - RGWUserPubSub(RGWRados *_store, const rgw_user& _user) : store(_store), - user(_user), - obj_ctx(store->svc.sysobj->init_obj_ctx()) { - get_user_meta_obj(&user_meta_obj); - } + RGWUserPubSub(RGWRados *_store, const rgw_user& _user); class Bucket { friend class RGWUserPubSub; @@ -563,17 +560,9 @@ public: return std::make_shared>(this, sub); } - void get_user_meta_obj(rgw_raw_obj *obj) const { - *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, user_meta_oid()); - } - - void get_bucket_meta_obj(const rgw_bucket& bucket, rgw_raw_obj *obj) const { - *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, bucket_meta_oid(bucket)); - } - - void get_sub_meta_obj(const string& name, rgw_raw_obj *obj) const { - *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sub_meta_oid(name)); - } + void get_user_meta_obj(rgw_raw_obj *obj) const; + void get_bucket_meta_obj(const rgw_bucket& bucket, rgw_raw_obj *obj) const; + void get_sub_meta_obj(const string& name, rgw_raw_obj *obj) const; // get all topics defined for the user and populate them into "result" // return 0 on success or if no topics exist, error code otherwise diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 556aeda9503..b7f52859838 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -46,6 +46,7 @@ #include "rgw_tools.h" #include "rgw_coroutine.h" #include "rgw_compression.h" +#include "rgw_worker.h" #undef fork // fails to compile RGWPeriod::fork() below diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 1318199e0f1..fd252a943af 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -7,7 +7,6 @@ #include #include "include/rados/librados.hpp" -#include "include/Context.h" #include "common/admin_socket.h" #include "common/RefCountedObj.h" #include "common/RWLock.h" @@ -2566,65 +2565,4 @@ public: } }; // class RGWMPObj - -class RGWRadosThread { - class Worker : public Thread { - CephContext *cct; - RGWRadosThread *processor; - Mutex lock; - Cond cond; - - void wait() { - Mutex::Locker l(lock); - cond.Wait(lock); - }; - - void wait_interval(const utime_t& wait_time) { - Mutex::Locker l(lock); - cond.WaitInterval(lock, wait_time); - } - - public: - Worker(CephContext *_cct, RGWRadosThread *_p) : cct(_cct), processor(_p), lock("RGWRadosThread::Worker") {} - void *entry() override; - void signal() { - Mutex::Locker l(lock); - cond.Signal(); - } - }; - - Worker *worker; - -protected: - CephContext *cct; - RGWRados *store; - - std::atomic down_flag = { false }; - - string thread_name; - - virtual uint64_t interval_msec() = 0; - virtual void stop_process() {} -public: - RGWRadosThread(RGWRados *_store, const string& thread_name = "radosgw") - : worker(NULL), cct(_store->ctx()), store(_store), thread_name(thread_name) {} - virtual ~RGWRadosThread() { - stop(); - } - - virtual int init() { return 0; } - virtual int process() = 0; - - bool going_down() { return down_flag; } - - void start(); - void stop(); - - void signal() { - if (worker) { - worker->signal(); - } - } -}; - #endif diff --git a/src/rgw/rgw_sync_trace.cc b/src/rgw/rgw_sync_trace.cc index 34aa00e939d..f8f7b66ce13 100644 --- a/src/rgw/rgw_sync_trace.cc +++ b/src/rgw/rgw_sync_trace.cc @@ -11,6 +11,7 @@ #include "rgw_sync_trace.h" #include "rgw_rados.h" +#include "rgw_worker.h" #define dout_context g_ceph_context diff --git a/src/rgw/rgw_trim_datalog.cc b/src/rgw/rgw_trim_datalog.cc index 1fd0fdefbce..a42b872a07d 100644 --- a/src/rgw/rgw_trim_datalog.cc +++ b/src/rgw/rgw_trim_datalog.cc @@ -9,6 +9,7 @@ #include "rgw_cr_rest.h" #include "rgw_data_sync.h" #include "rgw_zone.h" +#include "rgw_bucket.h" #include diff --git a/src/rgw/rgw_worker.h b/src/rgw/rgw_worker.h new file mode 100644 index 00000000000..1a849c58086 --- /dev/null +++ b/src/rgw/rgw_worker.h @@ -0,0 +1,89 @@ + + +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2019 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 "common/Thread.h" +#include "common/Mutex.h" +#include "common/Cond.h" + +class CephContext; +class RGWRados; + +class RGWRadosThread { + class Worker : public Thread { + CephContext *cct; + RGWRadosThread *processor; + Mutex lock; + Cond cond; + + void wait() { + Mutex::Locker l(lock); + cond.Wait(lock); + }; + + void wait_interval(const utime_t& wait_time) { + Mutex::Locker l(lock); + cond.WaitInterval(lock, wait_time); + } + + public: + Worker(CephContext *_cct, RGWRadosThread *_p) : cct(_cct), processor(_p), lock("RGWRadosThread::Worker") {} + void *entry() override; + void signal() { + Mutex::Locker l(lock); + cond.Signal(); + } + }; + + Worker *worker; + +protected: + CephContext *cct; + RGWRados *store; + + std::atomic down_flag = { false }; + + std::string thread_name; + + virtual uint64_t interval_msec() = 0; + virtual void stop_process() {} +public: + RGWRadosThread(RGWRados *_store, const std::string& thread_name = "radosgw") + : worker(NULL), cct(_store->ctx()), store(_store), thread_name(thread_name) {} + virtual ~RGWRadosThread() { + stop(); + } + + virtual int init() { return 0; } + virtual int process() = 0; + + bool going_down() { return down_flag; } + + void start(); + void stop(); + + void signal() { + if (worker) { + worker->signal(); + } + } +}; + -- 2.39.5