diff --git a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala index f4ce390dfa6..2e3f68b77c7 100644 --- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala +++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala @@ -20,6 +20,8 @@ import java.util.{Map => JMap} import scala.collection.JavaConverters._ +import org.apache.commons.lang3.StringUtils + import org.apache.kyuubi.client.BatchRestApi import org.apache.kyuubi.client.api.v1.dto.{Batch, OperationLog} import org.apache.kyuubi.client.util.BatchUtils @@ -50,6 +52,7 @@ class LogBatchCommand( var done = false var batch = this.batch.getOrElse(batchRestApi.getBatchById(batchId)) + var appState = this.batch.map(_.getAppState).orNull val kyuubiInstance = batch.getKyuubiInstance withKyuubiInstanceRestClient(kyuubiRestClient, kyuubiInstance) { kyuubiInstanceRestClient => @@ -85,6 +88,11 @@ class LogBatchCommand( Option(batch).foreach { batch => info(s"Application report for ${batch.getAppId} (state: ${batch.getAppState})," + s" batch id: $batchId (state: ${batch.getState})") + if (appState != batch.getAppState && StringUtils.isNotBlank(batch.getAppId)) { + appState = batch.getAppState + val appDetails = Render.buildBatchAppInfo(batch).mkString("\t ", "\n\t ", "") + info(appDetails) + } } } Thread.sleep(conf.get(CTL_BATCH_LOG_QUERY_INTERVAL)) diff --git a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala index 92db46d888c..c2a10e6b81b 100644 --- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala +++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala @@ -122,7 +122,7 @@ private[ctl] object Render { millisToDateString(batch.getEndTime, "yyyy-MM-dd HH:mm:ss")).mkString("\n~\n")) } - private def buildBatchAppInfo(batch: Batch, showDiagnostic: Boolean = true): List[String] = { + def buildBatchAppInfo(batch: Batch, showDiagnostic: Boolean = true): List[String] = { val batchAppInfo = ListBuffer[String]() batch.getBatchInfo.asScala.foreach { case (key, value) => batchAppInfo += s"$key: $value"