@@ -31,12 +31,15 @@ final private[streaming] class DStreamGraph extends Serializable with Logging {
3131 private val inputStreams = new ArrayBuffer [InputDStream [_]]()
3232 private val outputStreams = new ArrayBuffer [DStream [_]]()
3333
34+ val inputStreamNameAndID = new ArrayBuffer [(String , Int )]()
35+
3436 var rememberDuration : Duration = null
3537 var checkpointInProgress = false
3638
3739 var zeroTime : Time = null
3840 var startTime : Time = null
3941 var batchDuration : Duration = null
42+ var numReceivers : Int = 0
4043
4144 def start (time : Time ) {
4245 this .synchronized {
@@ -45,7 +48,9 @@ final private[streaming] class DStreamGraph extends Serializable with Logging {
4548 startTime = time
4649 outputStreams.foreach(_.initialize(zeroTime))
4750 outputStreams.foreach(_.remember(rememberDuration))
48- outputStreams.foreach(_.validateAtStart)
51+ outputStreams.foreach(_.validateAtStart())
52+ numReceivers = inputStreams.count(_.isInstanceOf [ReceiverInputDStream [_]])
53+ inputStreams.foreach(is => inputStreamNameAndID.+= ((is.name, is.id)))
4954 inputStreams.par.foreach(_.start())
5055 }
5156 }
@@ -106,16 +111,18 @@ final private[streaming] class DStreamGraph extends Serializable with Logging {
106111 .toArray
107112 }
108113
109- def getInputStreamName ( streamId : Int ) : Option [ String ] = synchronized {
110- inputStreams.find(_.id == streamId).map(_.name)
111- }
114+ def getReceiverNumber : Int = numReceivers
115+
116+ def getInputStreamNameAndID : ArrayBuffer [( String , Int )] = inputStreamNameAndID
112117
113118 def generateJobs (time : Time ): Seq [Job ] = {
114119 logDebug(" Generating jobs for time " + time)
115- val jobs = getOutputStreams().flatMap { outputStream =>
116- val jobOption = outputStream.generateJob(time)
117- jobOption.foreach(_.setCallSite(outputStream.creationSite))
118- jobOption
120+ val jobs = this .synchronized {
121+ outputStreams.flatMap { outputStream =>
122+ val jobOption = outputStream.generateJob(time)
123+ jobOption.foreach(_.setCallSite(outputStream.creationSite))
124+ jobOption
125+ }
119126 }
120127 logDebug(" Generated " + jobs.length + " jobs for time " + time)
121128 jobs
0 commit comments