Skip to content

Commit

Permalink
[KYUUBI #3941][FOLLOWUP] Config the interval for updating the same st…
Browse files Browse the repository at this point in the history
…atus for a query

### _Why are the changes needed?_

followup for #3941, support to config the interval for updating the same status for a query

### _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 #3960 from turboFei/config_exec_state_update.

Closes #3941

57d7319 [fwang12] config the interval for updating the same status for a query

Authored-by: fwang12 <fwang12@ebay.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
  • Loading branch information
turboFei committed Dec 12, 2022
1 parent fab235e commit e88d170
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,14 @@ object KyuubiConf {
.timeConf
.createWithDefault(Duration.ofSeconds(5).toMillis)

val OPERATION_STATUS_UPDATE_INTERVAL: ConfigEntry[Long] =
buildConf("kyuubi.operation.status.update.interval")
.internal
.doc("Interval(ms) for updating the same status for a query.")
.version("1.7.0")
.timeConf
.createWithDefault(Duration.ofSeconds(5).toMillis)

val OPERATION_FORCE_CANCEL: ConfigEntry[Boolean] =
buildConf("kyuubi.operation.interrupt.on.cancel")
.doc("When true, all running tasks will be interrupted if one cancels a query. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import org.apache.hive.service.rpc.thrift.{TGetOperationStatusResp, TOperationSt
import org.apache.hive.service.rpc.thrift.TOperationState._

import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.events.{EventBus, KyuubiOperationEvent}
import org.apache.kyuubi.operation.ExecuteStatement.DEFAULT_SAME_STATE_UPDATE_INTERVAL
import org.apache.kyuubi.operation.FetchOrientation.FETCH_NEXT
import org.apache.kyuubi.operation.OperationState.OperationState
import org.apache.kyuubi.operation.log.OperationLog
Expand Down Expand Up @@ -82,6 +82,8 @@ class ExecuteStatement(
var isComplete = false
var lastState: TOperationState = null
var lastStateUpdateTime: Long = 0L
val stateUpdateInterval =
session.sessionManager.getConf.get(KyuubiConf.OPERATION_STATUS_UPDATE_INTERVAL)
while (!isComplete) {
fetchQueryLog()
verifyTStatus(statusResp.getStatus)
Expand All @@ -90,7 +92,7 @@ class ExecuteStatement(
}
val remoteState = statusResp.getOperationState
if (lastState != remoteState ||
System.currentTimeMillis() - lastStateUpdateTime > DEFAULT_SAME_STATE_UPDATE_INTERVAL) {
System.currentTimeMillis() - lastStateUpdateTime > stateUpdateInterval) {
lastStateUpdateTime = System.currentTimeMillis()
info(s"Query[$statementId] in ${remoteState.name()}")
}
Expand Down Expand Up @@ -165,7 +167,3 @@ class ExecuteStatement(
EventBus.post(KyuubiOperationEvent(this))
}
}

object ExecuteStatement {
final val DEFAULT_SAME_STATE_UPDATE_INTERVAL = 5000L
}

0 comments on commit e88d170

Please sign in to comment.