dongjoon-hyun commented on a change in pull request #25409: 
[SPARK-28414][WEBUI] UI updates to show resource info in Standalone
URL: https://github.com/apache/spark/pull/25409#discussion_r312747437
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/deploy/master/ui/MasterPage.scala
 ##########
 @@ -67,24 +69,51 @@ private[ui] class MasterPage(parent: MasterWebUI) extends 
WebUIPage("") {
     }
   }
 
+  private def formatWorkerResources(worker: WorkerInfo): String = {
+    if (worker.resources.isEmpty) return "None"
+    val infoUsed = worker.resourcesInfoUsed
+    val infoFree = worker.resourcesInfoFree
+    infoUsed.map { case (rName, rInfo) =>
+      val used = rInfo.addresses.mkString("[", ", ", "]")
+      val free = infoFree(rName).addresses.mkString("[", ", ", "]")
+      s"$rName: Free: $free / Used: $used"
+    }.mkString(", ")
+  }
+
+  private def formatMasterResourcesInUse(aliveWorkers: Array[WorkerInfo]): 
String = {
+    val totalInfo = aliveWorkers.map(_.resourcesInfo)
+      .flatMap(_.toIterator)
+      .groupBy(_._1) // group by resource name
+      .map { case (rName, rInfoArr) =>
+        rName -> rInfoArr.map(_._2).reduce(_ + _)
+      }
+    val usedInfo = aliveWorkers.map(_.resourcesInfoUsed)
+      .flatMap(_.toIterator)
+      .groupBy(_._1) // group by resource name
+      .map { case (rName, rInfoArr) =>
+      rName -> rInfoArr.map(_._2).reduce(_ + _)
+    }
+    if (totalInfo.isEmpty) "None" else formatResourcesUsed(totalInfo, usedInfo)
 
 Review comment:
   Could you use `""` instead of `None`?

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