-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-6979][Streaming] Replace JobScheduler.eventActor and JobGenerator.eventActor with EventLoop #5554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
[SPARK-6979][Streaming] Replace JobScheduler.eventActor and JobGenerator.eventActor with EventLoop #5554
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce0fa73
Replace JobScheduler.eventActor with EventLoop
zsxwing ec6ec58
Fix the import order
zsxwing e496ace
Replace JobGenerator.eventActor with EventLoop
zsxwing 633e279
Fix NotSerializableException
zsxwing e9d3479
Add blank lines
zsxwing 5304350
Fix NotSerializableException
zsxwing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,15 @@ | |
|
|
||
| package org.apache.spark.streaming.scheduler | ||
|
|
||
| import scala.util.{Failure, Success, Try} | ||
| import scala.collection.JavaConversions._ | ||
| import java.util.concurrent.{TimeUnit, ConcurrentHashMap, Executors} | ||
| import akka.actor.{ActorRef, Actor, Props} | ||
| import org.apache.spark.{SparkException, Logging, SparkEnv} | ||
|
|
||
| import scala.collection.JavaConversions._ | ||
| import scala.util.{Failure, Success} | ||
|
|
||
| import org.apache.spark.Logging | ||
| import org.apache.spark.rdd.PairRDDFunctions | ||
| import org.apache.spark.streaming._ | ||
| import org.apache.spark.util.EventLoop | ||
|
|
||
|
|
||
| private[scheduler] sealed trait JobSchedulerEvent | ||
|
|
@@ -46,20 +48,20 @@ class JobScheduler(val ssc: StreamingContext) extends Logging { | |
| val listenerBus = new StreamingListenerBus() | ||
|
|
||
| // These two are created only when scheduler starts. | ||
| // eventActor not being null means the scheduler has been started and not stopped | ||
| // eventLoop not being null means the scheduler has been started and not stopped | ||
| var receiverTracker: ReceiverTracker = null | ||
| private var eventActor: ActorRef = null | ||
|
|
||
| private var eventLoop: EventLoop[JobSchedulerEvent] = null | ||
|
|
||
| def start(): Unit = synchronized { | ||
| if (eventActor != null) return // scheduler has already been started | ||
| if (eventLoop != null) return // scheduler has already been started | ||
|
|
||
| logDebug("Starting JobScheduler") | ||
| eventActor = ssc.env.actorSystem.actorOf(Props(new Actor { | ||
| override def receive: PartialFunction[Any, Unit] = { | ||
| case event: JobSchedulerEvent => processEvent(event) | ||
| } | ||
| }), "JobScheduler") | ||
| eventLoop = new EventLoop[JobSchedulerEvent]("JobScheduler") { | ||
| override protected def onReceive(event: JobSchedulerEvent): Unit = processEvent(event) | ||
|
|
||
| override protected def onError(e: Throwable): Unit = reportError("Error in job scheduler", e) | ||
| } | ||
| eventLoop.start() | ||
|
|
||
| listenerBus.start(ssc.sparkContext) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank line here |
||
| receiverTracker = new ReceiverTracker(ssc) | ||
|
|
@@ -69,7 +71,7 @@ class JobScheduler(val ssc: StreamingContext) extends Logging { | |
| } | ||
|
|
||
| def stop(processAllReceivedData: Boolean): Unit = synchronized { | ||
| if (eventActor == null) return // scheduler has already been stopped | ||
| if (eventLoop == null) return // scheduler has already been stopped | ||
| logDebug("Stopping JobScheduler") | ||
|
|
||
| // First, stop receiving | ||
|
|
@@ -96,8 +98,8 @@ class JobScheduler(val ssc: StreamingContext) extends Logging { | |
|
|
||
| // Stop everything else | ||
| listenerBus.stop() | ||
| ssc.env.actorSystem.stop(eventActor) | ||
| eventActor = null | ||
| eventLoop.stop() | ||
| eventLoop = null | ||
| logInfo("Stopped JobScheduler") | ||
| } | ||
|
|
||
|
|
@@ -117,7 +119,7 @@ class JobScheduler(val ssc: StreamingContext) extends Logging { | |
| } | ||
|
|
||
| def reportError(msg: String, e: Throwable) { | ||
| eventActor ! ErrorReported(msg, e) | ||
| eventLoop.post(ErrorReported(msg, e)) | ||
| } | ||
|
|
||
| private def processEvent(event: JobSchedulerEvent) { | ||
|
|
@@ -172,14 +174,14 @@ class JobScheduler(val ssc: StreamingContext) extends Logging { | |
|
|
||
| private class JobHandler(job: Job) extends Runnable { | ||
| def run() { | ||
| eventActor ! JobStarted(job) | ||
| eventLoop.post(JobStarted(job)) | ||
| // Disable checks for existing output directories in jobs launched by the streaming scheduler, | ||
| // since we may need to write output to an existing directory during checkpoint recovery; | ||
| // see SPARK-4835 for more details. | ||
| PairRDDFunctions.disableOutputSpecValidation.withValue(true) { | ||
| job.run() | ||
| } | ||
| eventActor ! JobCompleted(job) | ||
| eventLoop.post(JobCompleted(job)) | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a blank line here