-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[Spark-15155][Mesos] Optionally ignore default role resources #12933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -551,12 +551,16 @@ private[spark] class MesosClusterScheduler( | |
currentOffers: List[ResourceOffer], | ||
tasks: mutable.HashMap[OfferID, ArrayBuffer[TaskInfo]]): Unit = { | ||
for (submission <- candidates) { | ||
val acceptedResourceRoles = getAcceptedResourceRoles(submission.schedulerProperties) | ||
val driverCpu = submission.cores | ||
val driverMem = submission.mem | ||
logTrace(s"Finding offer to launch driver with cpu: $driverCpu, mem: $driverMem") | ||
val offerOption = currentOffers.find { o => | ||
getResource(o.resources, "cpus") >= driverCpu && | ||
getResource(o.resources, "mem") >= driverMem | ||
val acceptableResources = o.resources.asScala | ||
.filter((r: Resource) => acceptedResourceRoles(r.getRole)) | ||
.asJava | ||
getResource(acceptableResources, "cpus") >= driverCpu && | ||
getResource(acceptableResources, "mem") >= driverMem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent this continuation 2 spaces to make it clear it's a continuation |
||
} | ||
if (offerOption.isEmpty) { | ||
logDebug(s"Unable to find offer to launch driver id: ${submission.submissionId}, " + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,44 @@ trait MesosSchedulerUtils extends Logging { | |
// Driver for talking to Mesos | ||
protected var mesosDriver: SchedulerDriver = null | ||
|
||
/** | ||
* Returns the configured set of roles that an offer can be selected from | ||
* @param conf Spark configuration | ||
*/ | ||
protected def getAcceptedResourceRoles(conf: SparkConf): Set[String] = { | ||
getAcceptedResourceRoles( | ||
conf.getBoolean("spark.mesos.ignoreDefaultRoleResources", false), | ||
conf.getOption("spark.mesos.role")) | ||
} | ||
/** | ||
* Returns the configured set of roles that an offer can be selected from | ||
* @param props Mesos driver description schedulerProperties map | ||
*/ | ||
protected def getAcceptedResourceRoles(props: Map[String, String]): Set[String] = { | ||
getAcceptedResourceRoles( | ||
props.get("spark.mesos.ignoreDefaultRoleResources") match { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be my taste only but I'm finding this style hard to read. |
||
case Some(truth) => truth.toBoolean | ||
case None => false | ||
}, | ||
props.get("spark.mesos.role")) | ||
} | ||
/** | ||
* Internal version of getAcceptedResourceRoles | ||
* @param ignoreDefaultRoleResources user specified property | ||
* @param role user specified property | ||
*/ | ||
private def getAcceptedResourceRoles( | ||
ignoreDefaultRoleResources: Boolean, | ||
role: Option[String]) = { | ||
val roles = ignoreDefaultRoleResources match { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems more readable:
|
||
case true if role.isDefined => Set(role) | ||
case _ => Set(Some("*"), role) | ||
} | ||
val acceptedRoles = roles.flatten | ||
logDebug(s"Accepting resources from role(s): ${acceptedRoles.mkString(",")}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should move this log outside of this helper method, as there might be other context in the future that's calling this. |
||
acceptedRoles | ||
} | ||
|
||
/** | ||
* Creates a new MesosSchedulerDriver that communicates to the Mesos master. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a style thing, but I think you'd generally just write
(r => acceptedResourceRoles(r.getRole))