Skip to content

[SPARK-9886][CORE] Fix to use ShutdownHookManager in #10313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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 @@ -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