Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/5563#discussion_r33736409
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/MesosSchedulerUtils.scala
---
@@ -86,10 +88,138 @@ private[mesos] trait MesosSchedulerUtils extends
Logging {
/**
* Get the amount of resources for the specified type from the resource
list
*/
- protected def getResource(res: List[Resource], name: String): Double = {
+ protected def getResource(res: JList[Resource], name: String): Double = {
for (r <- res if r.getName == name) {
return r.getScalar.getValue
}
0.0
}
+
+ /** Helper method to get the key,value-set pair for a Mesos Attribute
protobuf */
+ def getAttribute(attr: Attribute): (String, Set[String]) =
+ (attr.getName, attr.getText.getValue.split(',').toSet)
+
+ /** Build a Mesos resource protobuf object */
+ def createResource(resourceName: String, quantity: Double):
Protos.Resource = {
+ Resource.newBuilder()
+ .setName(resourceName)
+ .setType(Value.Type.SCALAR)
+ .setScalar(Value.Scalar.newBuilder().setValue(quantity).build())
+ .build()
+ }
+
+ /**
+ * Converts the attributes from the resource offer into a Map of name ->
Attribute Value
+ * The attribute values are the mesos attribute types and they are
+ * @param offerAttributes
+ * @return
+ */
+ def toAttributeMap(offerAttributes: JList[Attribute]): Map[String,
GeneratedMessage] =
--- End diff --
how many of these helper methods you added can be protected? It's best to
tighten the visibility as much as possible.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]