Ngone51 commented on a change in pull request #25047: [WIP][SPARK-27371][CORE]
Support GPU-aware resources scheduling in Standalone
URL: https://github.com/apache/spark/pull/25047#discussion_r301596076
##########
File path: core/src/main/scala/org/apache/spark/deploy/master/WorkerInfo.scala
##########
@@ -89,17 +122,52 @@ private[spark] class WorkerInfo(
drivers(driver.id) = driver
memoryUsed += driver.desc.mem
coresUsed += driver.desc.cores
+ driverToResourcesUsed(driver.id) = driver.resources
}
def removeDriver(driver: DriverInfo) {
drivers -= driver.id
memoryUsed -= driver.desc.mem
coresUsed -= driver.desc.cores
+ driverToResourcesUsed.remove(driver.id)
}
def setState(state: WorkerState.Value): Unit = {
this.state = state
}
def isAlive(): Boolean = this.state == WorkerState.ALIVE
+
+ /**
+ * acquire specified amount resources for driver/executor from the worker
+ * @param resourceReqs the resources requirement from driver/executor
+ * @return
+ */
+ def acquireResources(resourceReqs: Map[String, Int])
+ : Map[String, Seq[String]] = {
+ resourceReqs.map { case (rName, amount) =>
+ // TODO (wuyi) rName does not exists ?
+ rName -> resources(rName).acquire(amount)
+ }
+ }
+
+ /**
+ * used during master recovery
+ */
+ def notifyResources(expected: Map[String, Seq[String]]): Unit = {
+ expected.foreach { case (rName, addresses) =>
+ resources(rName).acquire(addresses)
Review comment:
In HA, we persists `WorkInfo` into `persistenceEngine` once a Worker
registered. And at that time, the `WorkerInfo` has no assigned resources but
all free resources. When master recovered, it reads the `WorkInfo` from
`persistenceEngine`, so the `WorkInfo` should still be available for all
resources.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]