Browse Source

HDFS-1307 Add start time, end time and total time taken for FSCK to FSCK report. Contributed by Suresh Srinvias.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@966031 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 15 years ago
parent
commit
dd1c37882b
2 changed files with 13 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 10 1
      src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java

+ 3 - 0
CHANGES.txt

@@ -82,6 +82,9 @@ Trunk (unreleased changes)
     HDFS-1201. The HDFS component for HADOOP-6632. 
     (Kan Zhang & Jitendra Pandey via ddas)
     
+    HDFS-1307 Add start time, end time and total time taken for FSCK to 
+    FSCK report (suresh)
+    
 
   OPTIMIZATIONS
 

+ 10 - 1
src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java

@@ -23,6 +23,7 @@ import java.io.PrintWriter;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -145,7 +146,9 @@ public class NamenodeFsck {
    * Check files on DFS, starting from the indicated path.
    */
   public void fsck() {
+    final long startTime = System.currentTimeMillis();
     try {
+      out.println("Namenode FSCK started at " + new Date());
 
       final HdfsFileStatus file = namenode.getFileInfo(path);
       if (file != null) {
@@ -163,9 +166,13 @@ public class NamenodeFsck {
         out.println(" Number of data-nodes:\t\t" + totalDatanodes);
         out.println(" Number of racks:\t\t" + networktopology.getNumOfRacks());
 
+        out.println("FSCK ended at " + new Date() + " in "
+            + (System.currentTimeMillis() - startTime + " milliseconds"));
+
         // DFSck client scans for the string HEALTHY/CORRUPT to check the status
         // of file system and return appropriate code. Changing the output
-        // string might break testcases.
+        // string might break testcases. Also note this must be the last line 
+        // of the report.
         if (res.isHealthy()) {
           out.print("\n\nThe filesystem under path '" + path + "' " + HEALTHY_STATUS);
         } else {
@@ -179,6 +186,8 @@ public class NamenodeFsck {
     } catch (Exception e) {
       String errMsg = "Fsck on path '" + path + "' " + FAILURE_STATUS;
       LOG.warn(errMsg, e);
+      out.println("FSCK ended at " + new Date() + " in "
+          + (System.currentTimeMillis() - startTime + " milliseconds"));
       out.println(e.getMessage());
       out.print("\n\n" + errMsg);
     } finally {