You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by lo...@apache.org on 2008/09/17 03:37:31 UTC

svn commit: r696130 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/tools/DFSck.java

Author: lohit
Date: Tue Sep 16 18:37:31 2008
New Revision: 696130

URL: http://svn.apache.org/viewvc?rev=696130&view=rev
Log:
HADOOP-3911. Add a check to fsck options to make sure -files is not the first option to resolve conflicts with GenericOptionsParser

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/tools/DFSck.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=696130&r1=696129&r2=696130&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Sep 16 18:37:31 2008
@@ -577,6 +577,10 @@
     HADOOP-4139. Optimize Hive multi group-by.
     (Namin Jain via dhruba)
 
+		HADOOP-3911. Add a check to fsck options to make sure -files is not 
+		the first option to resolve conflicts with GenericOptionsParser
+		(lohit)
+
 Release 0.18.1 - 2008-09-17
 
   IMPROVEMENTS

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/tools/DFSck.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/tools/DFSck.java?rev=696130&r1=696129&r2=696130&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/tools/DFSck.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/tools/DFSck.java Tue Sep 16 18:37:31 2008
@@ -74,25 +74,31 @@
   }
   
   /**
+   * Print fsck usage information
+   */
+  static void printUsage() {
+    System.err.println("Usage: DFSck <path> [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]");
+    System.err.println("\t<path>\tstart checking from this path");
+    System.err.println("\t-move\tmove corrupted files to /lost+found");
+    System.err.println("\t-delete\tdelete corrupted files");
+    System.err.println("\t-files\tprint out files being checked");
+    System.err.println("\t-openforwrite\tprint out files opened for write");
+    System.err.println("\t-blocks\tprint out block report");
+    System.err.println("\t-locations\tprint out locations for every block");
+    System.err.println("\t-racks\tprint out network topology for data-node locations");
+    System.err.println("\t\tBy default fsck ignores files opened for write, " +
+                       "use -openforwrite to report such files. They are usually " +
+                       " tagged CORRUPT or HEALTHY depending on their block " +
+                        "allocation status");
+    ToolRunner.printGenericCommandUsage(System.err);
+  }
+  /**
    * @param args
    */
   public int run(String[] args) throws Exception {
     String fsName = getInfoServer();
     if (args.length == 0) {
-      System.err.println("Usage: DFSck <path> [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]");
-      System.err.println("\t<path>\tstart checking from this path");
-      System.err.println("\t-move\tmove corrupted files to /lost+found");
-      System.err.println("\t-delete\tdelete corrupted files");
-      System.err.println("\t-files\tprint out files being checked");
-      System.err.println("\t-openforwrite\tprint out files opened for write");
-      System.err.println("\t-blocks\tprint out block report");
-      System.err.println("\t-locations\tprint out locations for every block");
-      System.err.println("\t-racks\tprint out network topology for data-node locations");
-      System.err.println("\t\tBy default fsck ignores files opened for write, " +
-                         "use -openforwrite to report such files. They are usually " +
-                         " tagged CORRUPT or HEALTHY depending on their block " +
-                          "allocation status");
-      ToolRunner.printGenericCommandUsage(System.err);
+      printUsage();
       return -1;
     }
     StringBuffer url = new StringBuffer("http://"+fsName+"/fsck?path=");
@@ -134,7 +140,13 @@
   }
 
   public static void main(String[] args) throws Exception {
-    int res = ToolRunner.run(new DFSck(new Configuration()), args);
+    // -files option is also used by GenericOptionsParser
+    // Make sure that is not the first argument for fsck
+    int res = -1;
+    if ((args.length == 0 ) || ("-files".equals(args[0]))) 
+      printUsage();
+    else
+      res = ToolRunner.run(new DFSck(new Configuration()), args);
     System.exit(res);
   }
 }