turboFei commented on code in PR #2909:
URL: https://github.com/apache/incubator-kyuubi/pull/2909#discussion_r900712155


##########
kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala:
##########
@@ -46,41 +45,70 @@ class LogBatchCommand(cliConfig: CliConfig, restConfigMap: 
JMap[String, Object]
 
       var log: OperationLog = null
       var done = false
-      var batch: Batch = null
+      var batch: Batch = batchRestApi.getBatchById(batchId)
+      val kyuubiInstance = batch.getKyuubiInstance
 
-      while (!done) {
-        try {
-          log = batchRestApi.getBatchLocalLog(
-            batchId,
-            from,
-            size)
-          from += log.getLogRowSet.size
-          log.getLogRowSet.asScala.foreach(x => info(x))
-          if (!normalizedCliConfig.logOpts.forward) {
-            done = true
-          }
-        } catch {
-          case e: KyuubiRestException =>
-            error(s"Error fetching batch logs: ${e.getMessage}")
-        }
+      withKyuubiInstanceRestClient(kyuubiRestClient, kyuubiInstance) { 
kyuubiInstanceRestClient =>
+        val kyuubiInstanceBatchRestApi: BatchRestApi = new 
BatchRestApi(kyuubiInstanceRestClient)
+        while (!done) {
+          try {
+            log = kyuubiInstanceBatchRestApi.getBatchLocalLog(
+              batchId,
+              from,
+              size)
+            from += log.getLogRowSet.size
+            log.getLogRowSet.asScala.foreach(x => info(x))
 
-        if (log == null || log.getLogRowSet.size() == 0) {
-          batch = batchRestApi.getBatchById(batchId)
-          if (BatchUtil.isTerminalState(batch.getState)) {
-            done = true
+            val (latestBatch, shouldFinishLog) =
+              checkStatus(kyuubiInstanceBatchRestApi, batchId, log)
+            batch = latestBatch
+            done = shouldFinishLog
+          } catch {
+            case e: Exception =>
+              val (latestBatch, shouldFinishLog) = checkStatus(batchRestApi, 
batchId, log)
+              batch = latestBatch
+              done = shouldFinishLog
+              if (done) {
+                error(s"Error fetching batch logs: ${e.getMessage}")
+              }
           }
-        }
 
-        if (!done) {
-          Thread.sleep(DEFAULT_LOG_QUERY_INTERVAL)
+          if (!done) {
+            Thread.sleep(DEFAULT_LOG_QUERY_INTERVAL)

Review Comment:
   Let us increase the DEFAULT_LOG_QUERY_INTERVAL to 3000.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org
For additional commands, e-mail: notifications-h...@kyuubi.apache.org

Reply via email to