From 7bc6040ebb24130d0888847e1d1f5ae3893506d1 Mon Sep 17 00:00:00 2001 From: Siddharth Seth Date: Wed, 13 Feb 2013 19:40:36 +0000 Subject: [PATCH] YARN-391. Formatting fixes for LCEResourceHandler classes. Contributed by Steve Loughran) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1445882 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 ++ .../util/CgroupsLCEResourcesHandler.java | 32 +++++++++---------- .../util/DefaultLCEResourcesHandler.java | 4 +-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 957aaf5454..ee2161c007 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -35,6 +35,9 @@ Release 2.0.4-beta - UNRELEASED YARN-377. Use the new StringUtils methods added by HADOOP-9252 and fix TestContainersMonitor. (Chris Nauroth via szetszwo) + YARN-391. Formatting fixes for LCEResourceHandler classes. + (Steve Loughran via sseth) + Release 2.0.3-alpha - 2013-02-06 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/CgroupsLCEResourcesHandler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/CgroupsLCEResourcesHandler.java index 53a01ebdde..5bcd34f951 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/CgroupsLCEResourcesHandler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/CgroupsLCEResourcesHandler.java @@ -80,17 +80,17 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { NM_LINUX_CONTAINER_CGROUPS_MOUNT, false); this.cgroupMountPath = conf.get(YarnConfiguration. NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH, null); - + // remove extra /'s at end or start of cgroupPrefix if (cgroupPrefix.charAt(0) == '/') { - cgroupPrefix = cgroupPrefix.substring(1); + cgroupPrefix = cgroupPrefix.substring(1); } int len = cgroupPrefix.length(); if (cgroupPrefix.charAt(len - 1) == '/') { - cgroupPrefix = cgroupPrefix.substring(0, len - 1); + cgroupPrefix = cgroupPrefix.substring(0, len - 1); } - + // mount cgroups if requested if (cgroupMount && cgroupMountPath != null) { ArrayList cgroupKVs = new ArrayList(); @@ -98,14 +98,14 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { CONTROLLER_CPU); lce.mountCgroups(cgroupKVs, cgroupPrefix); } - + initializeControllerPaths(); } boolean isCpuWeightEnabled() { return this.cpuWeightEnabled; - } + } /* * Next four functions are for an individual cgroup. @@ -155,7 +155,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { } } } - } + } private void deleteCgroup(String controller, String groupName) { String path = pathForCgroup(controller, groupName); @@ -165,7 +165,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { if (! new File(path).delete()) { LOG.warn("Unable to delete cgroup at: " + path); } - } + } /* * Next three functions operate on all the resources we are enforcing. @@ -178,7 +178,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { private void setupLimits(ContainerId containerId, Resource containerResource) throws IOException { String containerName = containerId.toString(); - + if (isCpuWeightEnabled()) { createCgroup(CONTROLLER_CPU, containerName); updateCgroup(CONTROLLER_CPU, containerName, "shares", @@ -202,7 +202,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { if (isCpuWeightEnabled()) { deleteCgroup(CONTROLLER_CPU, containerName); - } + } } /* @@ -222,7 +222,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { String containerName = containerId.toString(); StringBuilder sb = new StringBuilder("cgroups="); - + if (isCpuWeightEnabled()) { sb.append(pathForCgroup(CONTROLLER_CPU, containerName) + "/cgroup.procs"); sb.append(","); @@ -231,7 +231,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { if (sb.charAt(sb.length() - 1) == ',') { sb.deleteCharAt(sb.length() - 1); } - + return sb.toString(); } @@ -255,8 +255,8 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { BufferedReader in = null; try { - in = new BufferedReader(new FileReader(new File(MTAB_FILE))); - + in = new BufferedReader(new FileReader(new File(MTAB_FILE))); + for (String str = in.readLine(); str != null; str = in.readLine()) { Matcher m = MTAB_FILE_FORMAT.matcher(str); @@ -316,6 +316,6 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler { } else { throw new IOException("Not able to enforce cpu weights; cannot find " + "cgroup for cpu controller in " + MTAB_FILE); - } + } } -} \ No newline at end of file +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/DefaultLCEResourcesHandler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/DefaultLCEResourcesHandler.java index fcb166ffbf..9fb87074e2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/DefaultLCEResourcesHandler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/util/DefaultLCEResourcesHandler.java @@ -33,7 +33,7 @@ public class DefaultLCEResourcesHandler implements LCEResourcesHandler { private Configuration conf; public DefaultLCEResourcesHandler() { - } + } public void setConf(Configuration conf) { this.conf = conf; @@ -42,7 +42,7 @@ public class DefaultLCEResourcesHandler implements LCEResourcesHandler { @Override public Configuration getConf() { return conf; - } + } public void init(LinuxContainerExecutor lce) { }