Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/3160#discussion_r20040695
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala ---
@@ -482,25 +484,30 @@ class StreamingContext private[streaming] (
/**
* Stop the execution of the streams, with option of ensuring all
received data
* has been processed.
- * @param stopSparkContext Stop the associated SparkContext or not
- * @param stopGracefully Stop gracefully by waiting for the processing
of all
+ *
+ * @param stopSparkContext if true, stops the associated SparkContext.
The underlying SparkContext
+ * will be stopped regardless of whether this
StreamingContext has been
+ * started.
+ * @param stopGracefully if true, stops gracefully by waiting for the
processing of all
* received data to be completed
*/
def stop(stopSparkContext: Boolean, stopGracefully: Boolean): Unit =
synchronized {
- // Warn (but not fail) if context is stopped twice,
- // or context is stopped before starting
- if (state == Initialized) {
- logWarning("StreamingContext has not been started yet")
- return
- }
if (state == Stopped) {
logWarning("StreamingContext has already been stopped")
- return
- } // no need to throw an exception as its okay to stop twice
- scheduler.stop(stopGracefully)
- logInfo("StreamingContext stopped successfully")
- waiter.notifyStop()
+ } else {
+ if (state == Initialized) {
--- End diff --
Why is the nested if necessary? Why not
if (state == Stopped) { ... } else if (state == Initialized) { ... } else
{ ... }
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]