spark git commit: [SPARK-12365][CORE] Use ShutdownHookManager where Runtime.getRuntime.addShutdownHook() is called
Repository: spark Updated Branches: refs/heads/branch-1.6 fb02e4e3b -> 4af64385b [SPARK-12365][CORE] Use ShutdownHookManager where Runtime.getRuntime.addShutdownHook() is called SPARK-9886 fixed ExternalBlockStore.scala This PR fixes the remaining references to Runtime.getRuntime.addShutdownHook() Author: tedyu Closes #10325 from ted-yu/master. (cherry picked from commit f590178d7a06221a93286757c68b23919bee9f03) Signed-off-by: Andrew Or Conflicts: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/4af64385 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/4af64385 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/4af64385 Branch: refs/heads/branch-1.6 Commit: 4af64385b085002d94c54d11bbd144f9f026bbd8 Parents: fb02e4e Author: tedyu Authored: Wed Dec 16 19:02:12 2015 -0800 Committer: Andrew Or Committed: Wed Dec 16 19:03:30 2015 -0800 -- .../spark/deploy/ExternalShuffleService.scala | 18 ++ .../deploy/mesos/MesosClusterDispatcher.scala | 13 + .../apache/spark/util/ShutdownHookManager.scala | 4 scalastyle-config.xml | 12 4 files changed, 27 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/spark/blob/4af64385/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala -- diff --git a/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala b/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala index e8a1e35..7fc96e4 100644 --- a/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala +++ b/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala @@ -28,7 +28,7 @@ import org.apache.spark.network.sasl.SaslServerBootstrap import org.apache.spark.network.server.{TransportServerBootstrap, TransportServer} import org.apache.spark.network.shuffle.ExternalShuffleBlockHandler import org.apache.spark.network.util.TransportConf -import org.apache.spark.util.Utils +import org.apache.spark.util.{ShutdownHookManager, Utils} /** * Provides a server from which Executors can read shuffle files (rather than reading directly from @@ -118,19 +118,13 @@ object ExternalShuffleService extends Logging { server = newShuffleService(sparkConf, securityManager) server.start() -installShutdownHook() +ShutdownHookManager.addShutdownHook { () => + logInfo("Shutting down shuffle service.") + server.stop() + barrier.countDown() +} // keep running until the process is terminated barrier.await() } - - private def installShutdownHook(): Unit = { -Runtime.getRuntime.addShutdownHook(new Thread("External Shuffle Service shutdown thread") { - override def run() { -logInfo("Shutting down shuffle service.") -server.stop() -barrier.countDown() - } -}) - } } http://git-wip-us.apache.org/repos/asf/spark/blob/4af64385/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala -- diff --git a/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala b/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala index 5d4e5b8..389eff5 100644 --- a/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala +++ b/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala @@ -22,7 +22,7 @@ import java.util.concurrent.CountDownLatch import org.apache.spark.deploy.mesos.ui.MesosClusterUI import org.apache.spark.deploy.rest.mesos.MesosRestServer import org.apache.spark.scheduler.cluster.mesos._ -import org.apache.spark.util.SignalLogger +import org.apache.spark.util.{ShutdownHookManager, SignalLogger} import org.apache.spark.{Logging, SecurityManager, SparkConf} /* @@ -103,14 +103,11 @@ private[mesos] object MesosClusterDispatcher extends Logging { } val dispatcher = new MesosClusterDispatcher(dispatcherArgs, conf) dispatcher.start() -val shutdownHook = new Thread() { - override def run() { -logInfo("Shutdown hook is shutting down dispatcher") -dispatcher.stop() -dispatcher.awaitShutdown() - } +ShutdownHookManager.addShutdownHook { () => + logInfo("Shutdown hook is shutting down dispatcher") + dispatcher.stop() + dispatcher.awaitShutdown() } -Runtime.getRuntime.addShutdownHook(shutdownHook) dispatcher.awaitShutdown() } } http://git-wip-us.apache.org/repos/asf/spark/blob/4af64385/core/src/m
spark git commit: [SPARK-12365][CORE] Use ShutdownHookManager where Runtime.getRuntime.addShutdownHook() is called
Repository: spark Updated Branches: refs/heads/master 38d9795a4 -> f590178d7 [SPARK-12365][CORE] Use ShutdownHookManager where Runtime.getRuntime.addShutdownHook() is called SPARK-9886 fixed ExternalBlockStore.scala This PR fixes the remaining references to Runtime.getRuntime.addShutdownHook() Author: tedyu Closes #10325 from ted-yu/master. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/f590178d Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/f590178d Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/f590178d Branch: refs/heads/master Commit: f590178d7a06221a93286757c68b23919bee9f03 Parents: 38d9795 Author: tedyu Authored: Wed Dec 16 19:02:12 2015 -0800 Committer: Andrew Or Committed: Wed Dec 16 19:02:12 2015 -0800 -- .../spark/deploy/ExternalShuffleService.scala | 18 +-- .../deploy/mesos/MesosClusterDispatcher.scala | 13 --- .../apache/spark/util/ShutdownHookManager.scala | 4 scalastyle-config.xml | 12 ++ .../hive/thriftserver/SparkSQLCLIDriver.scala | 24 +--- 5 files changed, 38 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/spark/blob/f590178d/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala -- diff --git a/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala b/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala index e8a1e35..7fc96e4 100644 --- a/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala +++ b/core/src/main/scala/org/apache/spark/deploy/ExternalShuffleService.scala @@ -28,7 +28,7 @@ import org.apache.spark.network.sasl.SaslServerBootstrap import org.apache.spark.network.server.{TransportServerBootstrap, TransportServer} import org.apache.spark.network.shuffle.ExternalShuffleBlockHandler import org.apache.spark.network.util.TransportConf -import org.apache.spark.util.Utils +import org.apache.spark.util.{ShutdownHookManager, Utils} /** * Provides a server from which Executors can read shuffle files (rather than reading directly from @@ -118,19 +118,13 @@ object ExternalShuffleService extends Logging { server = newShuffleService(sparkConf, securityManager) server.start() -installShutdownHook() +ShutdownHookManager.addShutdownHook { () => + logInfo("Shutting down shuffle service.") + server.stop() + barrier.countDown() +} // keep running until the process is terminated barrier.await() } - - private def installShutdownHook(): Unit = { -Runtime.getRuntime.addShutdownHook(new Thread("External Shuffle Service shutdown thread") { - override def run() { -logInfo("Shutting down shuffle service.") -server.stop() -barrier.countDown() - } -}) - } } http://git-wip-us.apache.org/repos/asf/spark/blob/f590178d/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala -- diff --git a/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala b/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala index 5d4e5b8..389eff5 100644 --- a/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala +++ b/core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala @@ -22,7 +22,7 @@ import java.util.concurrent.CountDownLatch import org.apache.spark.deploy.mesos.ui.MesosClusterUI import org.apache.spark.deploy.rest.mesos.MesosRestServer import org.apache.spark.scheduler.cluster.mesos._ -import org.apache.spark.util.SignalLogger +import org.apache.spark.util.{ShutdownHookManager, SignalLogger} import org.apache.spark.{Logging, SecurityManager, SparkConf} /* @@ -103,14 +103,11 @@ private[mesos] object MesosClusterDispatcher extends Logging { } val dispatcher = new MesosClusterDispatcher(dispatcherArgs, conf) dispatcher.start() -val shutdownHook = new Thread() { - override def run() { -logInfo("Shutdown hook is shutting down dispatcher") -dispatcher.stop() -dispatcher.awaitShutdown() - } +ShutdownHookManager.addShutdownHook { () => + logInfo("Shutdown hook is shutting down dispatcher") + dispatcher.stop() + dispatcher.awaitShutdown() } -Runtime.getRuntime.addShutdownHook(shutdownHook) dispatcher.awaitShutdown() } } http://git-wip-us.apache.org/repos/asf/spark/blob/f590178d/core/src/main/scala/org/apache/spark/util/ShutdownHookManager.scala -- diff --git a/core/src/main/scala/or