Skip to content

Commit

Permalink
[KYUUBI apache#4424][REST] Catch No Node Exception, when list kyuubi …
Browse files Browse the repository at this point in the history
…engines

### _Why are the changes needed?_

Close apache#4424

Catch No Node Exception, when list kyuubi engines

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [x] Add screenshots for manual tests if appropriate

- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request

![WX20230227-184957](https://user-images.githubusercontent.com/52876270/221544376-2f0d6b4b-0bc4-446e-abb1-d0c79211aea4.png)

Closes apache#4425 from zwangsheng/kyuubi-4424.

Closes apache#4424

3052b15 [zwangsheng] [Kyuubi apache#4424] Fix scala style
74825cf [zwangsheng] [Kyuubi apache#4424] Throw User Friendly Exception
7e8363c [zwangsheng] [Kyuubi apache#4424] Remove usless file & catch subException
4a3c469 [zwangsheng] [Kyuubi apache#4424] Catch cacth No Node Exception, when list kyuubi engines

Authored-by: zwangsheng <[email protected]>
Signed-off-by: ulyssesyou <[email protected]>
  • Loading branch information
zwangsheng authored and yanghua committed Apr 13, 2023
1 parent 570888e commit 76378a3
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import scala.collection.mutable.ListBuffer
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.tags.Tag
import org.apache.zookeeper.KeeperException.NoNodeException

import org.apache.kyuubi.{KYUUBI_VERSION, Logging, Utils}
import org.apache.kyuubi.client.api.v1.dto.Engine
Expand Down Expand Up @@ -140,9 +141,19 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
}
case None =>
withDiscoveryClient(fe.getConf) { discoveryClient =>
discoveryClient.getChildren(engineSpace).map { child =>
info(s"Listing engine nodes for $engineSpace/$child")
engineNodes ++= discoveryClient.getServiceNodesInfo(s"$engineSpace/$child")
try {
discoveryClient.getChildren(engineSpace).map { child =>
info(s"Listing engine nodes for $engineSpace/$child")
engineNodes ++= discoveryClient.getServiceNodesInfo(s"$engineSpace/$child")
}
} catch {
case nne: NoNodeException =>
error(
s"No such engine for user: $userName, " +
s"engine type: $engineType, share level: $shareLevel, subdomain: $subdomain",
nne)
throw new NotFoundException(s"No such engine for user: $userName, " +
s"engine type: $engineType, share level: $shareLevel, subdomain: $subdomain")
}
}
}
Expand Down

0 comments on commit 76378a3

Please sign in to comment.