From f5205c6bbb9349c59cf091a916afc64df4669036 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 14 Jan 2022 12:39:39 +0800 Subject: [PATCH] [KYUUBI #1759] Remove duplicate close operation api ### _Why are the changes needed?_ Remove duplicate close operation api, closes #1759 #1445 is duplicate with #1517 where action='close'. ``` /${version}/operations/${operation_identifier} desc: apply an action for an operation based on a given session identifier and operation identifier method: PUT params: action: "CANCEL" or "ADD" or "CLOSE" returns: status code /${version}/sessions/${session_identifier}/operations/${operation_identifier} desc: remove operation based on a given session identifier and operation identifier method: DELETE params: none returns: an instance of OperationHandle ``` ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1760 from simon824/closeoperation. Closes #1759 9af70a07 [simon] closeoperation Authored-by: simon Signed-off-by: Kent Yao --- .../server/api/v1/SessionsResource.scala | 23 ----------- .../server/api/v1/SessionsResourceSuite.scala | 39 ------------------- 2 files changed, 62 deletions(-) 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 158cf2bfc..419722ae2 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 @@ -31,7 +31,6 @@ import org.apache.hive.service.rpc.thrift.{TGetInfoType, TProtocolVersion} import org.apache.kyuubi.Utils.error import org.apache.kyuubi.events.KyuubiEvent import org.apache.kyuubi.operation.OperationHandle -import org.apache.kyuubi.operation.OperationHandle.parseOperationHandle import org.apache.kyuubi.server.api.ApiRequestContext import org.apache.kyuubi.session.SessionHandle import org.apache.kyuubi.session.SessionHandle.parseSessionHandle @@ -306,26 +305,4 @@ private[v1] class SessionsResource extends ApiRequestContext { throw new NotFoundException(s"Error getting functions") } } - - @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 = { - - try { - val operationHandle = parseOperationHandle(operationHandleStr) - fe.be.sessionManager.getSession(parseSessionHandle(sessionHandleStr)) - .closeOperation(operationHandle) - operationHandle - } catch { - case NonFatal(_) => - throw new NotFoundException(s"Error closing an operation") - } - } } diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala index e25db6f93..3f3d15cf5 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala @@ -247,43 +247,4 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { operationHandle = response.readEntity(classOf[OperationHandle]) assert(operationHandle.typ == OperationType.GET_FUNCTIONS) } - - test("close an operation") { - val requestObj = SessionOpenRequest( - 1, - "admin", - "123456", - "localhost", - Map("testConfig" -> "testValue")) - - var response: Response = webTarget.path("api/v1/sessions") - .request(MediaType.APPLICATION_JSON_TYPE) - .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE)) - - val sessionHandle = response.readEntity(classOf[SessionHandle]) - val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" + - s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}" - - val pathPrefix = s"api/v1/sessions/$serializedSessionHandle" - - response = webTarget.path(s"$pathPrefix/operations/catalogs") - .request(MediaType.APPLICATION_JSON_TYPE) - .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE)) - assert(200 == response.getStatus) - val operationHandle = response.readEntity(classOf[OperationHandle]) - assert(operationHandle.typ == OperationType.GET_CATALOGS) - - val serializedOperationHandle = s"${operationHandle.identifier.publicId}|" + - s"${operationHandle.identifier.secretId}|${operationHandle.protocol.getValue}|" + - s"${operationHandle.typ.toString}" - - response = webTarget.path(s"$pathPrefix/operations/$serializedOperationHandle") - .request(MediaType.APPLICATION_JSON_TYPE).delete() - assert(200 == response.getStatus) - - // verify operation - response = webTarget.path(s"api/v1/operations/$serializedOperationHandle/event") - .request(MediaType.APPLICATION_JSON_TYPE).get() - assert(404 == response.getStatus) - } }