YARN-377. Use the new StringUtils methods added by HADOOP-9252 and fix TestContainersMonitor. Contributed by Chris Nauroth

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1443796 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2013-02-07 23:53:49 +00:00
parent 7114a61318
commit a63d50f79a
3 changed files with 14 additions and 11 deletions

View File

@ -32,6 +32,9 @@ Release 2.0.4-beta - UNRELEASED
YARN-385. Add missing fields - location and #containers to YARN-385. Add missing fields - location and #containers to
ResourceRequestPBImpl's toString(). (Sandy Ryza via sseth) ResourceRequestPBImpl's toString(). (Sandy Ryza via sseth)
YARN-377. Use the new StringUtils methods added by HADOOP-9252 and fix
TestContainersMonitor. (Chris Nauroth via szetszwo)
Release 2.0.3-alpha - 2013-02-06 Release 2.0.3-alpha - 2013-02-06
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -28,7 +28,7 @@
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.AsyncDispatcher; import org.apache.hadoop.yarn.event.AsyncDispatcher;
@ -125,10 +125,10 @@ public synchronized void init(Configuration conf) {
this.maxPmemAllottedForContainers > this.maxPmemAllottedForContainers >
totalPhysicalMemoryOnNM * 0.80f) { totalPhysicalMemoryOnNM * 0.80f) {
LOG.warn("NodeManager configured with " + LOG.warn("NodeManager configured with " +
StringUtils.humanReadableInt(maxPmemAllottedForContainers) + TraditionalBinaryPrefix.long2String(maxPmemAllottedForContainers, "", 1) +
" physical memory allocated to containers, which is more than " + " physical memory allocated to containers, which is more than " +
"80% of the total physical memory available (" + "80% of the total physical memory available (" +
StringUtils.humanReadableInt(totalPhysicalMemoryOnNM) + TraditionalBinaryPrefix.long2String(totalPhysicalMemoryOnNM, "", 1) +
"). Thrashing might happen."); "). Thrashing might happen.");
} }
@ -493,12 +493,12 @@ private String formatErrorMessage(String memTypeExceeded,
private String formatUsageString(long currentVmemUsage, long vmemLimit, private String formatUsageString(long currentVmemUsage, long vmemLimit,
long currentPmemUsage, long pmemLimit) { long currentPmemUsage, long pmemLimit) {
return String.format("%sb of %sb physical memory used; " + return String.format("%sB of %sB physical memory used; " +
"%sb of %sb virtual memory used", "%sB of %sB virtual memory used",
StringUtils.humanReadableInt(currentPmemUsage), TraditionalBinaryPrefix.long2String(currentPmemUsage, "", 1),
StringUtils.humanReadableInt(pmemLimit), TraditionalBinaryPrefix.long2String(pmemLimit, "", 1),
StringUtils.humanReadableInt(currentVmemUsage), TraditionalBinaryPrefix.long2String(currentVmemUsage, "", 1),
StringUtils.humanReadableInt(vmemLimit)); TraditionalBinaryPrefix.long2String(vmemLimit, "", 1));
} }
} }

View File

@ -267,8 +267,8 @@ public void testContainerKillOnMemoryOverflow() throws IOException,
String expectedMsgPattern = String expectedMsgPattern =
"Container \\[pid=" + pid + ",containerID=" + cId "Container \\[pid=" + pid + ",containerID=" + cId
+ "\\] is running beyond virtual memory limits. Current usage: " + "\\] is running beyond virtual memory limits. Current usage: "
+ "[0-9.]+m?b of [0-9.]+m?b physical memory used; " + "[0-9.]+ ?[KMGTPE]?B of [0-9.]+ ?[KMGTPE]?B physical memory used; "
+ "[0-9.]+m?b of [0-9.]+m?b virtual memory used. " + "[0-9.]+ ?[KMGTPE]?B of [0-9.]+ ?[KMGTPE]?B virtual memory used. "
+ "Killing container.\nDump of the process-tree for " + "Killing container.\nDump of the process-tree for "
+ cId + " :\n"; + cId + " :\n";
Pattern pat = Pattern.compile(expectedMsgPattern); Pattern pat = Pattern.compile(expectedMsgPattern);