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_r304912525
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/deploy/master/WorkerInfo.scala
 ##########
 @@ -89,17 +125,51 @@ 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
+   */
+  def acquireResources(resourceReqs: Seq[ResourceRequirement])
+    : Map[String, ResourceInformation] = {
+    resourceReqs.map { req =>
+      val rName = req.resourceName
+      val amount = req.amount
+      rName -> resources(rName).acquire(amount)
+    }.toMap
+  }
+
+  /**
+   * used during master recovery
+   */
+  def notifyResources(expected: Map[String, ResourceInformation]): Unit = {
 
 Review comment:
   good name ! 

----------------------------------------------------------------
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]

Reply via email to