turboFei commented on code in PR #7037:
URL: https://github.com/apache/kyuubi/pull/7037#discussion_r2054540843


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala:
##########
@@ -561,6 +561,58 @@ private[v1] class BatchesResource extends 
ApiRequestContext with Logging {
     }
   }
 
+  @ApiResponse(
+    responseCode = "200",
+    content = Array(new Content(
+      mediaType = MediaType.APPLICATION_JSON,
+      schema = new Schema(implementation = classOf[ReassignBatchResponse]))),
+    description = "Reassign instance's all batch sessions to a new instance")
+  @GET
+  @Path("{kyuubiInstance}/{batchId}/reassign")
+  def reassignBatchSessions(
+      @PathParam("kyuubiInstance") kyuubiInstance: String,
+      @PathParam("batchId") batchId: String,
+      @QueryParam("force")
+      @DefaultValue("false") force: Boolean): ReassignBatchResponse = {
+    sessionManager.getBatchMetadata(batchId).map { metadata =>
+      val batchInstance = metadata.kyuubiInstance
+      if (batchInstance != kyuubiInstance) {
+        throw new IllegalStateException(s":parameter $kyuubiInstance needs to 
match $batchInstance")
+      }
+      val url = fe.connectionUrl
+      if (kyuubiInstance == url) {
+        throw new IllegalStateException(s"KyuubiInstance is alive: 
$kyuubiInstance")
+      }
+      if (!force && checkInstanceNetwork(kyuubiInstance, batchId)) {
+        throw new IllegalStateException(s"KyuubiInstance is alive: 
$kyuubiInstance," +
+          s"please use force option to bypass this check")
+      }
+      try {
+        sessionManager.reassignBatchSessions(kyuubiInstance, fe.connectionUrl)

Review Comment:
   the logical is not correct,
   
   you check the `batch` exists and then try to reassign all the batches on the 
instance. 
   
   It is not align.



-- 
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-unsubscr...@kyuubi.apache.org

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


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

Reply via email to