]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/Messenger: make connect_to() key method, get_connection() becomes wrapper
authorSage Weil <sage@redhat.com>
Mon, 30 Jul 2018 20:52:04 +0000 (15:52 -0500)
committerSage Weil <sage@redhat.com>
Mon, 30 Jul 2018 20:59:50 +0000 (15:59 -0500)
We'll phase out get_connection() wrappers.

Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/Messenger.h
src/msg/async/AsyncMessenger.cc
src/msg/async/AsyncMessenger.h
src/msg/simple/SimpleMessenger.cc
src/msg/simple/SimpleMessenger.h
src/msg/xio/XioMessenger.h

index b393fae3a1179817a37cb40ee35d70ed3328ea8a..931fca8b2697fd9847605decffeba82eb2dc91dc 100644 (file)
@@ -484,14 +484,14 @@ public:
    *
    * @param dest The entity to get a connection for.
    */
-  virtual ConnectionRef get_connection(const entity_inst_t& dest) = 0;
-
-  virtual ConnectionRef connect_to(
-    int type, const entity_addrvec_t& dest) {
+  virtual ConnectionRef get_connection(const entity_inst_t& dest) {
     // temporary
-    return get_connection(entity_inst_t(entity_name_t(type, -1),
-                                       dest.legacy_addr()));
+    return connect_to(dest.name.type(),
+                     entity_addrvec_t(dest.addr));
   }
+
+  virtual ConnectionRef connect_to(
+    int type, const entity_addrvec_t& dest) = 0;
   ConnectionRef connect_to_mon(const entity_addrvec_t& dest) {
     return connect_to(CEPH_ENTITY_TYPE_MON, dest);
   }
index 48922b9c48957038d01c4361244e0272f70eb80f..3b90886191765e0fe9e15da93b3e0c715d6c3a2e 100644 (file)
@@ -581,20 +581,20 @@ AsyncConnectionRef AsyncMessenger::create_connect(
   return conn;
 }
 
-ConnectionRef AsyncMessenger::get_connection(const entity_inst_t& dest)
+ConnectionRef AsyncMessenger::connect_to(int type, const entity_addrvec_t& addrs)
 {
   Mutex::Locker l(lock);
-  if (my_addrs->legacy_addr() == dest.addr) {
+  if (*my_addrs == addrs) {
     // local
     return local_connection;
   }
 
-  AsyncConnectionRef conn = _lookup_conn(entity_addrvec_t(dest.addr));
+  AsyncConnectionRef conn = _lookup_conn(addrs);
   if (conn) {
-    ldout(cct, 10) << __func__ << " " << dest << " existing " << conn << dendl;
+    ldout(cct, 10) << __func__ << " " << addrs << " existing " << conn << dendl;
   } else {
-    conn = create_connect(entity_addrvec_t(dest.addr), dest.name.type());
-    ldout(cct, 10) << __func__ << " " << dest << " new " << conn << dendl;
+    conn = create_connect(addrs, type);
+    ldout(cct, 10) << __func__ << " " << addrs << " new " << conn << dendl;
   }
 
   return conn;
index 2af8875bd2c740a2e38848f089fc529f50fa6a63..86a952ac126f30a17716ecf94ef93aee82f521ce 100644 (file)
@@ -149,7 +149,8 @@ public:
    * @defgroup Connection Management
    * @{
    */
-  ConnectionRef get_connection(const entity_inst_t& dest) override;
+  ConnectionRef connect_to(int type,
+                          const entity_addrvec_t& addrs) override;
   ConnectionRef get_loopback_connection() override;
   void mark_down(const entity_addr_t& addr) override {
     mark_down_addrs(entity_addrvec_t(addr));
index 2d79a9e06dfd04514771b8f62ce3bcb6ec201929..5bd397c4d300a5a9f1e28e44c027292624b6c6aa 100644 (file)
@@ -440,22 +440,23 @@ bool SimpleMessenger::verify_authorizer(Connection *con, int peer_type,
                                      challenge);
 }
 
-ConnectionRef SimpleMessenger::get_connection(const entity_inst_t& dest)
+ConnectionRef SimpleMessenger::connect_to(int type,
+                                         const entity_addrvec_t& addrs)
 {
   Mutex::Locker l(lock);
-  if (my_addr == dest.addr) {
+  if (my_addr == addrs.front()) {
     // local
     return local_connection;
   }
 
   // remote
   while (true) {
-    Pipe *pipe = _lookup_pipe(dest.addr);
+    Pipe *pipe = _lookup_pipe(addrs.front());
     if (pipe) {
-      ldout(cct, 10) << "get_connection " << dest << " existing " << pipe << dendl;
+      ldout(cct, 10) << "get_connection " << addrs << " existing " << pipe << dendl;
     } else {
-      pipe = connect_rank(dest.addr, dest.name.type(), NULL, NULL);
-      ldout(cct, 10) << "get_connection " << dest << " new " << pipe << dendl;
+      pipe = connect_rank(addrs.front(), type, NULL, NULL);
+      ldout(cct, 10) << "get_connection " << addrs << " new " << pipe << dendl;
     }
     Mutex::Locker l(pipe->pipe_lock);
     if (pipe->connection_state)
index 1a56bde09a29d6ce1c3f3cebb77d562d183d788d..3c5e850c91aef48411ccb9435ba6450e181d201b 100644 (file)
@@ -149,7 +149,7 @@ public:
    * @defgroup Connection Management
    * @{
    */
-  ConnectionRef get_connection(const entity_inst_t& dest) override;
+  ConnectionRef connect_to(int type, const entity_addrvec_t& addrs) override;
   ConnectionRef get_loopback_connection() override;
   int send_keepalive(Connection *con);
   void mark_down(const entity_addr_t& addr) override;
index a075708101872cda36cf4658143753069dc31641..6f8a67baf212b1f1f8554d9aa8a20c33e55b68dd 100644 (file)
@@ -134,6 +134,13 @@ public:
 
   virtual ConnectionRef get_connection(const entity_inst_t& dest);
 
+  // compat hack
+  ConnectionRef connect_to(
+    int type, const entity_addrvec_t& dest) override {
+    return get_connection(entity_inst_t(entity_name_t(type, -1),
+                                       dest.legacy_addr()));
+  }
+
   virtual ConnectionRef get_loopback_connection();
 
   void unregister_xcon(XioConnection *xcon);