YARN-7503. Configurable heap size / JVM opts in service AM. Contributed by Jonathan Hung

This commit is contained in:
Jian He 2017-11-16 10:53:55 -08:00
parent 28d0fcbef4
commit 6bf2c30192
3 changed files with 15 additions and 11 deletions

View File

@ -559,7 +559,7 @@ public class ServiceClient extends AppAdminClient implements SliderExitCodes,
Map<String, String> env = addAMEnv();
// create AM CLI
String cmdStr = buildCommandLine(serviceName, conf, appRootDir, hasAMLog4j);
String cmdStr = buildCommandLine(app, conf, appRootDir, hasAMLog4j);
submissionContext.setResource(Resource.newInstance(YarnServiceConf
.getLong(YarnServiceConf.AM_RESOURCE_MEM,
YarnServiceConf.DEFAULT_KEY_AM_RESOURCE_MEM, app.getConfiguration(),
@ -624,12 +624,12 @@ public class ServiceClient extends AppAdminClient implements SliderExitCodes,
LOG.debug(builder.toString());
}
private String buildCommandLine(String serviceName, Configuration conf,
private String buildCommandLine(Service app, Configuration conf,
Path appRootDir, boolean hasSliderAMLog4j) throws BadConfigException {
JavaCommandLineBuilder CLI = new JavaCommandLineBuilder();
CLI.forceIPv4().headless();
//TODO CLI.setJVMHeap
//TODO CLI.addJVMOPTS
CLI.setJVMOpts(YarnServiceConf.get(YarnServiceConf.JVM_OPTS, null,
app.getConfiguration(), conf));
if (hasSliderAMLog4j) {
CLI.sysprop(SYSPROP_LOG4J_CONFIGURATION, YARN_SERVICE_LOG4J_FILENAME);
CLI.sysprop(SYSPROP_LOG_DIR, ApplicationConstants.LOG_DIR_EXPANSION_VAR);
@ -637,7 +637,7 @@ public class ServiceClient extends AppAdminClient implements SliderExitCodes,
CLI.add(ServiceMaster.class.getCanonicalName());
//TODO debugAM CLI.add(Arguments.ARG_DEBUG)
CLI.add("-" + ServiceMaster.YARNFILE_OPTION, new Path(appRootDir,
serviceName + ".json"));
app.getName() + ".json"));
// pass the registry binding
CLI.addConfOptionToCLI(conf, RegistryConstants.KEY_REGISTRY_ZK_ROOT,
RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT);

View File

@ -85,6 +85,11 @@ public class YarnServiceConf {
public static final String READINESS_CHECK_INTERVAL = "yarn.service.readiness-check-interval.seconds";
public static final int DEFAULT_READINESS_CHECK_INTERVAL = 30; // seconds
/**
* JVM opts.
*/
public static final String JVM_OPTS = "yarn.service.am.java.opts";
/**
* Get long value for the property. First get from the userConf, if not
* present, get from systemConf.

View File

@ -48,13 +48,12 @@ public class JavaCommandLineBuilder extends CommandLineBuilder {
}
/**
* Set the size of the heap if a non-empty heap is passed in.
* @param heap empty string or something like "128M" ,"1G" etc. The value is
* trimmed.
* Set JVM opts.
* @param jvmOpts JVM opts
*/
public void setJVMHeap(String heap) {
if (ServiceUtils.isSet(heap)) {
add("-Xmx" + heap.trim());
public void setJVMOpts(String jvmOpts) {
if (ServiceUtils.isSet(jvmOpts)) {
add(jvmOpts);
}
}