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 sz...@apache.org on 2011/05/24 22:59:51 UTC

svn commit: r1127286 - in /hadoop/common/branches/yahoo-merge: ./ src/contrib/ec2/ src/docs/ src/java/ src/java/org/apache/hadoop/fs/ src/java/org/apache/hadoop/fs/shell/ src/test/core/ src/test/core/org/apache/hadoop/cli/

Author: szetszwo
Date: Tue May 24 20:59:51 2011
New Revision: 1127286

URL: http://svn.apache.org/viewvc?rev=1127286&view=rev
Log:
svn merge -c 1102012 from trunk for HADOOP-7275.

Added:
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Stat.java
      - copied unchanged from r1102012, hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Stat.java
Modified:
    hadoop/common/branches/yahoo-merge/   (props changed)
    hadoop/common/branches/yahoo-merge/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/yahoo-merge/src/contrib/ec2/   (props changed)
    hadoop/common/branches/yahoo-merge/src/docs/   (props changed)
    hadoop/common/branches/yahoo-merge/src/java/   (props changed)
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java
    hadoop/common/branches/yahoo-merge/src/test/core/   (props changed)
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml

Propchange: hadoop/common/branches/yahoo-merge/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 24 20:59:51 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653
+/hadoop/common/trunk:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012
 /hadoop/core/branches/branch-0.19/core:713112

Modified: hadoop/common/branches/yahoo-merge/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/CHANGES.txt?rev=1127286&r1=1127285&r2=1127286&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/CHANGES.txt (original)
+++ hadoop/common/branches/yahoo-merge/CHANGES.txt Tue May 24 20:59:51 2011
@@ -62,6 +62,9 @@ Trunk (unreleased changes)
     HADOOP-7271. Standardize shell command error messages.  (Daryn Sharp
     via szetszwo)
 
+    HADOOP-7275. Refactor the stat commands to conform to new FsCommand
+    class.  (Daryn Sharp via szetszwo)
+
   OPTIMIZATIONS
 
   BUG FIXES

Propchange: hadoop/common/branches/yahoo-merge/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 24 20:59:51 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/CHANGES.txt:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653
+/hadoop/common/trunk/CHANGES.txt:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
 /hadoop/core/trunk/CHANGES.txt:776175-785643,785929-786278

Propchange: hadoop/common/branches/yahoo-merge/src/contrib/ec2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 24 20:59:51 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/contrib/ec2:1043117,1076296,1078148,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653
+/hadoop/common/trunk/src/contrib/ec2:1043117,1076296,1078148,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012
 /hadoop/core/branches/branch-0.19/core/src/contrib/ec2:713112
 /hadoop/core/trunk/src/contrib/ec2:776175-784663

Propchange: hadoop/common/branches/yahoo-merge/src/docs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 24 20:59:51 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk/src/docs:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653
+/hadoop/common/trunk/src/docs:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012
 /hadoop/core/branches/branch-0.19/src/docs:713112

Propchange: hadoop/common/branches/yahoo-merge/src/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 24 20:59:51 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/java:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653
+/hadoop/common/trunk/src/java:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012
 /hadoop/core/branches/branch-0.19/core/src/java:713112
 /hadoop/core/trunk/src/core:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java?rev=1127286&r1=1127285&r2=1127286&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FsShell.java Tue May 24 20:59:51 2011
@@ -25,9 +25,7 @@ import java.net.URI;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
-import java.util.TimeZone;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -61,12 +59,8 @@ public class FsShell extends Configured 
 
   public static final SimpleDateFormat dateForm = 
     new SimpleDateFormat("yyyy-MM-dd HH:mm");
-  protected static final SimpleDateFormat modifFmt =
-    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   static final int BORDER = 2;
-  static {
-    modifFmt.setTimeZone(TimeZone.getTimeZone("UTC"));
-  }
+
   static final String GET_SHORT_USAGE = "-get [-ignoreCrc] [-crc] <src> <localdst>";
   static final String COPYTOLOCAL_SHORT_USAGE = GET_SHORT_USAGE.replace(
       "-get", "-copyToLocal");
