diff options
author | Radoslaw Zarzynski <rzarzynski@mirantis.com> | 2016-10-04 13:21:13 +0200 |
---|---|---|
committer | Radoslaw Zarzynski <rzarzynski@mirantis.com> | 2016-10-21 22:57:21 +0200 |
commit | 79923f4ddd3a3bb2185946e0591f99ddec5af7a2 (patch) | |
tree | d19d3a13519698a2b9cd58751dc26702c55f281a | |
parent | rgw: ONLY replace std::size_t with size_t. (diff) | |
download | ceph-79923f4ddd3a3bb2185946e0591f99ddec5af7a2.tar.xz ceph-79923f4ddd3a3bb2185946e0591f99ddec5af7a2.zip |
rgw: switch to namespaces and change naming in the frontend subsystem.
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
-rw-r--r-- | src/rgw/rgw_asio_client.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_asio_client.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_civetweb.cc | 10 | ||||
-rw-r--r-- | src/rgw/rgw_civetweb.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_civetweb_frontend.cc | 8 | ||||
-rw-r--r-- | src/rgw/rgw_client_io.cc | 9 | ||||
-rw-r--r-- | src/rgw/rgw_client_io.h | 52 | ||||
-rw-r--r-- | src/rgw/rgw_client_io_decoimpl.h | 141 | ||||
-rw-r--r-- | src/rgw/rgw_common.h | 8 | ||||
-rw-r--r-- | src/rgw/rgw_fcgi.cc | 4 | ||||
-rw-r--r-- | src/rgw/rgw_fcgi.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_fcgi_process.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_lib.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_loadgen.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_op.cc | 4 | ||||
-rw-r--r-- | src/rgw/rgw_op.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rest.cc | 18 | ||||
-rw-r--r-- | src/rgw/rgw_rest.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.cc | 4 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.h | 8 | ||||
-rw-r--r-- | src/rgw/rgw_rest_swift.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rest_swift.h | 12 | ||||
-rw-r--r-- | src/rgw/rgw_swift_auth.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_swift_auth.h | 2 |
24 files changed, 166 insertions, 138 deletions
diff --git a/src/rgw/rgw_asio_client.cc b/src/rgw/rgw_asio_client.cc index 06627b660c9..577d0027711 100644 --- a/src/rgw/rgw_asio_client.cc +++ b/src/rgw/rgw_asio_client.cc @@ -85,7 +85,7 @@ size_t RGWAsioClientIO::write_data(const char* const buf, auto bytes = boost::asio::write(socket, boost::asio::buffer(buf, len), ec); if (ec) { derr << "write_data failed with " << ec.message() << dendl; - throw RGWRestfulIOEngine::Exception(ec.value(), std::system_category()); + throw rgw::io::RestfulClient::Exception(ec.value(), std::system_category()); } return bytes; } diff --git a/src/rgw/rgw_asio_client.h b/src/rgw/rgw_asio_client.h index afbfa0fcee9..80dfa036390 100644 --- a/src/rgw/rgw_asio_client.h +++ b/src/rgw/rgw_asio_client.h @@ -24,7 +24,7 @@ class RGWBufferlistBody { Headers>; }; -class RGWAsioClientIO : public RGWRestfulIOEngine { +class RGWAsioClientIO : public rgw::io::RestfulClient { using tcp = boost::asio::ip::tcp; tcp::socket socket; diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 51873933134..2eb74a84006 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -17,9 +17,9 @@ size_t RGWCivetWeb::write_data(const char *buf, size_t len) const int ret = mg_write(conn, buf, len); if (ret == 0) { /* didn't send anything, error out */ - throw RGWRestfulIOEngine::Exception(EIO, std::system_category()); + throw rgw::io::RestfulClient::Exception(EIO, std::system_category()); } else if (ret < 0) { - throw RGWRestfulIOEngine::Exception(-ret, std::system_category()); + throw rgw::io::RestfulClient::Exception(-ret, std::system_category()); } return ret; } @@ -36,7 +36,7 @@ size_t RGWCivetWeb::read_data(char *buf, size_t len) { const int ret = mg_read(conn, buf, len); if (ret < 0) { - throw RGWRestfulIOEngine::Exception(-ret, std::system_category()); + throw rgw::io::RestfulClient::Exception(-ret, std::system_category()); } return ret; } @@ -121,9 +121,9 @@ static inline size_t safe_mg_printf(Args&&... args) const int ret = mg_printf(std::forward<Args>(args)...); if (ret == 0) { /* didn't send anything, error out */ - throw RGWRestfulIOEngine::Exception(EIO, std::system_category()); + throw rgw::io::RestfulClient::Exception(EIO, std::system_category()); } else if (ret < 0) { - throw RGWRestfulIOEngine::Exception(-ret, std::system_category()); + throw rgw::io::RestfulClient::Exception(-ret, std::system_category()); } return static_cast<size_t>(ret); } diff --git a/src/rgw/rgw_civetweb.h b/src/rgw/rgw_civetweb.h index 5f91e311965..d353a8c152d 100644 --- a/src/rgw/rgw_civetweb.h +++ b/src/rgw/rgw_civetweb.h @@ -10,7 +10,7 @@ struct mg_connection; -class RGWCivetWeb : public RGWRestfulIOEngine +class RGWCivetWeb : public rgw::io::RestfulClient { RGWEnv env; mg_connection *conn; diff --git a/src/rgw/rgw_civetweb_frontend.cc b/src/rgw/rgw_civetweb_frontend.cc index 80229426412..cda10f027fb 100644 --- a/src/rgw/rgw_civetweb_frontend.cc +++ b/src/rgw/rgw_civetweb_frontend.cc @@ -23,10 +23,10 @@ int RGWCivetWebFrontend::process(struct mg_connection* const conn) RWLock::RLocker lock(env.mutex); RGWRequest req(env.store->get_new_req_id()); - auto real_client_io = rgw_restful_io_add_reordering( - rgw_restful_io_add_buffering( - rgw_restful_io_add_chunking( - rgw_restful_io_add_conlen_controlling( + auto real_client_io = rgw::io::add_reordering( + rgw::io::add_buffering( + rgw::io::add_chunking( + rgw::io::add_conlen_controlling( RGWCivetWeb(conn, env.port))))); RGWRestfulIO client_io(&real_client_io); diff --git a/src/rgw/rgw_client_io.cc b/src/rgw/rgw_client_io.cc index 9c572a96c76..a01a357e1bb 100644 --- a/src/rgw/rgw_client_io.cc +++ b/src/rgw/rgw_client_io.cc @@ -9,7 +9,10 @@ #define dout_subsys ceph_subsys_rgw -void RGWClientIO::init(CephContext *cct) { +namespace rgw { +namespace io { + +void BasicClient::init(CephContext *cct) { init_env(cct); if (cct->_conf->subsys.should_gather(ceph_subsys_rgw, 20)) { @@ -22,6 +25,8 @@ void RGWClientIO::init(CephContext *cct) { } } +} /* namespace io */ +} /* namespace rgw */ int RGWRestfulIO::recv_body(char *buf, size_t max, bool calculate_hash) { @@ -35,7 +40,7 @@ int RGWRestfulIO::recv_body(char *buf, size_t max, bool calculate_hash) calc_hash_sha256_update_stream(sha256_hash, buf, sent); } return sent; - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { return -e.code().value(); } } diff --git a/src/rgw/rgw_client_io.h b/src/rgw/rgw_client_io.h index 61de21dbcab..46e2da118b6 100644 --- a/src/rgw/rgw_client_io.h +++ b/src/rgw/rgw_client_io.h @@ -16,32 +16,35 @@ #include "include/types.h" #include "rgw_common.h" -class RGWClientIO { +namespace rgw { +namespace io { + +class BasicClient { protected: virtual void init_env(CephContext *cct) = 0; public: - virtual ~RGWClientIO() {} + virtual ~BasicClient() {} void init(CephContext *cct); virtual RGWEnv& get_env() noexcept = 0; virtual int complete_request() = 0; -}; /* RGWClient IO */ +}; /* rgw::io::Client */ -class RGWClientIOAccounter { +class Accounter { public: - virtual ~RGWClientIOAccounter() {} + virtual ~Accounter() {} virtual void set_account(bool enabled) = 0; virtual uint64_t get_bytes_sent() const = 0; virtual uint64_t get_bytes_received() const = 0; -}; +}; /* rgw::io::Accounter */ -class RGWRestfulIOEngine : public RGWClientIO { - template<typename T> friend class RGWDecoratedRestfulIO; +class RestfulClient : public BasicClient { + template<typename T> friend class DecoratedRestfulClient; public: typedef std::system_error Exception; @@ -84,15 +87,15 @@ public: }; -/* Abstract decorator over any implementation of RGWRestfulIOEngine. */ +/* Abstract decorator over any implementation of rgw::io::RestfulClient. */ template <typename DecorateeT> -class RGWDecoratedRestfulIO : public RGWRestfulIOEngine { - template<typename T> friend class RGWDecoratedRestfulIO; +class DecoratedRestfulClient : public RestfulClient { + template<typename T> friend class DecoratedRestfulClient; typedef typename std::remove_pointer<DecorateeT>::type DerefedDecorateeT; - static_assert(std::is_base_of<RGWRestfulIOEngine, DerefedDecorateeT>::value, - "DecorateeT must be a subclass of RGWRestfulIOEngine"); + static_assert(std::is_base_of<RestfulClient, DerefedDecorateeT>::value, + "DecorateeT must be a subclass of rgw::io::RestfulClient"); DecorateeT decoratee; @@ -120,7 +123,7 @@ protected: } public: - RGWDecoratedRestfulIO(DecorateeT&& decoratee) + DecoratedRestfulClient(DecorateeT&& decoratee) : decoratee(std::move(decoratee)) { } @@ -172,6 +175,9 @@ public: } }; +} /* namespace rgw */ +} /* namespace io */ + /* We're doing this nasty thing only because of extensive usage of templates * to implement the static decorator pattern. C++ templates de facto enforce @@ -182,23 +188,23 @@ public: /* RGWRestfulIO: high level interface to interact with RESTful clients. What - * differentiates it from RGWRestfulIOEngine is providing more specific APIs - * like RGWClientIOAccounter or the AWS Auth v4 stuff implemented by filters + * differentiates it from rgw::io::RestfulClient is providing more specific APIs + * like rgw::io::Accounter or the AWS Auth v4 stuff implemented by filters * while hiding the pipelined architecture from clients. * - * RGWClientIOAccounter came in as a part of RGWRestfulIOAccountingEngine. */ -class RGWRestfulIO : public RGWRestfulIOAccountingEngine<RGWRestfulIOEngine*> { + * rgw::io::Accounter came in as a part of rgw::io::AccountingFilter. */ +class RGWRestfulIO : public rgw::io::AccountingFilter<rgw::io::RestfulClient*> { SHA256 *sha256_hash; public: virtual ~RGWRestfulIO() {} - RGWRestfulIO(RGWRestfulIOEngine* engine) - : RGWRestfulIOAccountingEngine<RGWRestfulIOEngine*>(std::move(engine)), + RGWRestfulIO(rgw::io::RestfulClient* engine) + : AccountingFilter<rgw::io::RestfulClient*>(std::move(engine)), sha256_hash(nullptr) { } - using RGWDecoratedRestfulIO<RGWRestfulIOEngine*>::recv_body; + using DecoratedRestfulClient<RestfulClient*>::recv_body; virtual int recv_body(char* buf, size_t max, bool calculate_hash); std::string grab_aws4_sha256_hash(); }; /* RGWRestfulIO */ @@ -210,8 +216,8 @@ static inline RGWRestfulIO* RESTFUL_IO(struct req_state* s) { return static_cast<RGWRestfulIO*>(s->cio); } -static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) { - return dynamic_cast<RGWClientIOAccounter*>(s->cio); +static inline rgw::io::Accounter* ACCOUNTING_IO(struct req_state* s) { + return dynamic_cast<rgw::io::Accounter*>(s->cio); } diff --git a/src/rgw/rgw_client_io_decoimpl.h b/src/rgw/rgw_client_io_decoimpl.h index cfecacfc8df..5847c5b4c24 100644 --- a/src/rgw/rgw_client_io_decoimpl.h +++ b/src/rgw/rgw_client_io_decoimpl.h @@ -11,17 +11,20 @@ #include "rgw_common.h" #include "rgw_client_io.h" +namespace rgw { +namespace io { + template <typename T> -class RGWRestfulIOAccountingEngine : public RGWDecoratedRestfulIO<T>, - public RGWClientIOAccounter { +class AccountingFilter : public DecoratedRestfulClient<T>, + public Accounter { bool enabled; uint64_t total_sent; uint64_t total_received; public: template <typename U> - RGWRestfulIOAccountingEngine(U&& decoratee) - : RGWDecoratedRestfulIO<T>(std::move(decoratee)), + AccountingFilter(U&& decoratee) + : DecoratedRestfulClient<T>(std::move(decoratee)), enabled(false), total_sent(0), total_received(0) { @@ -29,7 +32,8 @@ public: size_t send_status(const int status, const char* const status_name) override { - const auto sent = RGWDecoratedRestfulIO<T>::send_status(status, status_name); + const auto sent = DecoratedRestfulClient<T>::send_status(status, + status_name); if (enabled) { total_sent += sent; } @@ -37,7 +41,7 @@ public: } size_t send_100_continue() override { - const auto sent = RGWDecoratedRestfulIO<T>::send_100_continue(); + const auto sent = DecoratedRestfulClient<T>::send_100_continue(); if (enabled) { total_sent += sent; } @@ -46,7 +50,7 @@ public: size_t send_header(const boost::string_ref& name, const boost::string_ref& value) override { - const auto sent = RGWDecoratedRestfulIO<T>::send_header(name, value); + const auto sent = DecoratedRestfulClient<T>::send_header(name, value); if (enabled) { total_sent += sent; } @@ -54,7 +58,7 @@ public: } size_t send_content_length(const uint64_t len) override { - const auto sent = RGWDecoratedRestfulIO<T>::send_content_length(len); + const auto sent = DecoratedRestfulClient<T>::send_content_length(len); if (enabled) { total_sent += sent; } @@ -62,7 +66,7 @@ public: } size_t send_chunked_transfer_encoding() override { - const auto sent = RGWDecoratedRestfulIO<T>::send_chunked_transfer_encoding(); + const auto sent = DecoratedRestfulClient<T>::send_chunked_transfer_encoding(); if (enabled) { total_sent += sent; } @@ -70,7 +74,7 @@ public: } size_t complete_header() override { - const auto sent = RGWDecoratedRestfulIO<T>::complete_header(); + const auto sent = DecoratedRestfulClient<T>::complete_header(); if (enabled) { total_sent += sent; } @@ -78,7 +82,7 @@ public: } size_t recv_body(char* buf, size_t max) override { - const auto received = RGWDecoratedRestfulIO<T>::recv_body(buf, max); + const auto received = DecoratedRestfulClient<T>::recv_body(buf, max); if (enabled) { total_received += received; } @@ -87,7 +91,7 @@ public: size_t send_body(const char* const buf, const size_t len) override { - const auto sent = RGWDecoratedRestfulIO<T>::send_body(buf, len); + const auto sent = DecoratedRestfulClient<T>::send_body(buf, len); if (enabled) { total_sent += sent; } @@ -111,8 +115,8 @@ public: /* Filter for in-memory buffering incoming data and calculating the content * length header if it isn't present. */ template <typename T> -class RGWRestfulIOBufferingEngine : public RGWDecoratedRestfulIO<T> { - template<typename Td> friend class RGWDecoratedRestfulIO; +class BufferingFilter : public DecoratedRestfulClient<T> { + template<typename Td> friend class DecoratedRestfulClient; protected: ceph::bufferlist data; @@ -121,8 +125,8 @@ protected: public: template <typename U> - RGWRestfulIOBufferingEngine(U&& decoratee) - : RGWDecoratedRestfulIO<T>(std::move(decoratee)), + BufferingFilter(U&& decoratee) + : DecoratedRestfulClient<T>(std::move(decoratee)), has_content_length(false), buffer_data(false) { } @@ -135,33 +139,33 @@ public: }; template <typename T> -size_t RGWRestfulIOBufferingEngine<T>::send_body(const char* const buf, - const size_t len) +size_t BufferingFilter<T>::send_body(const char* const buf, + const size_t len) { if (buffer_data) { data.append(buf, len); return 0; } - return RGWDecoratedRestfulIO<T>::send_body(buf, len); + return DecoratedRestfulClient<T>::send_body(buf, len); } template <typename T> -size_t RGWRestfulIOBufferingEngine<T>::send_content_length(const uint64_t len) +size_t BufferingFilter<T>::send_content_length(const uint64_t len) { has_content_length = true; - return RGWDecoratedRestfulIO<T>::send_content_length(len); + return DecoratedRestfulClient<T>::send_content_length(len); } template <typename T> -size_t RGWRestfulIOBufferingEngine<T>::send_chunked_transfer_encoding() +size_t BufferingFilter<T>::send_chunked_transfer_encoding() { has_content_length = true; - return RGWDecoratedRestfulIO<T>::send_chunked_transfer_encoding(); + return DecoratedRestfulClient<T>::send_chunked_transfer_encoding(); } template <typename T> -size_t RGWRestfulIOBufferingEngine<T>::complete_header() +size_t BufferingFilter<T>::complete_header() { if (! has_content_length) { /* We will dump everything in complete_request(). */ @@ -169,79 +173,80 @@ size_t RGWRestfulIOBufferingEngine<T>::complete_header() return 0; } - return RGWDecoratedRestfulIO<T>::complete_header(); + return DecoratedRestfulClient<T>::complete_header(); } template <typename T> -int RGWRestfulIOBufferingEngine<T>::complete_request() +int BufferingFilter<T>::complete_request() { size_t sent = 0; if (! has_content_length) { - sent += RGWDecoratedRestfulIO<T>::send_content_length(data.length()); - sent += RGWDecoratedRestfulIO<T>::complete_header(); + sent += DecoratedRestfulClient<T>::send_content_length(data.length()); + sent += DecoratedRestfulClient<T>::complete_header(); } if (buffer_data) { /* We are sending each buffer separately to avoid extra memory shuffling * that would occur on data.c_str() to provide a continuous memory area. */ for (const auto& ptr : data.buffers()) { - sent += RGWDecoratedRestfulIO<T>::send_body(ptr.c_str(), - ptr.length()); + sent += DecoratedRestfulClient<T>::send_body(ptr.c_str(), + ptr.length()); } data.clear(); buffer_data = false; } - return sent + RGWDecoratedRestfulIO<T>::complete_request(); + return sent + DecoratedRestfulClient<T>::complete_request(); } template <typename T> static inline -RGWRestfulIOBufferingEngine<T> rgw_restful_io_add_buffering(T&& t) { - return RGWRestfulIOBufferingEngine<T>(std::move(t)); +BufferingFilter<T> add_buffering(T&& t) { + return BufferingFilter<T>(std::move(t)); } template <typename T> -class RGWRestfulIOChunkingEngine : public RGWDecoratedRestfulIO<T> { - template<typename Td> friend class RGWDecoratedRestfulIO; +class ChunkingFilter : public DecoratedRestfulClient<T> { + template<typename Td> friend class DecoratedRestfulClient; protected: bool has_content_length; bool chunking_enabled; public: template <typename U> - RGWRestfulIOChunkingEngine(U&& decoratee) - : RGWDecoratedRestfulIO<T>(std::move(decoratee)), + ChunkingFilter(U&& decoratee) + : DecoratedRestfulClient<T>(std::move(decoratee)), has_content_length(false), chunking_enabled(false) { } size_t send_content_length(const uint64_t len) override { has_content_length = true; - return RGWDecoratedRestfulIO<T>::send_content_length(len); + return DecoratedRestfulClient<T>::send_content_length(len); } size_t send_chunked_transfer_encoding() override { has_content_length = false; chunking_enabled = true; - return RGWDecoratedRestfulIO<T>::send_header("Transfer-Encoding", "chunked"); + return DecoratedRestfulClient<T>::send_header("Transfer-Encoding", + "chunked"); } size_t send_body(const char* buf, const size_t len) override { if (! chunking_enabled) { - return RGWDecoratedRestfulIO<T>::send_body(buf, len); + return DecoratedRestfulClient<T>::send_body(buf, len); } else { static constexpr char HEADER_END[] = "\r\n"; char sizebuf[32]; const auto slen = snprintf(sizebuf, sizeof(buf), "%" PRIx64 "\r\n", len); size_t sent = 0; - sent += RGWDecoratedRestfulIO<T>::send_body(sizebuf, slen); - sent += RGWDecoratedRestfulIO<T>::send_body(buf, len); - sent += RGWDecoratedRestfulIO<T>::send_body(HEADER_END, - sizeof(HEADER_END) - 1); + sent += DecoratedRestfulClient<T>::send_body(sizebuf, slen); + sent += DecoratedRestfulClient<T>::send_body(buf, len); + sent += DecoratedRestfulClient<T>::send_body(HEADER_END, + sizeof(HEADER_END) - 1); return sent; } } @@ -251,17 +256,17 @@ public: if (chunking_enabled) { static constexpr char CHUNKED_RESP_END[] = "0\r\n\r\n"; - sent += RGWDecoratedRestfulIO<T>::send_body(CHUNKED_RESP_END, - sizeof(CHUNKED_RESP_END) - 1); + sent += DecoratedRestfulClient<T>::send_body(CHUNKED_RESP_END, + sizeof(CHUNKED_RESP_END) - 1); } - return sent + RGWDecoratedRestfulIO<T>::complete_request(); + return sent + DecoratedRestfulClient<T>::complete_request(); } }; template <typename T> static inline -RGWRestfulIOChunkingEngine<T> rgw_restful_io_add_chunking(T&& t) { - return RGWRestfulIOChunkingEngine<T>(std::move(t)); +ChunkingFilter<T> add_chunking(T&& t) { + return ChunkingFilter<T>(std::move(t)); } @@ -269,7 +274,7 @@ RGWRestfulIOChunkingEngine<T> rgw_restful_io_add_chunking(T&& t) { * header where RFC 7230 requests so. The cases worth our attention are 204 No * Content as well as 304 Not Modified. */ template <typename T> -class RGWRestfulIOConLenControllingEngine : public RGWDecoratedRestfulIO<T> { +class ConLenControllingFilter : public DecoratedRestfulClient<T> { protected: enum class ContentLengthAction { FORWARD, @@ -279,8 +284,8 @@ protected: public: template <typename U> - RGWRestfulIOConLenControllingEngine(U&& decoratee) - : RGWDecoratedRestfulIO<T>(std::move(decoratee)), + ConLenControllingFilter(U&& decoratee) + : DecoratedRestfulClient<T>(std::move(decoratee)), action(ContentLengthAction::UNKNOWN) { } @@ -292,13 +297,13 @@ public: action = ContentLengthAction::FORWARD; } - return RGWDecoratedRestfulIO<T>::send_status(status, status_name); + return DecoratedRestfulClient<T>::send_status(status, status_name); } size_t send_content_length(const uint64_t len) override { switch(action) { case ContentLengthAction::FORWARD: - return RGWDecoratedRestfulIO<T>::send_content_length(len); + return DecoratedRestfulClient<T>::send_content_length(len); case ContentLengthAction::INHIBIT: return 0; case ContentLengthAction::UNKNOWN: @@ -309,15 +314,15 @@ public: }; template <typename T> static inline -RGWRestfulIOConLenControllingEngine<T> rgw_restful_io_add_conlen_controlling(T&& t) { - return RGWRestfulIOConLenControllingEngine<T>(std::move(t)); +ConLenControllingFilter<T> add_conlen_controlling(T&& t) { + return ConLenControllingFilter<T>(std::move(t)); } /* Filter that rectifies the wrong behaviour of some clients of the RGWRestfulIO * interface. Should be removed after fixing those clients. */ template <typename T> -class RGWRestfulIOReorderingEngine : public RGWDecoratedRestfulIO<T> { +class ReorderingFilter : public DecoratedRestfulClient<T> { protected: enum class ReorderState { RGW_EARLY_HEADERS, /* Got headers sent before calling send_status. */ @@ -338,7 +343,7 @@ protected: value.to_string())); return 0; case ReorderState::RGW_DATA: - return RGWDecoratedRestfulIO<T>::send_header(name, value); + return DecoratedRestfulClient<T>::send_header(name, value); } return -EIO; @@ -346,8 +351,8 @@ protected: public: template <typename U> - RGWRestfulIOReorderingEngine(U&& decoratee) - : RGWDecoratedRestfulIO<T>(std::move(decoratee)), + ReorderingFilter(U&& decoratee) + : DecoratedRestfulClient<T>(std::move(decoratee)), phase(ReorderState::RGW_EARLY_HEADERS) { } @@ -355,7 +360,7 @@ public: const char* const status_name) override { phase = ReorderState::RGW_STATUS_SEEN; - return RGWDecoratedRestfulIO<T>::send_status(status, status_name); + return DecoratedRestfulClient<T>::send_status(status, status_name); } size_t send_content_length(const uint64_t len) override { @@ -364,7 +369,7 @@ public: content_length = len; return 0; } else { - return RGWDecoratedRestfulIO<T>::send_content_length(len); + return DecoratedRestfulClient<T>::send_content_length(len); } } @@ -376,22 +381,24 @@ public: /* Sent content length if necessary. */ if (content_length) { - sent += RGWDecoratedRestfulIO<T>::send_content_length(*content_length); + sent += DecoratedRestfulClient<T>::send_content_length(*content_length); } /* Header data in buffers are already counted. */ for (const auto& kv : headers) { - sent += RGWDecoratedRestfulIO<T>::send_header(kv.first, kv.second); + sent += DecoratedRestfulClient<T>::send_header(kv.first, kv.second); } headers.clear(); - return sent + RGWDecoratedRestfulIO<T>::complete_header(); + return sent + DecoratedRestfulClient<T>::complete_header(); } }; template <typename T> static inline -RGWRestfulIOReorderingEngine<T> rgw_restful_io_add_reordering(T&& t) { - return RGWRestfulIOReorderingEngine<T>(std::move(t)); +ReorderingFilter<T> add_reordering(T&& t) { + return ReorderingFilter<T>(std::move(t)); } +} /* namespace io */ +} /* namespace rgw */ #endif /* CEPH_RGW_CLIENT_IO_DECOIMPL_H */ diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 28e6396e0d7..1c486028fd5 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1131,7 +1131,11 @@ struct req_state; class RGWEnv; -class RGWClientIO; +namespace rgw { +namespace io { +class BasicClient; +} +} struct req_info { RGWEnv *env; @@ -1265,7 +1269,7 @@ class RGWRequest; /** Store all the state necessary to complete and respond to an HTTP request*/ struct req_state { CephContext *cct; - RGWClientIO *cio; + rgw::io::BasicClient *cio; RGWRequest *req; /// XXX: re-remove?? http_op op; RGWOpType op_type; diff --git a/src/rgw/rgw_fcgi.cc b/src/rgw/rgw_fcgi.cc index de090be4c6b..54e842d49f3 100644 --- a/src/rgw/rgw_fcgi.cc +++ b/src/rgw/rgw_fcgi.cc @@ -8,7 +8,7 @@ size_t RGWFCGX::write_data(const char* const buf, const size_t len) { const auto ret = FCGX_PutStr(buf, len, fcgx->out); if (ret < 0) { - throw RGWRestfulIOEngine::Exception(-ret, std::system_category()); + throw rgw::io::RestfulClient::Exception(-ret, std::system_category()); } return ret; } @@ -17,7 +17,7 @@ size_t RGWFCGX::read_data(char* const buf, const size_t len) { const auto ret = FCGX_GetStr(buf, len, fcgx->in); if (ret < 0) { - throw RGWRestfulIOEngine::Exception(-ret, std::system_category()); + throw rgw::io::RestfulClient::Exception(-ret, std::system_category()); } return ret; } diff --git a/src/rgw/rgw_fcgi.h b/src/rgw/rgw_fcgi.h index 2fb0582ab44..952bb0a8eb2 100644 --- a/src/rgw/rgw_fcgi.h +++ b/src/rgw/rgw_fcgi.h @@ -11,7 +11,7 @@ struct FCGX_Request; -class RGWFCGX : public RGWRestfulIOEngine +class RGWFCGX : public rgw::io::RestfulClient { FCGX_Request *fcgx; RGWEnv env; diff --git a/src/rgw/rgw_fcgi_process.cc b/src/rgw/rgw_fcgi_process.cc index 554cf2c64a8..0f70b561742 100644 --- a/src/rgw/rgw_fcgi_process.cc +++ b/src/rgw/rgw_fcgi_process.cc @@ -116,7 +116,7 @@ void RGWFCGXProcess::handle_request(RGWRequest* r) { RGWFCGXRequest* req = static_cast<RGWFCGXRequest*>(r); FCGX_Request* fcgx = req->fcgx; - auto real_client_io = rgw_restful_io_add_conlen_controlling( + auto real_client_io = rgw::io::add_conlen_controlling( RGWFCGX(fcgx)); RGWRestfulIO client_io(&real_client_io); diff --git a/src/rgw/rgw_lib.h b/src/rgw/rgw_lib.h index c10f66915c5..a730822308b 100644 --- a/src/rgw/rgw_lib.h +++ b/src/rgw/rgw_lib.h @@ -50,8 +50,8 @@ namespace rgw { /* request interface */ - class RGWLibIO : public RGWClientIO, - public RGWClientIOAccounter + class RGWLibIO : public rgw::io::BasicClient, + public rgw::io::Accounter { RGWUserInfo user_info; RGWEnv env; diff --git a/src/rgw/rgw_loadgen.h b/src/rgw/rgw_loadgen.h index 862fe270bc0..a5faf282309 100644 --- a/src/rgw/rgw_loadgen.h +++ b/src/rgw/rgw_loadgen.h @@ -32,7 +32,7 @@ struct RGWLoadGenRequestEnv { /* XXX does RGWLoadGenIO actually want to perform stream/HTTP I/O, * or (e.g) are these NOOPs? */ -class RGWLoadGenIO : public RGWRestfulIOEngine +class RGWLoadGenIO : public rgw::io::RestfulClient { uint64_t left_to_read; RGWLoadGenRequestEnv* req; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a6f22b2f9fc..17b5c905dae 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -5284,7 +5284,9 @@ RGWHandler::~RGWHandler() { } -int RGWHandler::init(RGWRados *_store, struct req_state *_s, RGWClientIO *cio) +int RGWHandler::init(RGWRados *_store, + struct req_state *_s, + rgw::io::BasicClient *cio) { store = _store; s = _s; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 442f530e4ae..f47edf417fc 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -1515,7 +1515,7 @@ public: RGWHandler() : store(NULL), s(NULL) {} virtual ~RGWHandler(); - virtual int init(RGWRados* store, struct req_state* _s, RGWClientIO* cio); + virtual int init(RGWRados* store, struct req_state* _s, rgw::io::BasicClient* cio); virtual int init_permissions(RGWOp *op) { return 0; diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 1ee068429cc..9e49eb072ac 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -281,7 +281,7 @@ static void dump_status(struct req_state *s, int status, s->formatter->set_status(status, status_name); try { RESTFUL_IO(s)->send_status(status, status_name); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_status() returned err=" << e.what() << dendl; } @@ -376,7 +376,7 @@ void dump_header(struct req_state* const s, { try { RESTFUL_IO(s)->send_header(name, val); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_header() returned err=" << e.what() << dendl; } @@ -415,7 +415,7 @@ void dump_content_length(struct req_state* const s, const uint64_t len) { try { RESTFUL_IO(s)->send_content_length(len); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_content_length() returned err=" << e.what() << dendl; } @@ -426,7 +426,7 @@ static void dump_chunked_encoding(struct req_state* const s) { try { RESTFUL_IO(s)->send_chunked_transfer_encoding(); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_chunked_transfer_encoding()" << " returned err=" << e.what() << dendl; } @@ -708,7 +708,7 @@ void end_header(struct req_state* s, RGWOp* op, const char *content_type, try { RESTFUL_IO(s)->complete_header(); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->complete_header() returned err=" << e.what() << dendl; } @@ -798,7 +798,7 @@ void dump_continue(struct req_state * const s) { try { RESTFUL_IO(s)->send_100_continue(); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_100_continue() returned err=" << e.what() << dendl; } @@ -834,7 +834,7 @@ int dump_body(struct req_state* const s, { try { return RESTFUL_IO(s)->send_body(buf, len); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { return -e.code().value(); } } @@ -855,7 +855,7 @@ int recv_body(struct req_state* const s, { try { return RESTFUL_IO(s)->recv_body(buf, max, s->aws4_auth_needs_complete); - } catch (RGWRestfulIOEngine::Exception& e) { + } catch (rgw::io::RestfulClient::Exception& e) { return -e.code().value(); } } @@ -1797,7 +1797,7 @@ static int64_t parse_content_length(const char *content_length) return len; } -int RGWREST::preprocess(struct req_state *s, RGWClientIO* cio) +int RGWREST::preprocess(struct req_state *s, rgw::io::BasicClient* cio) { req_info& info = s->info; diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index 95766eb3a9a..32c7fdbee40 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -477,7 +477,7 @@ class RGWRestfulIO; class RGWREST { RGWRESTMgr mgr; - static int preprocess(struct req_state *s, RGWClientIO *rio); + static int preprocess(struct req_state *s, rgw::io::BasicClient* rio); public: RGWREST() {} RGWHandler_REST *get_handler(RGWRados *store, diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index bf0f916138f..7f4f3c22d2c 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -3186,7 +3186,7 @@ int RGWHandler_REST_S3::postauth_init() } int RGWHandler_REST_S3::init(RGWRados *store, struct req_state *s, - RGWClientIO *cio) + rgw::io::BasicClient *cio) { int ret; @@ -4135,7 +4135,7 @@ int RGW_Auth_S3::authorize_v2(RGWRados *store, struct req_state *s) } int RGWHandler_Auth_S3::init(RGWRados *store, struct req_state *state, - RGWClientIO *cio) + rgw::io::BasicClient *cio) { int ret = RGWHandler_REST_S3::init_from_header(state, RGW_FORMAT_JSON, true); diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index c75cf4fdf53..6793f5fdaf7 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -470,7 +470,9 @@ public: static int validate_bucket_name(const string& bucket); static int validate_object_name(const string& bucket); - virtual int init(RGWRados *store, struct req_state *s, RGWClientIO *cio); + virtual int init(RGWRados *store, + struct req_state *s, + rgw::io::BasicClient *cio); virtual int authorize() { return RGW_Auth_S3::authorize(store, s); } @@ -485,7 +487,9 @@ public: RGWHandler_REST_S3() : RGWHandler_REST() {} virtual ~RGWHandler_REST_S3() {} - virtual int init(RGWRados *store, struct req_state *s, RGWClientIO *cio); + virtual int init(RGWRados *store, + struct req_state *s, + rgw::io::BasicClient *cio); virtual int authorize() { return RGW_Auth_S3::authorize(store, s); } diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 17bb13de593..64995b1fcc3 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -2347,7 +2347,7 @@ int RGWHandler_REST_SWIFT::init_from_header(struct req_state *s) } int RGWHandler_REST_SWIFT::init(RGWRados* store, struct req_state* s, - RGWClientIO *cio) + rgw::io::BasicClient *cio) { struct req_init_state *t = &s->init_state; diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index f318f9b0119..4cc68ef6a07 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -266,7 +266,7 @@ public: static int validate_bucket_name(const string& bucket); - int init(RGWRados *store, struct req_state *s, RGWClientIO *cio); + int init(RGWRados *store, struct req_state *s, rgw::io::BasicClient *cio); int authorize() override; int postauth_init() override; @@ -315,7 +315,7 @@ public: int init(RGWRados* const store, struct req_state* const s, - RGWClientIO* const cio) override { + rgw::io::BasicClient* const cio) override { website_handler = boost::in_place<RGWSwiftWebsiteHandler>(store, s, this); return RGWHandler_REST_SWIFT::init(store, s, cio); } @@ -353,7 +353,7 @@ public: int init(RGWRados* const store, struct req_state* const s, - RGWClientIO* const cio) override { + rgw::io::BasicClient* const cio) override { website_handler = boost::in_place<RGWSwiftWebsiteHandler>(store, s, this); return RGWHandler_REST_SWIFT::init(store, s, cio); } @@ -403,7 +403,7 @@ public: int init(RGWRados* const store, struct req_state* const state, - RGWClientIO* const cio) override { + rgw::io::BasicClient* const cio) override { state->dialect = "swift"; state->formatter = new JSONFormatter; state->format = RGW_FORMAT_JSON; @@ -456,7 +456,7 @@ public: int init(RGWRados* const store, struct req_state* const state, - RGWClientIO* const cio) override { + rgw::io::BasicClient* const cio) override { state->dialect = "swift"; state->formatter = new JSONFormatter; state->format = RGW_FORMAT_JSON; @@ -509,7 +509,7 @@ public: int init(RGWRados* const store, struct req_state* const state, - RGWClientIO* const cio) override { + rgw::io::BasicClient* const cio) override { state->dialect = "swift"; state->formatter = new JSONFormatter; state->format = RGW_FORMAT_JSON; diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index cbd5c8f35a1..b8efaf1adc4 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -611,7 +611,7 @@ done: } int RGWHandler_SWIFT_Auth::init(RGWRados *store, struct req_state *state, - RGWClientIO *cio) + rgw::io::BasicClient *cio) { state->dialect = "swift-auth"; state->formatter = new JSONFormatter; diff --git a/src/rgw/rgw_swift_auth.h b/src/rgw/rgw_swift_auth.h index 0f559fddf9a..c4c7d0a076e 100644 --- a/src/rgw/rgw_swift_auth.h +++ b/src/rgw/rgw_swift_auth.h @@ -140,7 +140,7 @@ public: ~RGWHandler_SWIFT_Auth() {} RGWOp *op_get(); - int init(RGWRados *store, struct req_state *state, RGWClientIO *cio); + int init(RGWRados *store, struct req_state *state, rgw::io::BasicClient *cio); int authorize(); int postauth_init() { return 0; } int read_permissions(RGWOp *op) { return 0; } |