This is an automated email from the ASF dual-hosted git repository.

zhouky pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git


The following commit(s) were added to refs/heads/main by this push:
     new 11fe324a0 [CELEBORN-1093] Improve setup endpoint
11fe324a0 is described below

commit 11fe324a08383bbc2c5eb8ba4ad6573c1e4c9c11
Author: onebox-li <[email protected]>
AuthorDate: Tue Oct 31 21:39:59 2023 +0800

    [CELEBORN-1093] Improve setup endpoint
    
    ### What changes were proposed in this pull request?
    Avoid transform RpcEndpointAddress -> celebornUrl -> RpcEndpointAddress 
when setupEndpointRef.
    
    ### Why are the changes needed?
    Ditto
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Cluster test.
    
    Closes #2049 from onebox-li/improve-setup-endpoint.
    
    Authored-by: onebox-li <[email protected]>
    Signed-off-by: zky.zhoukeyong <[email protected]>
---
 .../main/scala/org/apache/celeborn/common/rpc/RpcEnv.scala   | 12 ++++++------
 .../org/apache/celeborn/common/rpc/netty/NettyRpcEnv.scala   | 10 ++++------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/common/src/main/scala/org/apache/celeborn/common/rpc/RpcEnv.scala 
b/common/src/main/scala/org/apache/celeborn/common/rpc/RpcEnv.scala
index 673724304..4d3d6d0d2 100644
--- a/common/src/main/scala/org/apache/celeborn/common/rpc/RpcEnv.scala
+++ b/common/src/main/scala/org/apache/celeborn/common/rpc/RpcEnv.scala
@@ -81,15 +81,15 @@ abstract class RpcEnv(conf: CelebornConf) {
   def setupEndpoint(name: String, endpoint: RpcEndpoint): RpcEndpointRef
 
   /**
-   * Retrieve the [[RpcEndpointRef]] represented by `uri` asynchronously.
+   * Retrieve the [[RpcEndpointRef]] represented by `addr` asynchronously.
    */
-  def asyncSetupEndpointRefByURI(uri: String): Future[RpcEndpointRef]
+  def asyncSetupEndpointRefByAddr(addr: RpcEndpointAddress): 
Future[RpcEndpointRef]
 
   /**
-   * Retrieve the [[RpcEndpointRef]] represented by `uri`. This is a blocking 
action.
+   * Retrieve the [[RpcEndpointRef]] represented by `addr`. This is a blocking 
action.
    */
-  def setupEndpointRefByURI(uri: String): RpcEndpointRef = {
-    defaultLookupTimeout.awaitResult(asyncSetupEndpointRefByURI(uri))
+  def setupEndpointRefByAddr(addr: RpcEndpointAddress): RpcEndpointRef = {
+    defaultLookupTimeout.awaitResult(asyncSetupEndpointRefByAddr(addr))
   }
 
   /**
@@ -97,7 +97,7 @@ abstract class RpcEnv(conf: CelebornConf) {
    * This is a blocking action.
    */
   def setupEndpointRef(address: RpcAddress, endpointName: String): 
RpcEndpointRef = {
-    setupEndpointRefByURI(RpcEndpointAddress(address, endpointName).toString)
+    setupEndpointRefByAddr(RpcEndpointAddress(address, endpointName))
   }
 
   /**
diff --git 
a/common/src/main/scala/org/apache/celeborn/common/rpc/netty/NettyRpcEnv.scala 
b/common/src/main/scala/org/apache/celeborn/common/rpc/netty/NettyRpcEnv.scala
index 6d0eb2bf6..31809e366 100644
--- 
a/common/src/main/scala/org/apache/celeborn/common/rpc/netty/NettyRpcEnv.scala
+++ 
b/common/src/main/scala/org/apache/celeborn/common/rpc/netty/NettyRpcEnv.scala
@@ -119,18 +119,16 @@ class NettyRpcEnv(
     }
   }
 
-  def asyncSetupEndpointRefByURI(uri: String): Future[RpcEndpointRef] = {
-    val addr = RpcEndpointAddress(uri)
-    val endpointRef = new NettyRpcEndpointRef(conf, addr, this)
+  def asyncSetupEndpointRefByAddr(addr: RpcEndpointAddress): 
Future[RpcEndpointRef] = {
     val verifier = new NettyRpcEndpointRef(
       conf,
       RpcEndpointAddress(addr.rpcAddress, RpcEndpointVerifier.NAME),
       this)
-    
verifier.ask[Boolean](RpcEndpointVerifier.CheckExistence(endpointRef.name)).flatMap
 { find =>
+    
verifier.ask[Boolean](RpcEndpointVerifier.CheckExistence(addr.name)).flatMap { 
find =>
       if (find) {
-        Future.successful(endpointRef)
+        Future.successful(new NettyRpcEndpointRef(conf, addr, this))
       } else {
-        Future.failed(new RpcEndpointNotFoundException(uri))
+        Future.failed(new RpcEndpointNotFoundException(addr.toString))
       }
     }(ThreadUtils.sameThread)
   }

Reply via email to