Ngone51 commented on a change in pull request #24856: [SPARK-27823] [CORE] 
Refactor resource handling code
URL: https://github.com/apache/spark/pull/24856#discussion_r293865557
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/resource/ResourceInformation.scala
 ##########
 @@ -35,3 +41,25 @@ class ResourceInformation(
 
   override def toString: String = s"[name: ${name}, addresses: 
${addresses.mkString(",")}]"
 }
+
+private[spark] object ResourceInformation {
+  /**
+   * Parses a JSON string into a [[ResourceInformation]] instance.
+   */
+  def parseJson(json: String): ResourceInformation = {
+    implicit val formats = DefaultFormats
+    try {
+      parse(json).extract[ResourceInformationJson].toResourceInformation
+    } catch {
+      case NonFatal(e) =>
+        throw new SparkException(s"Error parsing JSON into 
ResourceInformation:\n$json\n", e)
 
 Review comment:
   Maybe, given tips of what is right JSON format for user ?

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