Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ private[kyuubi] class EngineRef(

private val clientPoolName: String = conf.get(ENGINE_POOL_NAME)

private var builder: ProcBuilder = _

@VisibleForTesting
private[kyuubi] val subdomain: String = conf.get(ENGINE_SHARE_LEVEL_SUBDOMAIN) match {
case Some(_subdomain) => _subdomain
Expand Down Expand Up @@ -162,7 +164,7 @@ private[kyuubi] class EngineRef(
conf.set(HA_ZK_ENGINE_REF_ID, engineRefId)
val started = System.currentTimeMillis()
conf.set(KYUUBI_ENGINE_SUBMIT_TIME_KEY, String.valueOf(started))
val builder = engineType match {
builder = engineType match {
case SPARK_SQL =>
conf.setIfMissing(SparkProcessBuilder.APP_KEY, defaultEngineName)
new SparkProcessBuilder(appUser, conf, extraEngineLog)
Expand Down Expand Up @@ -230,4 +232,17 @@ private[kyuubi] class EngineRef(
create(discoveryClient, extraEngineLog)
}
}

def close(): Unit = {
if (shareLevel == CONNECTION && builder != null) {
try {
val clusterManager = builder.clusterManager()
builder.close(true)
engineManager.killApplication(clusterManager, engineRefId)
} catch {
case e: Exception =>
warn(s"Error closing engine builder, engineRefId: $engineRefId", e)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ trait ProcBuilder {
process
}

def close(): Unit = synchronized {
def close(destroyProcess: Boolean = !waitCompletion): Unit = synchronized {
if (logCaptureThread != null) {
logCaptureThread.interrupt()
logCaptureThread = null
}
if (!waitCompletion && process != null) {
if (destroyProcess && process != null) {
info("Destroy the process, since waitCompletion is false.")
process.destroyForcibly()
process = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class KyuubiSessionImpl(
try {
if (_client != null) _client.closeSession()
} finally {
if (engine != null) engine.close()
sessionEvent.endTime = System.currentTimeMillis()
EventBus.post(sessionEvent)
MetricsSystem.tracing(_.decCount(MetricRegistry.name(CONN_OPEN, user)))
Expand Down