HDFS-1954. Improved corrupt files warning on NameNode web UI. Contributed by Patrick Hunt.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@1134424 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 8bb8ef8..f517a64 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -970,6 +970,9 @@
     HDFS-1948  Forward port 'hdfs-1520 lightweight namenode operation to
     trigger lease recovery' (stack)
 
+    HDFS-1954. Improved corrupt files warning on NameNode web UI.
+    (Patrick Hunt via shv)
+
   OPTIMIZATIONS
 
     HDFS-1140. Speedup INode.getPathComponents. (Dmytro Molkov via shv)
diff --git a/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java b/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
index e80ef09..494a2de 100644
--- a/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
+++ b/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
@@ -142,12 +142,25 @@
         + "\n</table></div>";
   }
 
-  static String getWarningText(FSNamesystem fsn) {
-    // Ideally this should be displayed in RED
+  /**
+   * Generate warning text if there are corrupt files.
+   * @return a warning if files are corrupt, otherwise return an empty string.
+   */
+  static String getCorruptFilesWarning(FSNamesystem fsn) {
     long missingBlocks = fsn.getMissingBlocksCount();
     if (missingBlocks > 0) {
-      return "<br> WARNING :" + " There are " + missingBlocks
-          + " missing blocks. Please check the log or run fsck. <br><br>";
+      StringBuilder result = new StringBuilder();
+
+      // Warning class is typically displayed in RED
+      result.append("<br/><a class=\"warning\" href=\"/corrupt_files.jsp\" title=\"List corrupt files\">\n");
+      result.append("<b>WARNING : There are " + missingBlocks
+          + " missing blocks. Please check the logs or run fsck in order to identify the missing blocks.</b>");
+      result.append("</a>");
+
+      result.append("<br/><div class=\"small\">See the Hadoop FAQ for common causes and potential solutions.");
+      result.append("<br/><br/>\n");
+
+      return result.toString();
     }
     return "";
   }
diff --git a/src/webapps/hdfs/dfshealth.jsp b/src/webapps/hdfs/dfshealth.jsp
index 14c1cb9..caa0534 100644
--- a/src/webapps/hdfs/dfshealth.jsp
+++ b/src/webapps/hdfs/dfshealth.jsp
@@ -50,9 +50,7 @@
 <b> <%= NamenodeJspHelper.getSecurityModeText()%> </b>
 <b> <%= NamenodeJspHelper.getSafeModeText(fsn)%> </b>
 <b> <%= NamenodeJspHelper.getInodeLimitText(fsn)%> </b>
-<a class="warning" href="/corrupt_files.jsp" title="List corrupt files">
-  <%= NamenodeJspHelper.getWarningText(fsn)%>
-</a>
+<%= NamenodeJspHelper.getCorruptFilesWarning(fsn)%>
 
 <% healthjsp.generateHealthReport(out, nn, request); %>
 <hr>