turboFei commented on code in PR #2295:
URL: https://github.com/apache/incubator-kyuubi/pull/2295#discussion_r846075175
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala:
##########
@@ -64,11 +71,53 @@ case class SparkSQLEngine(spark: SparkSession) extends
Serverable("SparkSQLEngin
assert(currentEngine.isDefined)
currentEngine.get.stop()
})
+
+ startLifetimeTerminatingChecker(() => {
+ assert(currentEngine.isDefined)
+ currentEngine.get.stop()
+ })
+ }
+
+ override def stop(): Unit = synchronized {
+ super.stop()
+
+ shutdown = true
+ val shutdownTimeout = conf.get(ENGINE_EXEC_POOL_SHUTDOWN_TIMEOUT)
+ ThreadUtils.shutdown(lifetimeTerminatingChecker, Duration(shutdownTimeout,
TimeUnit.MILLISECONDS))
}
override protected def stopServer(): Unit = {
countDownLatch.countDown()
}
+
+ private[kyuubi] def startLifetimeTerminatingChecker(stop: () => Unit): Unit
= {
+ val interval = conf.get(ENGINE_CHECK_INTERVAL)
+ val maxLifetime = conf.get(ENGINE_SPARK_MAX_LIFETIME)
+ if (maxLifetime > 0) {
+ val checkTask = new Runnable {
+ override def run(): Unit = {
+ if (!shutdown && System.currentTimeMillis() - getStartTime >
maxLifetime) {
+ if (!deregistered) {
+ info(s"Spark engine has been running for more than $maxLifetime
ms," +
+ s"deregistering from engine discovery space.")
Review Comment:
nit:
```
s" deregistering
```
--
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]