]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: promote policy related method to Messenger
authorYingxin Cheng <yingxincheng@gmail.com>
Sun, 3 Feb 2019 12:52:51 +0000 (20:52 +0800)
committerYingxin Cheng <yingxincheng@gmail.com>
Tue, 12 Feb 2019 08:48:03 +0000 (16:48 +0800)
Signed-off-by: Yingxin Cheng <yingxincheng@gmail.com>
src/crimson/net/Messenger.h
src/crimson/net/SocketMessenger.h

index e9e0de3539cfdaf02468b13a7a14b68a235d53f5..9d766cb061e4f74505b3a68063294abfd03cbd69 100644 (file)
 #include <seastar/core/future.hh>
 
 #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<Throttle>;
+
 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<Messenger*>
   create(const entity_name_t& name,
          const std::string& lname,
index 2a769ce69c5e3014df67eaa75af6618fdfc7111f..535dea3a1403ea8cbf1bd2f0f2d5e0c2264815ae 100644 (file)
 #include <seastar/core/reactor.hh>
 #include <seastar/core/sharded.hh>
 
-#include "msg/Policy.h"
 #include "Messenger.h"
 #include "SocketConnection.h"
-#include "crimson/thread/Throttle.h"
 
 namespace ceph::net {
 
-using SocketPolicy = ceph::net::Policy<ceph::thread::Throttle>;
-
 class SocketMessenger final : public Messenger, public seastar::peering_sharded_service<SocketMessenger> {
   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<entity_addr_t, SocketConnectionRef> connections;
   std::set<SocketConnectionRef> accepting_conns;
-  using Throttle = ceph::thread::Throttle;
   ceph::net::PolicySet<Throttle> 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);