hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r1026741 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/tools/DFSck.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFsck.java
Date Sun, 24 Oct 2010 05:39:07 GMT
Author: dhruba
Date: Sun Oct 24 05:39:07 2010
New Revision: 1026741

URL: http://svn.apache.org/viewvc?rev=1026741&view=rev
Log:
HDFS-1472. Allow programmatic access to fsck output.
(Ramkumar Vadali via dhruba)


Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFsck.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1026741&r1=1026740&r2=1026741&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Sun Oct 24 05:39:07 2010
@@ -148,6 +148,9 @@ Trunk (unreleased changes)
     HDFS-1456. Provide builder for constructing instances of MiniDFSCluster.
     (jghoman)
 
+    HDFS-1472. Allow programmatic access to fsck output.
+    (Ramkumar Vadali via dhruba)
+
   OPTIMIZATIONS
 
     HDFS-1140. Speedup INode.getPathComponents. (Dmytro Molkov via shv)

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java?rev=1026741&r1=1026740&r2=1026741&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/tools/DFSck.java Sun Oct 24 05:39:07
2010
@@ -21,6 +21,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.PrintStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
@@ -70,14 +71,20 @@ public class DFSck extends Configured im
   }
 
   private final UserGroupInformation ugi;
+  private final PrintStream out;
 
   /**
    * Filesystem checker.
    * @param conf current Configuration
    */
   public DFSck(Configuration conf) throws IOException {
+    this(conf, System.out);
+  }
+
+  public DFSck(Configuration conf, PrintStream out) throws IOException {
     super(conf);
     this.ugi = UserGroupInformation.getCurrentUser();
+    this.out = out;
   }
 
   /**
@@ -163,10 +170,10 @@ public class DFSck extends Configured im
             continue;
           numCorrupt++;
           if (numCorrupt == 1) {
-            System.out.println("The list of corrupt files under path '" 
+            out.println("The list of corrupt files under path '" 
                 + dir + "' are:");
           }
-          System.out.println(line);
+          out.println(line);
           try {
             // Get the block # that we need to send in next call
             lastBlock = line.split("\t")[0];
@@ -179,7 +186,7 @@ public class DFSck extends Configured im
         input.close();
       }
     }
-    System.out.println("The filesystem under path '" + dir + "' has " 
+    out.println("The filesystem under path '" + dir + "' has " 
         + numCorrupt + " CORRUPT files");
     if (numCorrupt == 0)
       errCode = 0;
@@ -231,7 +238,7 @@ public class DFSck extends Configured im
     int errCode = -1;
     try {
       while ((line = input.readLine()) != null) {
-        System.out.println(line);
+        out.println(line);
         lastLine = line;
       }
     } finally {

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFsck.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFsck.java?rev=1026741&r1=1026740&r2=1026741&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFsck.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFsck.java Sun
Oct 24 05:39:07 2010
@@ -73,16 +73,13 @@ public class TestFsck extends TestCase {
   static String runFsck(Configuration conf, int expectedErrCode, 
                         boolean checkErrorCode,String... path) 
                         throws Exception {
-    PrintStream oldOut = System.out;
     ByteArrayOutputStream bStream = new ByteArrayOutputStream();
-    PrintStream newOut = new PrintStream(bStream, true);
-    System.setOut(newOut);
+    PrintStream out = new PrintStream(bStream, true);
     ((Log4JLogger)FSPermissionChecker.LOG).getLogger().setLevel(Level.ALL);
-    int errCode = ToolRunner.run(new DFSck(conf), path);
+    int errCode = ToolRunner.run(new DFSck(conf, out), path);
     if (checkErrorCode)
       assertEquals(expectedErrCode, errCode);
     ((Log4JLogger)FSPermissionChecker.LOG).getLogger().setLevel(Level.INFO);
-    System.setOut(oldOut);
     return bStream.toString();
   }
 



Mime
View raw message