【发布时间】:2017-03-03 06:22:07
【问题描述】:
我有一个应用程序主机和一个基于代码from the Hadoop documentation 的纱线客户端。目前,yarn 客户端使用与应用程序主服务器相同的内存配置,但我想提供允许用户为应用程序最终运行的容器指定内存需求的功能。
我一直在查看 YarnClient 和 ApplicationSubmissionContext 的 Java 文档,但我仍然对是否可以仅为应用程序的容器设置内存和 vcore 感到困惑。
YarnClient 有代码:
// Set up the container launch context for the application master
ContainerLaunchContext amContainer = ContainerLaunchContext.newInstance(
localResources, env, commands, null, null, null);
// Set up resource type requirements
// For now, both memory and vcores are supported, so we set memory and
// vcores requirements
Resource capability = Resource.newInstance(amMemory, amVCores);
appContext.setResource(capability);
JavaDocs 声明setResource 设置了ApplicationMaster 为此应用程序所需的资源。我认为这意味着我只能在创建 ApplicationSubmissionContext 时为 ApplicationMaster 配置容器。那是对的吗?
如何为将在 YarnClient 中运行应用程序的容器指定 vcore 和内存?
编辑:
我看到YarnClient中也设置了以下内容。这导致更多的问题。资源是否设置了两次?还是代码的一部分设置了应用程序的容器,另一部分设置了应用程序主的容器?
// Set java executable command
LOG.info("Setting up app master command");
vargs.add(Environment.JAVA_HOME.$$() + "/bin/java");
// Set Xmx based on am memory size
vargs.add("-Xmx" + amMemory + "m");
// Set class name
vargs.add(appMasterMainClass);
// Set params for Application Master
vargs.add("--container_memory " + String.valueOf(containerMemory));
vargs.add("--container_vcores " + String.valueOf(containerVirtualCores));
vargs.add("--num_containers " + String.valueOf(numContainers));
vargs.add("--priority " + String.valueOf(shellCmdPriority));
【问题讨论】:
标签: hadoop hadoop-yarn