Skip to content

Commit 576c4a4

Browse files
committed
Merge pull request apache#478 from sryza/sandy-spark-1033
SPARK-1033. Ask for cores in Yarn container requests Tested on a pseudo-distributed cluster against the Fair Scheduler and observed a worker taking more than a single core.
2 parents 5bcfd79 + adf4261 commit 576c4a4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/running-on-yarn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ See [Building Spark with Maven](building-with-maven.html) for instructions on ho
133133

134134
# Important Notes
135135

136-
- We do not requesting container resources based on the number of cores. Thus the numbers of cores given via command line arguments cannot be guaranteed.
136+
- Before Hadoop 2.2, YARN does not support cores in container resource requests. Thus, when running against an earlier version, the numbers of cores given via command line arguments cannot be passed to YARN. Whether core requests are honored in scheduling decisions depends on which scheduler is in use and how it is configured.
137137
- The local directories used for spark will be the local directories configured for YARN (Hadoop Yarn config yarn.nodemanager.local-dirs). If the user specifies spark.local.dir, it will be ignored.
138138
- The --files and --archives options support specifying file names with the # similar to Hadoop. For example you can specify: --files localtest.txt#appSees.txt and this will upload the file you have locally named localtest.txt into HDFS but this will be linked to by the name appSees.txt and your application should use the name as appSees.txt to reference it when running on YARN.
139139
- The --addJars option allows the SparkContext.addJar function to work if you are using it with local files. It does not need to be used if you are using it with HDFS, HTTP, HTTPS, or FTP files.

yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocationHandler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,15 @@ private[yarn] class YarnAllocationHandler(
532532
priority: Int
533533
): ArrayBuffer[ContainerRequest] = {
534534

535-
val memoryResource = Records.newRecord(classOf[Resource])
536-
memoryResource.setMemory(workerMemory + YarnAllocationHandler.MEMORY_OVERHEAD)
535+
val memoryRequest = workerMemory + YarnAllocationHandler.MEMORY_OVERHEAD
536+
val resource = Resource.newInstance(memoryRequest, workerCores)
537537

538538
val prioritySetting = Records.newRecord(classOf[Priority])
539539
prioritySetting.setPriority(priority)
540540

541541
val requests = new ArrayBuffer[ContainerRequest]()
542542
for (i <- 0 until numWorkers) {
543-
requests += new ContainerRequest(memoryResource, hosts, racks, prioritySetting)
543+
requests += new ContainerRequest(resource, hosts, racks, prioritySetting)
544544
}
545545
requests
546546
}

0 commit comments

Comments
 (0)