[KYUUBI #1258] Implement sessions/execpool/statistic
### _Why are the changes needed?_ This is a subtask of umbrella issue #KPIP-1 ### _How was this patch tested?_ - [x] 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 #1259 from simon824/h1. Closes #1258 8b92b2d2 [simon] future.cancel 7aa6416c [simon] merge to statistic e0c5d1ab [simon] [KYUUBI #1258] Implement /sessions/execpoolsize and /sessions/execpoolactivecount d9219801 [simon] [SUB-TASK][KPIP-1] Authored-by: simon <zhangshiming@cvte.com> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
This commit is contained in:
parent
23d821950e
commit
3774658831
@ -36,6 +36,13 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
SessionOpenCount(backendService.sessionManager.getOpenSessionCount)
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("execpool/statistic")
|
||||
def execPoolStatistic(): ExecPoolStatistic = {
|
||||
ExecPoolStatistic(backendService.sessionManager.getExecPoolSize,
|
||||
backendService.sessionManager.getActiveCount)
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes(Array(MediaType.APPLICATION_JSON))
|
||||
def openSession(request: SessionOpenRequest): SessionHandle = {
|
||||
|
||||
@ -19,6 +19,8 @@ package org.apache.kyuubi.server.api.v1
|
||||
|
||||
case class SessionOpenCount(openSessionCount: Int)
|
||||
|
||||
case class ExecPoolStatistic(execPoolSize: Int, execPoolActiveCount: Int)
|
||||
|
||||
case class SessionOpenRequest(
|
||||
protocolVersion: Int,
|
||||
user: String,
|
||||
|
||||
@ -22,8 +22,7 @@ import javax.ws.rs.core.MediaType
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.apache.kyuubi.server.RestApiBaseSuite
|
||||
import org.apache.kyuubi.server.RestFrontendServiceSuite
|
||||
import org.apache.kyuubi.server.{RestApiBaseSuite, RestFrontendService, RestFrontendServiceSuite}
|
||||
import org.apache.kyuubi.session.SessionHandle
|
||||
|
||||
class SessionsResourceSuite extends RestApiBaseSuite {
|
||||
@ -84,4 +83,32 @@ class SessionsResourceSuite extends RestApiBaseSuite {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
def testExecPoolStatistic: Unit = {
|
||||
RestFrontendServiceSuite.withKyuubiRestServer {
|
||||
(restFrontendService: RestFrontendService, _, _) =>
|
||||
|
||||
val sessionManager = restFrontendService.be.sessionManager
|
||||
val future = sessionManager.submitBackgroundOperation(() => {
|
||||
Thread.sleep(3000)
|
||||
})
|
||||
|
||||
// verify the exec pool statistic
|
||||
var response = target("api/v1/sessions/execpool/statistic").request().get()
|
||||
val execPoolStatistic1 = response.readEntity(classOf[ExecPoolStatistic])
|
||||
assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1)
|
||||
|
||||
future.cancel(true)
|
||||
response = target("api/v1/sessions/execpool/statistic").request().get()
|
||||
val execPoolStatistic2 = response.readEntity(classOf[ExecPoolStatistic])
|
||||
assert(execPoolStatistic2.execPoolSize == 1 && execPoolStatistic2.execPoolActiveCount == 0)
|
||||
|
||||
sessionManager.stop()
|
||||
response = target("api/v1/sessions/execpool/statistic").request().get()
|
||||
val execPoolStatistic3 = response.readEntity(classOf[ExecPoolStatistic])
|
||||
assert(execPoolStatistic3.execPoolSize == 0 && execPoolStatistic3.execPoolActiveCount == 0)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user