Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/5907#discussion_r29834015
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala ---
@@ -607,8 +614,27 @@ class StreamingContext private[streaming] (
*/
object StreamingContext extends Logging {
+ /**
+ * Lock that guards access to global variables that track active
StreamingContext.
+ */
+ private val ACTIVATION_LOCK = new Object()
- private[streaming] val DEFAULT_CLEANER_TTL = 3600
+ private var activeContext: AtomicReference[StreamingContext] =
+ new AtomicReference[StreamingContext](null)
+
+ private def assertNoOtherContextIsActive(): Unit = {
+ ACTIVATION_LOCK.synchronized {
+ if (activeContext.get() != null) {
+ throw new SparkException("Only one StreamingContext may be started
in this JVM")
--- End diff --
Well, let me be a little bit more unambiguous in the choice of verbs. We
are allowed to instantiate multiple StreamingContexts provided only one is
started (`ssc.start()`) at a time. That's why I used "started" so that it
directly maps to `ssc.start()`. This is different from `SparkContexts` where it
is started as soon as it is instantiated.
I will add the callsite information.
---
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]