You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/11/29 14:13:58 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #3876] Return kyuubi instance when opening interactive session via SessionsResource

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

feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new a30fdde08 [KYUUBI #3876] Return kyuubi instance when opening interactive session via SessionsResource
a30fdde08 is described below

commit a30fdde08d29d06a22536f5b4186e4a6dd499d7a
Author: fwang12 <fw...@ebay.com>
AuthorDate: Tue Nov 29 22:13:48 2022 +0800

    [KYUUBI #3876] Return kyuubi instance when opening interactive session via SessionsResource
    
    ### _Why are the changes needed?_
    
    Because we do not support multiple node HA now for SessionsResource.
    It is difficult to use if load balancer is used for kyuubi gateway.
    In this pr, we return the actual kyuubi instance so that user can call the instance directly for follow operations.
    It should be a temporary workaround to support multiple kyuubi instances use case.
    ### _How was this patch tested?_
    - [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #3876 from turboFei/session_instance.
    
    Closes #3876
    
    b123effb [fwang12] Return kyuubi instance when opening interactive session via SessionsResource
    
    Authored-by: fwang12 <fw...@ebay.com>
    Signed-off-by: fwang12 <fw...@ebay.com>
---
 .../org/apache/kyuubi/client/api/v1/dto/SessionHandle.java   | 12 +++++++++++-
 .../org/apache/kyuubi/server/api/v1/SessionsResource.scala   |  2 +-
 .../kyuubi/operation/KyuubiRestAuthenticationSuite.scala     |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java
index e44ff0f16..7695cb39d 100644
--- a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java
@@ -24,11 +24,13 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 
 public class SessionHandle {
   private UUID identifier;
+  private String kyuubiInstance;
 
   public SessionHandle() {}
 
-  public SessionHandle(UUID identifier) {
+  public SessionHandle(UUID identifier, String kyuubiInstance) {
     this.identifier = identifier;
+    this.kyuubiInstance = kyuubiInstance;
   }
 
   public UUID getIdentifier() {
@@ -39,6 +41,14 @@ public class SessionHandle {
     this.identifier = identifier;
   }
 
+  public String getKyuubiInstance() {
+    return kyuubiInstance;
+  }
+
+  public void setKyuubiInstance(String kyuubiInstance) {
+    this.kyuubiInstance = kyuubiInstance;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
index 74e8dc274..17e23c58d 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
@@ -153,7 +153,7 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
         KYUUBI_SERVER_IP_KEY -> fe.host,
         KYUUBI_SESSION_CONNECTION_URL_KEY -> fe.connectionUrl,
         KYUUBI_SESSION_REAL_USER_KEY -> fe.getRealUser())).toMap)
-    new dto.SessionHandle(handle.identifier)
+    new dto.SessionHandle(handle.identifier, fe.connectionUrl)
   }
 
   @ApiResponse(
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala
index 858aac00e..a46c52572 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala
@@ -145,6 +145,7 @@ class KyuubiRestAuthenticationSuite extends RestClientTestHelper {
 
     assert(HttpServletResponse.SC_OK == response.getStatus)
     val sessionHandle = response.readEntity(classOf[SessionHandle])
+    assert(sessionHandle.getKyuubiInstance === fe.connectionUrl)
     val session = server.backendService.sessionManager.getSession(
       org.apache.kyuubi.session.SessionHandle.fromUUID(sessionHandle.getIdentifier.toString))
       .asInstanceOf[KyuubiSession]