Skip to content

Commit 45ccdea

Browse files
committed
Remove usages of getAMMemory
This merges the refator with commit ed1980f.
1 parent d8e33b6 commit 45ccdea

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

yarn/alpha/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private[spark] class Client(
8888
: ContainerLaunchContext = {
8989
val containerContext = super.createContainerLaunchContext(newAppResponse)
9090
val capability = Records.newRecord(classOf[Resource])
91-
capability.setMemory(getAMMemory(newAppResponse) + amMemoryOverhead)
91+
capability.setMemory(args.amMemory + amMemoryOverhead)
9292
containerContext.setResource(capability)
9393
containerContext
9494
}
@@ -116,17 +116,6 @@ private[spark] class Client(
116116
amContainer.setContainerTokens(ByteBuffer.wrap(dob.getData()))
117117
}
118118

119-
/**
120-
* Return the amount of memory for launching the ApplicationMaster container (MB).
121-
* GetNewApplicationResponse#getMinimumResourceCapability does not exist in the stable API.
122-
*/
123-
override def getAMMemory(newAppResponse: GetNewApplicationResponse): Int = {
124-
val minResMemory = newAppResponse.getMinimumResourceCapability().getMemory()
125-
val amMemory = ((args.amMemory / minResMemory) * minResMemory) +
126-
((if ((args.amMemory % minResMemory) == 0) 0 else minResMemory) - amMemoryOverhead)
127-
amMemory
128-
}
129-
130119
/**
131120
* Return the security token used by this client to communicate with the ApplicationMaster.
132121
* If no security is enabled, the token returned by the report is null.

yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ClientBase.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private[spark] trait ClientBase extends Logging {
6666
throw new IllegalArgumentException(s"Required executor memory ($executorMem MB) " +
6767
s"is above the max threshold ($maxMem MB) of this cluster!")
6868
}
69-
val amMem = getAMMemory(newAppResponse) + amMemoryOverhead
69+
val amMem = args.amMemory + amMemoryOverhead
7070
if (amMem > maxMem) {
7171
throw new IllegalArgumentException(s"Required AM memory ($amMem MB) " +
7272
s"is above the max threshold ($maxMem MB) of this cluster!")
@@ -306,7 +306,7 @@ private[spark] trait ClientBase extends Logging {
306306
val javaOpts = ListBuffer[String]()
307307

308308
// Add Xmx for AM memory
309-
javaOpts += "-Xmx" + getAMMemory(newAppResponse) + "m"
309+
javaOpts += "-Xmx" + args.amMemory + "m"
310310

311311
val tmpDir = new Path(Environment.PWD.$(), YarnConfiguration.DEFAULT_CONTAINER_TEMP_DIR)
312312
javaOpts += "-Djava.io.tmpdir=" + tmpDir
@@ -476,9 +476,6 @@ private[spark] trait ClientBase extends Logging {
476476
* If no security is enabled, the token returned by the report is null.
477477
*/
478478
protected def getClientToken(report: ApplicationReport): String
479-
480-
/** Return the amount of memory for launching the ApplicationMaster container (MB). */
481-
protected def getAMMemory(newAppResponse: GetNewApplicationResponse): Int = args.amMemory
482479
}
483480

484481
private[spark] object ClientBase extends Logging {

yarn/common/src/test/scala/org/apache/spark/deploy/yarn/ClientBaseSuite.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ class ClientBaseSuite extends FunSuite with Matchers {
237237
val hadoopConf: Configuration,
238238
val sparkConf: SparkConf,
239239
val yarnConf: YarnConfiguration) extends ClientBase {
240-
override def getAMMemory(newApp: GetNewApplicationResponse): Int = ???
241240
override def setupSecurityToken(amContainer: ContainerLaunchContext): Unit = ???
242241
override def submitApplication(): ApplicationId = ???
243242
override def getApplicationReport(appId: ApplicationId): ApplicationReport = ???

0 commit comments

Comments
 (0)