Github user nishkamravi2 commented on a diff in the pull request:
https://github.com/apache/spark/pull/6607#discussion_r32812244
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/scheduler/ReceiverTracker.scala
---
@@ -308,12 +336,25 @@ class ReceiverTracker(ssc: StreamingContext,
skipReceiverLaunch: Boolean = false
supervisor.start()
supervisor.awaitTermination()
}
+
// Run the dummy Spark job to ensure that all slaves have registered.
// This avoids all the receivers to be scheduled on the same node.
if (!ssc.sparkContext.isLocal) {
ssc.sparkContext.makeRDD(1 to 50, 50).map(x => (x,
1)).reduceByKey(_ + _, 20).collect()
}
+ // Get the list of executors and schedule receivers
+ val executors = getExecutors(ssc)
+ val locations = scheduleReceivers(receivers, executors)
+ val tempRDD =
+ if (locations(0) != null) {
--- End diff --
Generally speaking, what if there were numerous conditions for which
locations(0) could be null, would you enlist them all? It's common practice to
do: Obj x = f(); if (x) {do blah}. If we don't want a check on locations(0),
the right way would be to return null (or some such) from scheduleReceiver when
locations(0) is null. So we can check if(locations) instead of
if(locations(0)). Better still, we can check for if(!executors.isEmpty) before
invoking scheduleReceiver, so no further check is needed.
---
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]