File tree Expand file tree Collapse file tree 4 files changed +20
-27
lines changed
core/src/main/scala/org/apache/spark Expand file tree Collapse file tree 4 files changed +20
-27
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ import org.apache.spark.network.sasl.SaslServerBootstrap
28
28
import org .apache .spark .network .server .{TransportServerBootstrap , TransportServer }
29
29
import org .apache .spark .network .shuffle .ExternalShuffleBlockHandler
30
30
import org .apache .spark .network .util .TransportConf
31
- import org .apache .spark .util .{ ShutdownHookManager , Utils }
31
+ import org .apache .spark .util .Utils
32
32
33
33
/**
34
34
* Provides a server from which Executors can read shuffle files (rather than reading directly from
@@ -118,13 +118,19 @@ object ExternalShuffleService extends Logging {
118
118
server = newShuffleService(sparkConf, securityManager)
119
119
server.start()
120
120
121
- ShutdownHookManager .addShutdownHook { () =>
122
- logInfo(" Shutting down shuffle service." )
123
- server.stop()
124
- barrier.countDown()
125
- }
121
+ installShutdownHook()
126
122
127
123
// keep running until the process is terminated
128
124
barrier.await()
129
125
}
126
+
127
+ private def installShutdownHook (): Unit = {
128
+ Runtime .getRuntime.addShutdownHook(new Thread (" External Shuffle Service shutdown thread" ) {
129
+ override def run () {
130
+ logInfo(" Shutting down shuffle service." )
131
+ server.stop()
132
+ barrier.countDown()
133
+ }
134
+ })
135
+ }
130
136
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import java.util.concurrent.CountDownLatch
22
22
import org .apache .spark .deploy .mesos .ui .MesosClusterUI
23
23
import org .apache .spark .deploy .rest .mesos .MesosRestServer
24
24
import org .apache .spark .scheduler .cluster .mesos ._
25
- import org .apache .spark .util .{ ShutdownHookManager , SignalLogger }
25
+ import org .apache .spark .util .SignalLogger
26
26
import org .apache .spark .{Logging , SecurityManager , SparkConf }
27
27
28
28
/*
@@ -103,11 +103,14 @@ private[mesos] object MesosClusterDispatcher extends Logging {
103
103
}
104
104
val dispatcher = new MesosClusterDispatcher (dispatcherArgs, conf)
105
105
dispatcher.start()
106
- ShutdownHookManager .addShutdownHook { () =>
107
- logInfo(" Shutdown hook is shutting down dispatcher" )
108
- dispatcher.stop()
109
- dispatcher.awaitShutdown()
106
+ val shutdownHook = new Thread () {
107
+ override def run () {
108
+ logInfo(" Shutdown hook is shutting down dispatcher" )
109
+ dispatcher.stop()
110
+ dispatcher.awaitShutdown()
111
+ }
110
112
}
113
+ Runtime .getRuntime.addShutdownHook(shutdownHook)
111
114
dispatcher.awaitShutdown()
112
115
}
113
116
}
Original file line number Diff line number Diff line change @@ -162,9 +162,7 @@ private[spark] object ShutdownHookManager extends Logging {
162
162
val hook = new Thread {
163
163
override def run () {}
164
164
}
165
- // scalastyle:off runtimeaddshutdownhook
166
165
Runtime .getRuntime.addShutdownHook(hook)
167
- // scalastyle:on runtimeaddshutdownhook
168
166
Runtime .getRuntime.removeShutdownHook(hook)
169
167
} catch {
170
168
case ise : IllegalStateException => return true
@@ -230,9 +228,7 @@ private [util] class SparkShutdownHookManager {
230
228
.invoke(shm, hookTask, Integer .valueOf(fsPriority + 30 ))
231
229
232
230
case Failure (_) =>
233
- // scalastyle:off runtimeaddshutdownhook
234
231
Runtime .getRuntime.addShutdownHook(new Thread (hookTask, " Spark Shutdown Hook" ));
235
- // scalastyle:on runtimeaddshutdownhook
236
232
}
237
233
}
238
234
Original file line number Diff line number Diff line change @@ -157,18 +157,6 @@ This file is divided into 3 sections:
157
157
]]> </customMessage >
158
158
</check >
159
159
160
- <check customId =" runtimeaddshutdownhook" level =" error" class =" org.scalastyle.file.RegexChecker" enabled =" true" >
161
- <parameters ><parameter name =" regex" >Runtime\.getRuntime\.addShutdownHook</parameter ></parameters >
162
- <customMessage ><![CDATA[
163
- Are you sure that you want to use Runtime.getRuntime.addShutdownHook? In most cases, you should use
164
- ShutdownHookManager.addShutdownHook instead.
165
- If you must use Runtime.getRuntime.addShutdownHook, wrap the code block with
166
- // scalastyle:off runtimeaddshutdownhook
167
- Runtime.getRuntime.addShutdownHook(...)
168
- // scalastyle:on runtimeaddshutdownhook
169
- ]]> </customMessage >
170
- </check >
171
-
172
160
<check customId =" classforname" level =" error" class =" org.scalastyle.file.RegexChecker" enabled =" true" >
173
161
<parameters ><parameter name =" regex" >Class\.forName</parameter ></parameters >
174
162
<customMessage ><![CDATA[
You can’t perform that action at this time.
0 commit comments