yaooqinn commented on a change in pull request #1445:
URL: https://github.com/apache/incubator-kyuubi/pull/1445#discussion_r756557042
##########
File path:
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
##########
@@ -322,6 +322,70 @@ private[v1] class SessionsResource extends
ApiRequestContext {
}
}
+ @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 = getSessionHandle(sessionHandleStr)
+ val operationHandle = getOperationHandle(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 handle with a given session identifier and operation
identifier")
+ @GET
+ @Path("{sessionHandle}/operations/{operationHandle}")
+ def getOperationHandle(
+ @PathParam("sessionHandle") sessionHandleStr: String,
+ @PathParam("operationHandle") operationHandleStr: String):
OperationHandle = {
+ val sessionHandle = getSessionHandle(sessionHandleStr)
+ val operationHandle = getOperationHandle(operationHandleStr)
+ val hasHandle = backendService.sessionManager.getSession(sessionHandle)
+ .isHasOperationHandle(operationHandle)
+ if (hasHandle) {
+ operationHandle
+ } else {
+ throw new NotFoundException(s"Error getting operationHandle")
+ }
+
+ }
+
+ def getOperationHandle(operationHandleStr: String): OperationHandle = {
+ try {
+ val splitOperationHandle = operationHandleStr.split("\\|")
+ val handleIdentifier = new HandleIdentifier(
+ UUID.fromString(splitOperationHandle(0)),
+ UUID.fromString(splitOperationHandle(1)))
+ val protocolVersion =
TProtocolVersion.findByValue(splitOperationHandle(2).toInt)
+ val operationType = OperationType.withName(splitOperationHandle(3))
+ val operationHandle = new OperationHandle(handleIdentifier,
operationType, protocolVersion)
+
+ // if the operationHandle is invalid, KyuubiSQLException will be thrown
here.
+
backendService.sessionManager.operationManager.getOperation(operationHandle)
Review comment:
we can make it method only for parsing
--
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]