@@ -485,62 +479,6 @@ public class FsShell extends Configured 
   }
 
   /**
-   * Print statistics about path in specified format.
-   * Format sequences:
-   *   %b: Size of file in blocks
-   *   %n: Filename
-   *   %o: Block size
-   *   %r: replication
-   *   %y: UTC date as &quot;yyyy-MM-dd HH:mm:ss&quot;
-   *   %Y: Milliseconds since January 1, 1970 UTC
-   */
-  void stat(char[] fmt, String src) throws IOException {
-    Path srcPath = new Path(src);
-    FileSystem srcFs = srcPath.getFileSystem(getConf());
-    FileStatus glob[] = srcFs.globStatus(srcPath);
-    if (null == glob)
-      throw new PathNotFoundException(src);
-    for (FileStatus f : glob) {
-      StringBuilder buf = new StringBuilder();
-      for (int i = 0; i < fmt.length; ++i) {
-        if (fmt[i] != '%') {
-          buf.append(fmt[i]);
-        } else {
-          if (i + 1 == fmt.length) break;
-          switch(fmt[++i]) {
-            case 'b':
-              buf.append(f.getLen());
-              break;
-            case 'F':
-              buf.append(f.isDirectory() ? "directory" 
-                                         : (f.isFile() ? "regular file" : "symlink"));
-              break;
-            case 'n':
-              buf.append(f.getPath().getName());
-              break;
-            case 'o':
-              buf.append(f.getBlockSize());
-              break;
-            case 'r':
-              buf.append(f.getReplication());
-              break;
-            case 'y':
-              buf.append(modifFmt.format(new Date(f.getModificationTime())));
-              break;
-            case 'Y':
-              buf.append(f.getModificationTime());
-              break;
-            default:
-              buf.append(fmt[i]);
-              break;
-          }
-        }
-      }
-      System.out.println(buf.toString());
-    }
-  }
-
-  /**
    * Move files that match the file pattern <i>srcf</i>
    * to a destination file.
    * When moving mutiple files, the destination must be a directory. 
@@ -825,7 +763,7 @@ public class FsShell extends Configured 
       GET_SHORT_USAGE + "\n\t" +
       "[" + COPYTOLOCAL_SHORT_USAGE + "] [-moveToLocal <src> <localdst>]\n\t" +
       "[-report]\n\t" +
-      "[-touchz <path>] [-test -[ezd] <path>] [-stat [format] <path>]";
+      "[-touchz <path>] [-test -[ezd] <path>]";
 
     String conf ="-conf <configuration file>:  Specify an application configuration file.";
  
@@ -905,10 +843,6 @@ public class FsShell extends Configured 
     String test = "-test -[ezd] <path>: If file { exists, has zero length, is a directory\n" +
       "\t\tthen return 0, else return 1.\n";
 
-    String stat = "-stat [format] <path>: Print statistics about the file/directory at <path>\n" +
-      "\t\tin the specified format. Format accepts filesize in blocks (%b), filename (%n),\n" +
-      "\t\tblock size (%o), replication (%r), modification date (%y, %Y)\n";
-    
     String expunge = "-expunge: Empty the Trash.\n";
     
     String help = "-help [cmd]: \tDisplays help for given command or all commands if none\n" +
@@ -957,8 +891,6 @@ public class FsShell extends Configured 
       System.out.println(touchz);
     } else if ("test".equals(cmd)) {
       System.out.println(test);
-    } else if ("stat".equals(cmd)) {
-      System.out.println(stat);
     } else if ("help".equals(cmd)) {
       System.out.println(help);
     } else {
@@ -985,7 +917,6 @@ public class FsShell extends Configured 
       System.out.println(moveToLocal);
       System.out.println(touchz);
       System.out.println(test);
-      System.out.println(stat);
 
       for (String thisCmdName : commandFactory.getNames()) {
         printHelp(commandFactory.getInstance(thisCmdName));
@@ -1099,9 +1030,6 @@ public class FsShell extends Configured 
     } else if ("-test".equals(cmd)) {
       System.err.println("Usage: java FsShell" +
                          " [-test -[ezd] <path>]");
-    } else if ("-stat".equals(cmd)) {
-      System.err.println("Usage: java FsShell" +
-                         " [-stat [format] <path>]");
     } else {
       System.err.println("Usage: java FsShell");
       System.err.println("           [-df [<path>]]");
@@ -1120,7 +1048,6 @@ public class FsShell extends Configured 
       System.err.println("           [-moveToLocal [-crc] <src> <localdst>]");
       System.err.println("           [-touchz <path>]");
       System.err.println("           [-test -[ezd] <path>]");
-      System.err.println("           [-stat [format] <path>]");
       for (String name : commandFactory.getNames()) {
       	instance = commandFactory.getInstance(name);
         System.err.println("           [" + instance.getUsage() + "]");
@@ -1170,7 +1097,7 @@ public class FsShell extends Configured 
         return exitCode;
       }
     } else if ("-rm".equals(cmd) || "-rmr".equals(cmd) ||
-               "-touchz".equals(cmd) || "-stat".equals(cmd)) {
+               "-touchz".equals(cmd)) {
       if (argv.length < 2) {
         printUsage(cmd);
         return exitCode;
@@ -1243,12 +1170,6 @@ public class FsShell extends Configured 
         exitCode = doall(cmd, argv, i);
       } else if ("-test".equals(cmd)) {
         exitCode = test(argv, i);
-      } else if ("-stat".equals(cmd)) {
-        if (i + 1 < argv.length) {
-          stat(argv[i++].toCharArray(), argv[i++]);
-        } else {
-          stat("%y".toCharArray(), argv[i]);
-        }
       } else if ("-help".equals(cmd)) {
         if (i < argv.length) {
           printHelp(argv[i]);

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java?rev=1127286&r1=1127285&r2=1127286&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/FsCommand.java Tue May 24 20:59:51 2011
@@ -50,6 +50,7 @@ abstract public class FsCommand extends 
     factory.registerCommands(Ls.class);
     factory.registerCommands(Mkdir.class);
     factory.registerCommands(SetReplication.class);
+    factory.registerCommands(Stat.class);
     factory.registerCommands(Tail.class);
   }
 

Propchange: hadoop/common/branches/yahoo-merge/src/test/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 24 20:59:51 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/test/core:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653
+/hadoop/common/trunk/src/test/core:1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012
 /hadoop/core/branches/branch-0.19/core/src/test/core:713112
 /hadoop/core/trunk/src/test/core:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml?rev=1127286&r1=1127285&r2=1127286&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml (original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/cli/testConf.xml Tue May 24 20:59:51 2011
@@ -583,7 +583,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>^-stat \[format\] &lt;path&gt;: Print statistics about the file/directory at &lt;path&gt;( )*</expected-output>
+          <expected-output>^-stat \[format\] &lt;path&gt; \.\.\.:( |\t)*Print statistics about the file/directory at &lt;path&gt;( )*</expected-output>
         </comparator>
         <comparator>
           <type>RegexpComparator</type>