Skip to content

Commit

Permalink
[SPARK-9886][CORE] Fix to use ShutdownHookManager in
Browse files Browse the repository at this point in the history
ExternalBlockStore.scala

Author: Naveen <naveenminchu@gmail.com>

Closes #10313 from naveenminchu/branch-fix-SPARK-9886.
  • Loading branch information
naveenminchu authored and Andrew Or committed Dec 16, 2015
1 parent 63ccdef commit 8a215d2
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.nio.ByteBuffer
import scala.util.control.NonFatal

import org.apache.spark.Logging
import org.apache.spark.util.Utils
import org.apache.spark.util.{ShutdownHookManager, Utils}


/**
Expand Down Expand Up @@ -177,15 +177,6 @@ private[spark] class ExternalBlockStore(blockManager: BlockManager, executorId:
}
}

private def addShutdownHook() {
Runtime.getRuntime.addShutdownHook(new Thread("ExternalBlockStore shutdown hook") {
override def run(): Unit = Utils.logUncaughtExceptions {
logDebug("Shutdown hook called")
externalBlockManager.map(_.shutdown())
}
})
}

// Create concrete block manager and fall back to Tachyon by default for backward compatibility.
private def createBlkManager(): Option[ExternalBlockManager] = {
val clsName = blockManager.conf.getOption(ExternalBlockStore.BLOCK_MANAGER_NAME)
Expand All @@ -196,7 +187,10 @@ private[spark] class ExternalBlockStore(blockManager: BlockManager, executorId:
.newInstance()
.asInstanceOf[ExternalBlockManager]
instance.init(blockManager, executorId)
addShutdownHook();
ShutdownHookManager.addShutdownHook { () =>
logDebug("Shutdown hook called")
externalBlockManager.map(_.shutdown())
}
Some(instance)
} catch {
case NonFatal(t) =>
Expand Down

0 comments on commit 8a215d2

Please sign in to comment.