From fcf44394a06fa6498d0f88d7b0daca69fa015888 Mon Sep 17 00:00:00 2001 From: Amar Kamat Date: Tue, 8 Nov 2011 04:48:57 +0000 Subject: [PATCH] MAPREDUCE-3346. [Rumen] LoggedTaskAttempt#getHostName() returns null. (amarrk) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1199106 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 2 ++ .../hadoop/tools/rumen/LoggedTaskAttempt.java | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index bdcdddf2925..28768899f17 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -15,6 +15,8 @@ Release 0.23.1 - Unreleased OPTIMIZATIONS BUG FIXES + MAPREDUCE-3346 [Rumen] LoggedTaskAttempt#getHostName() returns null. + (amarrk) MAPREDUCE-3221. Reenabled the previously ignored test in TestSubmitJob and fixed bugs in it. (Devaraj K via vinodkv) diff --git a/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java b/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java index fde7d0545eb..5437a15003c 100644 --- a/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java +++ b/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java @@ -328,11 +328,27 @@ public class LoggedTaskAttempt implements DeepCompare { return hostName; } - + void setHostName(String hostName) { + this.hostName = hostName; + } + // hostName is saved in the format rackName/NodeName void setHostName(String hostName, String rackName) { - this.hostName = hostName == null || rackName == null ? null - : rackName.intern() + "/" + hostName.intern(); + if (hostName == null || hostName.length() == 0) { + throw new RuntimeException("Invalid entry! Missing hostname"); + } else if (rackName == null || rackName.length() == 0) { + setHostName(hostName); + } else { + // make sure that the rackname is prefixed with a '/' + if (!rackName.startsWith("/")) { + rackName = "/" + rackName; + } + // make sure that the hostname is prefixed with a '/' + if (!hostName.startsWith("/")) { + hostName = "/" + hostName; + } + setHostName(rackName.intern() + hostName.intern()); + } } public long getHdfsBytesRead() {