From 5f56980127704d3c2877d0d0b5047791c00fdac9 Mon Sep 17 00:00:00 2001 From: jayadevanmurali Date: Sat, 23 Jan 2016 11:48:48 +0000 Subject: [SPARK-11137][STREAMING] Make StreamingContext.stop() exception-safe Make StreamingContext.stop() exception-safe Author: jayadevanmurali Closes #10807 from jayadevanmurali/branch-0.1-SPARK-11137. --- .../org/apache/spark/streaming/StreamingContext.scala | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'streaming/src/main') diff --git a/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala b/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala index ec57c05e3b..32bea88ec6 100644 --- a/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala +++ b/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala @@ -693,12 +693,20 @@ class StreamingContext private[streaming] ( // interrupted. See SPARK-12001 for more details. Because the body of this case can be // executed twice in the case of a partial stop, all methods called here need to be // idempotent. - scheduler.stop(stopGracefully) + Utils.tryLogNonFatalError { + scheduler.stop(stopGracefully) + } // Removing the streamingSource to de-register the metrics on stop() - env.metricsSystem.removeSource(streamingSource) - uiTab.foreach(_.detach()) + Utils.tryLogNonFatalError { + env.metricsSystem.removeSource(streamingSource) + } + Utils.tryLogNonFatalError { + uiTab.foreach(_.detach()) + } StreamingContext.setActiveContext(null) - waiter.notifyStop() + Utils.tryLogNonFatalError { + waiter.notifyStop() + } if (shutdownHookRef != null) { shutdownHookRefToRemove = shutdownHookRef shutdownHookRef = null -- cgit v1.2.3