From 0158c84c8361ffcfe5031be17afbd1c9842c950e Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Thu, 18 Jun 2020 15:24:14 +0200 Subject: [PATCH] crimson: move Throttle to src/crimson/common. Signed-off-by: Radoslaw Zarzynski --- src/crimson/CMakeLists.txt | 6 ++---- src/crimson/{thread/Throttle.cc => common/throttle.cc} | 6 +++--- src/crimson/{thread/Throttle.h => common/throttle.h} | 4 ++-- src/crimson/net/Messenger.h | 4 ++-- src/crimson/net/SocketConnection.h | 4 ++-- src/test/crimson/test_alien_echo.cc | 6 +++--- 6 files changed, 14 insertions(+), 16 deletions(-) rename src/crimson/{thread/Throttle.cc => common/throttle.cc} (91%) rename src/crimson/{thread/Throttle.h => common/throttle.h} (94%) diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index f11718fdeb2..e5b4da69888 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -19,7 +19,8 @@ set(crimson_common_srcs common/config_proxy.cc common/formatter.cc common/perf_counters_collection.cc - common/log.cc) + common/log.cc + common/throttle.cc) # the specialized version of ceph-common, where # - the logging is sent to Seastar backend @@ -166,14 +167,11 @@ set(crimson_net_srcs net/ProtocolV1.cc net/ProtocolV2.cc net/chained_dispatchers.cc) -set(crimson_thread_srcs - thread/Throttle.cc) add_library(crimson STATIC ${crimson_auth_srcs} ${crimson_mgr_srcs} ${crimson_mon_srcs} ${crimson_net_srcs} - ${crimson_thread_srcs} ${CMAKE_SOURCE_DIR}/src/common/buffer_seastar.cc) target_compile_options(crimson PUBLIC "-ftemplate-backtrace-limit=0") diff --git a/src/crimson/thread/Throttle.cc b/src/crimson/common/throttle.cc similarity index 91% rename from src/crimson/thread/Throttle.cc rename to src/crimson/common/throttle.cc index 99be02fa658..4ddf77dee22 100644 --- a/src/crimson/thread/Throttle.cc +++ b/src/crimson/common/throttle.cc @@ -1,6 +1,6 @@ -#include "Throttle.h" +#include "throttle.h" -namespace crimson::thread { +namespace crimson::common { int64_t Throttle::take(int64_t c) { @@ -56,4 +56,4 @@ bool Throttle::_should_wait(size_t c) const { (c >= max && count > max)); // except for large c } -} // namespace crimson::thread +} // namespace crimson::common diff --git a/src/crimson/thread/Throttle.h b/src/crimson/common/throttle.h similarity index 94% rename from src/crimson/thread/Throttle.h rename to src/crimson/common/throttle.h index 117924b2e94..fea471c8d61 100644 --- a/src/crimson/thread/Throttle.h +++ b/src/crimson/common/throttle.h @@ -10,7 +10,7 @@ #include "common/ThrottleInterface.h" -namespace crimson::thread { +namespace crimson::common { class Throttle final : public ThrottleInterface { size_t max = 0; @@ -36,4 +36,4 @@ private: bool _should_wait(size_t c) const; }; -} // namespace crimson::thread +} // namespace crimson::common diff --git a/src/crimson/net/Messenger.h b/src/crimson/net/Messenger.h index 2b136aa4fe0..7065d2ad2af 100644 --- a/src/crimson/net/Messenger.h +++ b/src/crimson/net/Messenger.h @@ -17,8 +17,8 @@ #include #include "Fwd.h" +#include "crimson/common/throttle.h" #include "crimson/net/chained_dispatchers.h" -#include "crimson/thread/Throttle.h" #include "msg/Message.h" #include "msg/Policy.h" @@ -35,7 +35,7 @@ namespace crimson::net { class Interceptor; #endif -using Throttle = crimson::thread::Throttle; +using Throttle = crimson::common::Throttle; using SocketPolicy = ceph::net::Policy; class Messenger { diff --git a/src/crimson/net/SocketConnection.h b/src/crimson/net/SocketConnection.h index 67657a6e190..0af08e0e4f2 100644 --- a/src/crimson/net/SocketConnection.h +++ b/src/crimson/net/SocketConnection.h @@ -17,10 +17,10 @@ #include #include "msg/Policy.h" +#include "crimson/common/throttle.h" #include "crimson/net/chained_dispatchers.h" #include "crimson/net/Connection.h" #include "crimson/net/Socket.h" -#include "crimson/thread/Throttle.h" namespace crimson::net { @@ -34,7 +34,7 @@ class SocketConnection : public Connection { SocketMessenger& messenger; std::unique_ptr protocol; - ceph::net::Policy policy; + ceph::net::Policy policy; /// the seq num of the last transmitted message seq_num_t out_seq = 0; diff --git a/src/test/crimson/test_alien_echo.cc b/src/test/crimson/test_alien_echo.cc index 0a0f22eb9ae..b5710adcbea 100644 --- a/src/test/crimson/test_alien_echo.cc +++ b/src/test/crimson/test_alien_echo.cc @@ -4,10 +4,10 @@ #include "messages/MPing.h" #include "common/ceph_argparse.h" #include "crimson/auth/DummyAuth.h" +#include "crimson/common/throttle.h" #include "crimson/net/Connection.h" #include "crimson/net/Dispatcher.h" #include "crimson/net/Messenger.h" -#include "crimson/thread/Throttle.h" #include #include @@ -38,7 +38,7 @@ struct DummyAuthAuthorizer : public AuthAuthorizer { }; struct Server { - crimson::thread::Throttle byte_throttler; + crimson::common::Throttle byte_throttler; crimson::net::MessengerRef msgr; crimson::auth::DummyAuthClientServer dummy_auth; struct ServerDispatcher : crimson::net::Dispatcher { @@ -64,7 +64,7 @@ struct Server { }; struct Client { - crimson::thread::Throttle byte_throttler; + crimson::common::Throttle byte_throttler; crimson::net::MessengerRef msgr; crimson::auth::DummyAuthClientServer dummy_auth; struct ClientDispatcher : crimson::net::Dispatcher { -- 2.39.5