Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 20, 2023
1 parent 5d9b7dc commit 96846d1
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,27 @@ class SparkSQLSessionManager private (name: String, spark: SparkSession)
if (!userIsolatedSparkSession) {
userIsolatedSparkSessionThread =
Some(ThreadUtils.newDaemonSingleThreadScheduledExecutor("user-isolated-cache-checker"))
scheduleTolerableRunnableWithFixedDelay(
_,
() => {
userIsolatedCacheLock.synchronized {
val iter = userIsolatedCacheCount.entrySet().iterator()
while (iter.hasNext) {
val kv = iter.next()
if (kv.getValue._1 == 0 &&
kv.getValue._2 + userIsolatedIdleTimeout < System.currentTimeMillis()) {
userIsolatedCache.remove(kv.getKey)
iter.remove()
userIsolatedSparkSessionThread.foreach { thread =>
scheduleTolerableRunnableWithFixedDelay(
thread,
() => {
userIsolatedCacheLock.synchronized {
val iter = userIsolatedCacheCount.entrySet().iterator()
while (iter.hasNext) {
val kv = iter.next()
if (kv.getValue._1 == 0 &&
kv.getValue._2 + userIsolatedIdleTimeout < System.currentTimeMillis()) {
userIsolatedCache.remove(kv.getKey)
iter.remove()
}
}
}
}
},
userIsolatedIdleInterval,
userIsolatedIdleInterval,
TimeUnit.MILLISECONDS,
"user-isolated-spark-session-cache-checker")
},
userIsolatedIdleInterval,
userIsolatedIdleInterval,
TimeUnit.MILLISECONDS,
"user-isolated-spark-session-cache-checker")
}
}
}

Expand Down

0 comments on commit 96846d1

Please sign in to comment.