felixcheung commented on a change in pull request #24730: [SPARK-27835][Core]
Resource Scheduling: change driver config from addresses
URL: https://github.com/apache/spark/pull/24730#discussion_r288858863
##########
File path: core/src/main/scala/org/apache/spark/ResourceDiscoverer.scala
##########
@@ -132,4 +132,20 @@ private[spark] object ResourceDiscoverer extends Logging {
}
}
}
+
+ def parseAllocatedFromJsonFile(resourcesFile: String): Map[String,
ResourceInformation] = {
+ implicit val formats = DefaultFormats
+ // case class to make json4s parsing easy
+ case class JsonResourceInformation(val name: String, val addresses:
Array[String])
+ val resourceInput = new BufferedInputStream(new
FileInputStream(resourcesFile))
+ val resources = try {
+ parse(resourceInput).extract[Seq[JsonResourceInformation]]
+ } catch {
+ case e@(_: MappingException | _: MismatchedInputException | _:
ClassCastException) =>
+ throw new SparkException(s"Exception parsing the resources in
$resourcesFile", e)
+ } finally {
+ resourceInput.close()
+ }
+ resources.map(r => (r.name, new ResourceInformation(r.name,
r.addresses))).toMap
Review comment:
ah yes ;) I just mean it walking through a `Seq` when the goal is a `Map`
----------------------------------------------------------------
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]