You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/06/09 01:33:41 UTC

[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #2819: [KYUUBI #2820][SUB-TASK][KPIP-4] Support to redirect getLocalLog and closeBatchSession requests across kyuubi instances

ulysses-you commented on code in PR #2819:
URL: https://github.com/apache/incubator-kyuubi/pull/2819#discussion_r892994611


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala:
##########
@@ -204,14 +231,64 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
         throw new NotAllowedException(t.getMessage)
     }
 
-    if (!session.user.equals(userName)) {
-      throw new NotAllowedException(
-        s"$userName is not allowed to close the session belong to ${session.user}")
+    Option(sessionManager.getBatchSessionImpl(sessionHandle)).map { batchSession =>
+      if (userName != batchSession.user) {
+        throw new NotAllowedException(
+          s"$userName is not allowed to close the session belong to ${batchSession.user}")
+      }
+      sessionManager.closeSession(batchSession.handle)
+      val (success, msg) = batchSession.batchJobSubmissionOp.getKillMessage
+      new CloseBatchResponse(success, msg)
+    }.getOrElse {
+      Option(sessionManager.getBatchSessionMetadata(batchId)).map { metadata =>
+        if (userName != metadata.username) {
+          throw new NotAllowedException(
+            s"$userName is not allowed to close the session belong to ${metadata.username}")
+        } else if (OperationState.isTerminal(OperationState.withName(metadata.state)) ||
+          metadata.kyuubiInstance == fe.connectionUrl) {
+          new CloseBatchResponse(false, s"The batch[$metadata] has been terminated.")
+        } else {
+          info(s"Redirecting delete batch[$batchId] to ${metadata.kyuubiInstance}")
+          val internalRestClient = getInternalRestClient(metadata.kyuubiInstance)
+          var closeBatchResponse: CloseBatchResponse = new CloseBatchResponse(false, "")
+          var closeCompletion: Boolean = false
+          try {
+            var retryCount = 0

Review Comment:
   let's revert this part code in this pr, also the related config.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org