You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/08/15 15:12:59 UTC

[GitHub] [spark] tgravescs commented on a change in pull request #25409: [SPARK-28414][WEBUI] UI updates to show resource info in Standalone

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


With regards,
Apache Git Services

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