Github user sebastienrainville commented on a diff in the pull request:
https://github.com/apache/spark/pull/1140#discussion_r14165073
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/MesosSchedulerBackend.scala
---
@@ -206,14 +203,13 @@ private[spark] class MesosSchedulerBackend(
val taskLists = scheduler.resourceOffers(offerableWorkers)
// Build a list of Mesos tasks for each slave
- val mesosTasks = offers.map(o =>
Collections.emptyList[MesosTaskInfo]())
+ val mesosTasks = offers.map(o => new JArrayList[MesosTaskInfo]())
for ((taskList, index) <- taskLists.zipWithIndex) {
if (!taskList.isEmpty) {
- val offerNum = offerableIndices(index)
- val slaveId = offers(offerNum).getSlaveId.getValue
- slaveIdsWithExecutors += slaveId
- mesosTasks(offerNum) = new
JArrayList[MesosTaskInfo](taskList.size)
for (taskDesc <- taskList) {
+ val slaveId = taskDesc.executorId
+ val offerNum = offers.indexWhere(_.getSlaveId.getValue ==
slaveId)
--- End diff --
It seems that `executorId` and `slaveId` are synonyms:
```
offerableWorkers += new WorkerOffer(
offer.getSlaveId.getValue,
offer.getHostname,
getResource(offer.getResourcesList, "cpus").toInt)
```
```case class WorkerOffer(executorId: String, host: String, cores: Int)```
For the usage of indexWhere, I would assume that its cost is negligible in
this case, but I will see if I can find a more optimal way to do it.
---
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.
---