Github user archit279thakur commented on a diff in the pull request: https://github.com/apache/spark/pull/6263#discussion_r44059314 --- Diff: core/src/main/scala/org/apache/spark/storage/StorageStatusListener.scala --- @@ -17,26 +17,55 @@ package org.apache.spark.storage +import java.util.concurrent.TimeUnit + +import scala.collection.JavaConversions.collectionAsScalaIterable import scala.collection.mutable +import scala.language.reflectiveCalls +import org.apache.spark.SparkConf import org.apache.spark.annotation.DeveloperApi import org.apache.spark.scheduler._ +import com.google.common.base.Ticker +import com.google.common.cache.CacheBuilder + /** * :: DeveloperApi :: * A SparkListener that maintains executor storage status. * * This class is thread-safe (unlike JobProgressListener) */ + +object StorageStatusListener { + val TIME_TO_EXPIRE_KILLED_EXECUTOR = "spark.ui.timeToExpireKilledExecutor" +} + @DeveloperApi -class StorageStatusListener extends SparkListener { +class StorageStatusListener(conf: SparkConf) extends SparkListener { + var ticker = Ticker.systemTicker() + + private [storage] def this(conf: SparkConf, ticker: Ticker) = { + this(conf) + this.ticker = ticker + } + + import StorageStatusListener._ + // This maintains only blocks that are cached (i.e. storage level is not StorageLevel.NONE) private[storage] val executorIdToStorageStatus = mutable.Map[String, StorageStatus]() + private[storage] val removedExecutorIdToStorageStatus = CacheBuilder.newBuilder(). + expireAfterWrite(conf.getTimeAsSeconds(TIME_TO_EXPIRE_KILLED_EXECUTOR, "0"), TimeUnit.SECONDS). + ticker(ticker).build[String, StorageStatus]() def storageStatusList: Seq[StorageStatus] = synchronized { executorIdToStorageStatus.values.toSeq } - + + def removedExecutorStorageStatusList: Seq[StorageStatus] = synchronized{ --- End diff -- Thanks for pointing it out. Corrected.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org