yaooqinn commented on a change in pull request #1445:
URL: https://github.com/apache/incubator-kyuubi/pull/1445#discussion_r761835649



##########
File path: 
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
##########
@@ -322,7 +322,77 @@ private[v1] class SessionsResource extends 
ApiRequestContext {
     }
   }
 
-  def getSessionHandle(sessionHandleStr: String): SessionHandle = {
+  @ApiResponse(
+    responseCode = "200",
+    content = Array(new Content(
+      mediaType = MediaType.APPLICATION_JSON)),
+    description = "Close an operation")
+  @DELETE
+  @Path("{sessionHandle}/operations/{operationHandle}")
+  def closeOperation(
+      @PathParam("sessionHandle") sessionHandleStr: String,
+      @PathParam("operationHandle") operationHandleStr: String): 
OperationHandle = {
+    val sessionHandle = parseSessionHandle(sessionHandleStr)
+    val operationHandle = parseOperationHandle(operationHandleStr)
+    try {
+      
backendService.sessionManager.getSession(sessionHandle).closeOperation(operationHandle)
+      operationHandle
+    } catch {
+      case NonFatal(_) =>
+        throw new NotFoundException(s"Error closing an operation")
+    }
+  }
+
+  @ApiResponse(
+    responseCode = "200",
+    content = Array(new Content(
+      mediaType = MediaType.APPLICATION_JSON)),
+    description =
+      "Get an operation detail with a given session identifier and operation 
identifier")
+  @GET
+  @Path("{sessionHandle}/operations/{operationHandle}")
+  def getOperationHandle(
+      @PathParam("sessionHandle") sessionHandleStr: String,
+      @PathParam("operationHandle") operationHandleStr: String): 
OperationDetail = {
+    val operationHandle = parseOperationHandle(operationHandleStr)
+    try {
+      val operation = 
backendService.sessionManager.operationManager.getOperation(operationHandle)
+      OperationDetail(operation.shouldRunAsync, operation.isTimedOut, 
operation.getStatus)
+    } catch {
+      case NonFatal(e) =>
+        throw new NotFoundException(s"Error closing an operation")
+    }
+  }
+
+  def parseOperationHandle(operationHandleStr: String): OperationHandle = {
+    try {
+      val operationHandleParts = operationHandleStr.split("\\|")
+      require(
+        operationHandleParts.size == 4,
+        s"Expected 4 parameters but found ${operationHandleParts.size}.")
+
+      val handleIdentifier = new HandleIdentifier(
+        UUID.fromString(operationHandleParts(0)),
+        UUID.fromString(operationHandleParts(1)))
+
+      val protocolVersion = 
TProtocolVersion.findByValue(operationHandleParts(2).toInt)
+      val operationType = OperationType.withName(operationHandleParts(3))
+      val operationHandle = new OperationHandle(handleIdentifier, 
operationType, protocolVersion)
+
+      if 
(!backendService.sessionManager.operationManager.isHasOperation(operationHandle))
 {

Review comment:
       we don't need this




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to