Skip to content

Commit

Permalink
Remove usages of getAMMemory
Browse files Browse the repository at this point in the history
This merges the refator with commit
ed1980f.
  • Loading branch information
andrewor14 committed Sep 16, 2014
1 parent d8e33b6 commit 45ccdea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private[spark] class Client(
: ContainerLaunchContext = {
val containerContext = super.createContainerLaunchContext(newAppResponse)
val capability = Records.newRecord(classOf[Resource])
capability.setMemory(getAMMemory(newAppResponse) + amMemoryOverhead)
capability.setMemory(args.amMemory + amMemoryOverhead)
containerContext.setResource(capability)
containerContext
}
Expand Down Expand Up @@ -116,17 +116,6 @@ private[spark] class Client(
amContainer.setContainerTokens(ByteBuffer.wrap(dob.getData()))
}

/**
* Return the amount of memory for launching the ApplicationMaster container (MB).
* GetNewApplicationResponse#getMinimumResourceCapability does not exist in the stable API.
*/
override def getAMMemory(newAppResponse: GetNewApplicationResponse): Int = {
val minResMemory = newAppResponse.getMinimumResourceCapability().getMemory()
val amMemory = ((args.amMemory / minResMemory) * minResMemory) +
((if ((args.amMemory % minResMemory) == 0) 0 else minResMemory) - amMemoryOverhead)
amMemory
}

/**
* Return the security token used by this client to communicate with the ApplicationMaster.
* If no security is enabled, the token returned by the report is null.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private[spark] trait ClientBase extends Logging {
throw new IllegalArgumentException(s"Required executor memory ($executorMem MB) " +
s"is above the max threshold ($maxMem MB) of this cluster!")
}
val amMem = getAMMemory(newAppResponse) + amMemoryOverhead
val amMem = args.amMemory + amMemoryOverhead
if (amMem > maxMem) {
throw new IllegalArgumentException(s"Required AM memory ($amMem MB) " +
s"is above the max threshold ($maxMem MB) of this cluster!")
Expand Down Expand Up @@ -306,7 +306,7 @@ private[spark] trait ClientBase extends Logging {
val javaOpts = ListBuffer[String]()

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

val tmpDir = new Path(Environment.PWD.$(), YarnConfiguration.DEFAULT_CONTAINER_TEMP_DIR)
javaOpts += "-Djava.io.tmpdir=" + tmpDir
Expand Down Expand Up @@ -476,9 +476,6 @@ private[spark] trait ClientBase extends Logging {
* If no security is enabled, the token returned by the report is null.
*/
protected def getClientToken(report: ApplicationReport): String

/** Return the amount of memory for launching the ApplicationMaster container (MB). */
protected def getAMMemory(newAppResponse: GetNewApplicationResponse): Int = args.amMemory
}

private[spark] object ClientBase extends Logging {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ class ClientBaseSuite extends FunSuite with Matchers {
val hadoopConf: Configuration,
val sparkConf: SparkConf,
val yarnConf: YarnConfiguration) extends ClientBase {
override def getAMMemory(newApp: GetNewApplicationResponse): Int = ???
override def setupSecurityToken(amContainer: ContainerLaunchContext): Unit = ???
override def submitApplication(): ApplicationId = ???
override def getApplicationReport(appId: ApplicationId): ApplicationReport = ???
Expand Down

0 comments on commit 45ccdea

Please sign in to comment.