From f2397748500bf64eceeab455093c0efdc9fdbcaa Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Sun, 3 Feb 2019 20:52:51 +0800 Subject: [PATCH] crimson/net: promote policy related method to Messenger Signed-off-by: Yingxin Cheng --- src/crimson/net/Messenger.h | 11 +++++++++++ src/crimson/net/SocketMessenger.h | 14 ++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/crimson/net/Messenger.h b/src/crimson/net/Messenger.h index e9e0de3539c..9d766cb061e 100644 --- a/src/crimson/net/Messenger.h +++ b/src/crimson/net/Messenger.h @@ -17,11 +17,16 @@ #include #include "Fwd.h" +#include "crimson/thread/Throttle.h" +#include "msg/Policy.h" class AuthAuthorizer; namespace ceph::net { +using Throttle = ceph::thread::Throttle; +using SocketPolicy = ceph::net::Policy; + class Messenger { entity_name_t my_name; entity_addrvec_t my_addrs; @@ -89,6 +94,12 @@ class Messenger { virtual void print(ostream& out) const = 0; + virtual void set_default_policy(const SocketPolicy& p) = 0; + + virtual void set_policy(entity_type_t peer_type, const SocketPolicy& p) = 0; + + virtual void set_policy_throttler(entity_type_t peer_type, Throttle* throttle) = 0; + static seastar::future create(const entity_name_t& name, const std::string& lname, diff --git a/src/crimson/net/SocketMessenger.h b/src/crimson/net/SocketMessenger.h index 2a769ce69c5..535dea3a140 100644 --- a/src/crimson/net/SocketMessenger.h +++ b/src/crimson/net/SocketMessenger.h @@ -21,15 +21,11 @@ #include #include -#include "msg/Policy.h" #include "Messenger.h" #include "SocketConnection.h" -#include "crimson/thread/Throttle.h" namespace ceph::net { -using SocketPolicy = ceph::net::Policy; - class SocketMessenger final : public Messenger, public seastar::peering_sharded_service { const int master_sid; const seastar::shard_id sid; @@ -39,7 +35,6 @@ class SocketMessenger final : public Messenger, public seastar::peering_sharded_ Dispatcher *dispatcher = nullptr; std::map connections; std::set accepting_conns; - using Throttle = ceph::thread::Throttle; ceph::net::PolicySet policy_set; // Distinguish messengers with meaningful names for debugging const std::string logic_name; @@ -96,11 +91,14 @@ class SocketMessenger final : public Messenger, public seastar::peering_sharded_ << ") " << get_myaddr(); } + void set_default_policy(const SocketPolicy& p) override; + + void set_policy(entity_type_t peer_type, const SocketPolicy& p) override; + + void set_policy_throttler(entity_type_t peer_type, Throttle* throttle) override; + public: seastar::future<> learned_addr(const entity_addr_t &peer_addr_for_me); - void set_default_policy(const SocketPolicy& p); - void set_policy(entity_type_t peer_type, const SocketPolicy& p); - void set_policy_throttler(entity_type_t peer_type, Throttle* throttle); SocketConnectionRef lookup_conn(const entity_addr_t& addr); void accept_conn(SocketConnectionRef); -- 2.39.5