Skip to content

Commit 2c9ea1a

Browse files
logarithmXinyu Liu
authored andcommitted
SAMZA-1014: Add property to set YARN AM cpu cores
1 parent 9b0861f commit 2c9ea1a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

samza-yarn/src/main/java/org/apache/samza/config/YarnConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public class YarnConfig extends MapConfig {
8585
*/
8686
public static final String AM_CONTAINER_LABEL = "yarn.am.container.label";
8787

88+
/**
89+
* Number of CPU cores to request from YARN for running the AM
90+
*/
91+
public static final String AM_CONTAINER_MAX_CPU_CORES = "yarn.am.container.cpu.cores";
92+
private static final int DEFAULT_AM_CPU_CORES = 1;
93+
8894
/**
8995
* Determines the interval for the Heartbeat between the AM and the Yarn RM
9096
*/
@@ -188,6 +194,10 @@ public String getAMContainerLabel() {
188194
return get(AM_CONTAINER_LABEL, null);
189195
}
190196

197+
public int getAMContainerMaxCpuCores() {
198+
return getInt(AM_CONTAINER_MAX_CPU_CORES, DEFAULT_AM_CPU_CORES);
199+
}
200+
191201
public String getAmOpts() {
192202
return get(AM_JVM_OPTIONS, "");
193203
}

samza-yarn/src/main/scala/org/apache/samza/job/yarn/ClientHelper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ClientHelper(conf: Configuration) extends Logging {
9292

9393
val packagePath = new Path(yarnConfig.getPackagePath)
9494
val mem = yarnConfig.getAMContainerMaxMemoryMb
95-
val cpu = 1
95+
val cpu = yarnConfig.getAMContainerMaxCpuCores
9696
val queueName = Option(yarnConfig.getQueueName)
9797
val appMasterLabel = Option(yarnConfig.getAMContainerLabel)
9898

0 commit comments

Comments
 (0)