You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/10/30 09:53:41 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #3722] Set default parameters for BatchesResource in server side

This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 14b9fd5e7 [KYUUBI #3722] Set default parameters for BatchesResource in server side
14b9fd5e7 is described below

commit 14b9fd5e755aca850fb7327527abb8ee69506207
Author: Fei Wang <fw...@ebay.com>
AuthorDate: Sun Oct 30 17:53:31 2022 +0800

    [KYUUBI #3722] Set default parameters for BatchesResource in server side
    
    ### _Why are the changes needed?_
    
    Set the same default values for BatchesResource in server side.
    ### _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
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #3722 from turboFei/batch_user_defaults.
    
    Closes #3722
    
    496e61a55 [Fei Wang] default in server side
    
    Authored-by: Fei Wang <fw...@ebay.com>
    Signed-off-by: Fei Wang <fw...@ebay.com>
---
 docs/client/rest/rest_api.md                       | 36 +++++++++++-----------
 .../kyuubi/server/api/v1/BatchesResource.scala     |  4 +--
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/docs/client/rest/rest_api.md b/docs/client/rest/rest_api.md
index d494fbd79..b95d908a8 100644
--- a/docs/client/rest/rest_api.md
+++ b/docs/client/rest/rest_api.md
@@ -269,23 +269,23 @@ Returns all the batches.
 
 #### Request Parameters
 
-| Name       | Description                                                                                             | Type   |
-| :--------- |:--------------------------------------------------------------------------------------------------------| :----- |
-| batchType  | The batch type, such as spark/flink, if no batchType is specified,<br/> return all types                | String |
-| batchState | The valid batch state can be one of the following:<br/> PENDING, RUNNING, FINISHED, ERROR, CANCELED     | String |
-| batchUser  | The user name that created the batch                                                                    | String |
-| createTime | Return the batch that created after this timestamp                                                      | Long   |
-| endTime    | Return the batch that ended before this timestamp                                                       | Long   |
-| from       | The start index to fetch sessions                                                                       | Int    |
-| size       | Number of sessions to fetch                                                                             | Int    |
+| Name       | Description                                                                                         | Type   |
+| :--------- |:----------------------------------------------------------------------------------------------------| :----- |
+| batchType  | The batch type, such as spark/flink, if no batchType is specified,<br/> return all types            | String |
+| batchState | The valid batch state can be one of the following:<br/> PENDING, RUNNING, FINISHED, ERROR, CANCELED | String |
+| batchUser  | The user name that created the batch                                                                | String |
+| createTime | Return the batch that created after this timestamp                                                  | Long   |
+| endTime    | Return the batch that ended before this timestamp                                                   | Long   |
+| from       | The start index to fetch batches                                                                    | Int    |
+| size       | Number of batches to fetch, 100 by default                                                          | Int    |
 
 #### Response Body
 
-| Name    | Description                         | Type |
-| :------ | :---------------------------------- | :--- |
-| from    | The start index of fetched sessions | Int  |
-| total   | Number of sessions fetched          | Int  |
-| batches | [Batch](#batch) List                | List |
+| Name    | Description                        | Type |
+| :------ |:-----------------------------------| :--- |
+| from    | The start index of fetched batches | Int  |
+| total   | Number of batches fetched          | Int  |
+| batches | [Batch](#batch) List               | List |
 
 ### POST /batches
 
@@ -337,10 +337,10 @@ Gets the local log lines from this batch.
 
 #### Request Parameters
 
-| Name | Description                       | Type |
-| :--- | :-------------------------------- | :--- |
-| from | Offset                            | Int  |
-| size | Max number of log lines to return | Int  |
+| Name | Description                                       | Type |
+| :--- |:--------------------------------------------------| :--- |
+| from | Offset                                            | Int  |
+| size | Max number of log lines to return, 100 by default | Int  |
 
 #### Response Body
 
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
index b0333b309..26973b6e0 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
@@ -232,7 +232,7 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
       @QueryParam("createTime") createTime: Long,
       @QueryParam("endTime") endTime: Long,
       @QueryParam("from") from: Int,
-      @QueryParam("size") size: Int): GetBatchesResponse = {
+      @QueryParam("size") @DefaultValue("100") size: Int): GetBatchesResponse = {
     require(
       createTime >= 0 && endTime >= 0 && (endTime == 0 || createTime <= endTime),
       "Invalid time range")
@@ -264,7 +264,7 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
   def getBatchLocalLog(
       @PathParam("batchId") batchId: String,
       @QueryParam("from") @DefaultValue("-1") from: Int,
-      @QueryParam("size") size: Int): OperationLog = {
+      @QueryParam("size") @DefaultValue("100") size: Int): OperationLog = {
     val userName = fe.getUserName(Map.empty[String, String])
     val sessionHandle = formatSessionHandle(batchId)
     Option(sessionManager.getBatchSessionImpl(sessionHandle)).map { batchSession =>