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

 ##########
 File path: 
core/src/main/scala/org/apache/spark/deploy/StandaloneResourceUtils.scala
 ##########
 @@ -345,4 +345,27 @@ private[spark] object StandaloneResourceUtils extends 
Logging {
   def needCoordinate(conf: SparkConf): Boolean = {
     conf.get(SPARK_RESOURCES_COORDINATE)
   }
+
+  // used for UI
+  def formatResourcesAddresses(resources: Map[String, ResourceInformation]): 
String = {
+    resources.map { case (rName, rInfo) =>
+      s"$rName: ${rInfo.addresses.mkString("[", ", ", "]")}"
+    }.mkString(", ")
+  }
+
+  // used for UI
+  def formatResourcesUsed(
+      resources: Map[String, ResourceInformation],
+      resourcesUsed: Map[String, ResourceInformation]): String = {
+    resources.map { case (rName, rInfo) =>
+      val used = resourcesUsed(rName).addresses.length
+      val total = rInfo.addresses.length
+      s"$used / $total $rName"
+    }.mkString(", ")
+  }
+
+  // used for UI
+  def formatResourceRequirements(requirements: Seq[ResourceRequirement]): 
String = {
+    requirements.map { req => s"${req.amount} 
${req.resourceName}"}.mkString(", ")
 
 Review comment:
   nit just use () and cleanup spacing.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to