From 996a210ab0131606639ba87fd5daab14bf05b35f Mon Sep 17 00:00:00 2001 From: Jian He Date: Mon, 9 May 2016 14:49:10 -0700 Subject: [PATCH] YARN-4778. Support specifying resources for task containers in SLS. Contributed by Wangda Tan --- .../org/apache/hadoop/yarn/sls/SLSRunner.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java index c79233585c..3be8ff1330 100644 --- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java +++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java @@ -64,6 +64,7 @@ import org.apache.hadoop.yarn.sls.scheduler.SchedulerWrapper; import org.apache.hadoop.yarn.sls.scheduler.TaskRunner; import org.apache.hadoop.yarn.sls.utils.SLSUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.apache.log4j.Logger; import org.codehaus.jackson.JsonFactory; import org.codehaus.jackson.map.ObjectMapper; @@ -316,10 +317,25 @@ private void startAMFromSLSTraces(Resource containerResource, long taskFinish = Long.parseLong( jsonTask.get("container.end.ms").toString()); long lifeTime = taskFinish - taskStart; + + // Set memory and vcores from job trace file + Resource res = Resources.clone(containerResource); + if (jsonTask.containsKey("container.memory")) { + int containerMemory = Integer.parseInt( + jsonTask.get("container.memory").toString()); + res.setMemory(containerMemory); + } + + if (jsonTask.containsKey("container.vcores")) { + int containerVCores = Integer.parseInt( + jsonTask.get("container.vcores").toString()); + res.setVirtualCores(containerVCores); + } + int priority = Integer.parseInt( jsonTask.get("container.priority").toString()); String type = jsonTask.get("container.type").toString(); - containerList.add(new ContainerSimulator(containerResource, + containerList.add(new ContainerSimulator(res, lifeTime, hostname, priority, type)); }