Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.util.Properties
import java.util.concurrent.{ConcurrentHashMap, TimeUnit}

import scala.collection.JavaConverters._
import scala.collection.mutable.HashSet
import scala.util.Failure

import org.apache.commons.lang.SerializationUtils
Expand Down Expand Up @@ -64,6 +65,8 @@ class JobScheduler(val ssc: StreamingContext) extends Logging {

private var eventLoop: EventLoop[JobSchedulerEvent] = null

private val inputInfoMissedTimes = HashSet[Time]()

def start(): Unit = synchronized {
if (eventLoop != null) return // scheduler has already been started

Expand Down Expand Up @@ -139,6 +142,7 @@ class JobScheduler(val ssc: StreamingContext) extends Logging {
def submitJobSet(jobSet: JobSet) {
if (jobSet.jobs.isEmpty) {
logInfo("No jobs added for time " + jobSet.time)
inputInfoMissedTimes.add(jobSet.time)
} else {
listenerBus.post(StreamingListenerBatchSubmitted(jobSet.toBatchInfo))
jobSets.put(jobSet.time, jobSet)
Expand Down Expand Up @@ -193,6 +197,14 @@ class JobScheduler(val ssc: StreamingContext) extends Logging {
listenerBus.post(StreamingListenerOutputOperationCompleted(job.toOutputOperationInfo))
logInfo("Finished job " + job.id + " from job set of time " + jobSet.time)
if (jobSet.hasCompleted) {
// submit fake BatchCompleted event to show missing inputInfo on Streaming UI
inputInfoMissedTimes.foreach (time => {
val streamIdToInputInfos = inputInfoTracker.getInfo(time)
val fakeJobSet = JobSet(time, Seq(), streamIdToInputInfos)
listenerBus.post(StreamingListenerBatchCompleted(fakeJobSet.toBatchInfo))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change the semantics if posing fake StreamingListenerBatchCompleted, if user's code rely on this, will this break their assumptions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it would be a breaking change in that case. Give the fact that some information is indeed missing now, we need either send more events or add additional fields in current event. The later might be better and more correct in semantics, although it can still break current implementation of user's custom listener. And I noticed that listener interface is annotated as DeveloperAPI, so it's expected that API might be changed. How do you think?

})
inputInfoMissedTimes.clear()

jobSets.remove(jobSet.time)
jobGenerator.onBatchCompletion(jobSet.time)
logInfo("Total delay: %.3f s for time %s (execution: %.3f s)".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ case class JobSet(

def hasStarted: Boolean = processingStartTime > 0

def hasCompleted: Boolean = incompleteJobs.isEmpty
def hasCompleted: Boolean = incompleteJobs.isEmpty && processingStartTime >= 0

// Time taken to process all the jobs from the time they started processing
// (i.e. not including the time they wait in the streaming scheduler queue)
Expand Down