Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
092c631f
Commit
092c631f
authored
12 years ago
by
Charles Reiss
Browse files
Options
Downloads
Patches
Plain Diff
Pull detection of being in a shutdown hook into utility function.
parent
d0588bd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/Utils.scala
+21
-0
21 additions, 0 deletions
core/src/main/scala/spark/Utils.scala
core/src/main/scala/spark/executor/Executor.scala
+2
-14
2 additions, 14 deletions
core/src/main/scala/spark/executor/Executor.scala
with
23 additions
and
14 deletions
core/src/main/scala/spark/Utils.scala
+
21
−
0
View file @
092c631f
...
...
@@ -454,4 +454,25 @@ private object Utils extends Logging {
def
clone
[
T
](
value
:
T
,
serializer
:
SerializerInstance
)
:
T
=
{
serializer
.
deserialize
[
T
](
serializer
.
serialize
(
value
))
}
/**
* Detect whether this thread might be executing a shutdown hook. Will always return true if
* the current thread is a running a shutdown hook but may spuriously return true otherwise (e.g.
* if System.exit was just called by a concurrent thread).
*
* Currently, this detects whether the JVM is shutting down by Runtime#addShutdownHook throwing
* an IllegalStateException.
*/
def
inShutdown
()
:
Boolean
=
{
try
{
val
hook
=
new
Thread
{
override
def
run
()
{}
}
Runtime
.
getRuntime
.
addShutdownHook
(
hook
)
Runtime
.
getRuntime
.
removeShutdownHook
(
hook
)
}
catch
{
case
ise
:
IllegalStateException
=>
return
true
}
return
false
}
}
This diff is collapsed.
Click to expand it.
core/src/main/scala/spark/executor/Executor.scala
+
2
−
14
View file @
092c631f
...
...
@@ -52,20 +52,8 @@ private[spark] class Executor extends Logging {
logError
(
"Uncaught exception in thread "
+
thread
,
exception
)
// We may have been called from a shutdown hook. If so, we must not call System.exit().
// (If we do, we will deadlock.) Runtime#addShutdownHook should fail if we are shutting
// down, which would either occur if we were called from a shutdown hook or if
// a System.exit() occured concurrently.
var
shuttingDown
=
false
try
{
val
hook
=
new
Thread
{
override
def
run
()
{}
}
Runtime
.
getRuntime
.
addShutdownHook
(
hook
)
Runtime
.
getRuntime
.
removeShutdownHook
(
hook
)
}
catch
{
case
ise
:
IllegalStateException
=>
shuttingDown
=
true
}
if
(!
shuttingDown
)
{
// (If we do, we will deadlock.)
if
(!
Utils
.
inShutdown
())
{
if
(
exception
.
isInstanceOf
[
OutOfMemoryError
])
{
System
.
exit
(
ExecutorExitCode
.
OOM
)
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment