wForget commented on code in PR #5410:
URL: https://github.com/apache/kyuubi/pull/5410#discussion_r1357015180
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/kyuubi/SQLOperationListener.scala:
##########
@@ -79,37 +80,45 @@ class SQLOperationListener(
}
}
- override def onJobStart(jobStart: SparkListenerJobStart): Unit =
activeJobs.synchronized {
- if (sameGroupId(jobStart.properties)) {
- val jobId = jobStart.jobId
- val stageSize = jobStart.stageInfos.size
- if (executionId.isEmpty) {
- executionId =
Option(jobStart.properties.getProperty(SPARK_SQL_EXECUTION_ID_KEY))
- .map(_.toLong)
- consoleProgressBar
- operation match {
- case executeStatement: ExecuteStatement =>
- executeStatement.setCompiledStateIfNeeded()
- case _ =>
+ override def onJobStart(jobStart: SparkListenerJobStart): Unit = {
+ activeJobs.synchronized {
+ if (sameGroupId(jobStart.properties)) {
+ val jobId = jobStart.jobId
+ val stageIds = jobStart.stageInfos.map(_.stageId)
+ val stageSize = jobStart.stageInfos.size
+ if (executionId.isEmpty) {
+ executionId =
Option(jobStart.properties.getProperty(SPARK_SQL_EXECUTION_ID_KEY))
+ .map(_.toLong)
+ consoleProgressBar
+ operation match {
+ case executeStatement: ExecuteStatement =>
+ executeStatement.setCompiledStateIfNeeded()
+ case _ =>
+ }
+ }
+ activeJobs.put(
+ jobId,
+ new SparkJobInfo(stageSize, stageIds)
+ )
+ withOperationLog {
+ info(s"Query [$operationId]: Job $jobId started with $stageSize
stages," +
+ s" ${activeJobs.size()} active jobs running")
}
- }
- withOperationLog {
- activeJobs.add(jobId)
- info(s"Query [$operationId]: Job $jobId started with $stageSize
stages," +
- s" ${activeJobs.size()} active jobs running")
}
}
}
override def onJobEnd(jobEnd: SparkListenerJobEnd): Unit =
activeJobs.synchronized {
val jobId = jobEnd.jobId
- if (activeJobs.remove(jobId)) {
- val hint = jobEnd.jobResult match {
- case JobSucceeded => "succeeded"
- case _ => "failed" // TODO: Handle JobFailed(exception: Exception)
- }
- withOperationLog {
- info(s"Query [$operationId]: Job $jobId $hint, ${activeJobs.size()}
active jobs running")
+ activeJobs.synchronized {
Review Comment:
duplicate `activeJobs.synchronized`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]