hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1126782 - 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/
Date Mon, 23 May 2011 22:13:28 GMT
Author: szetszwo
Date: Mon May 23 22:13:27 2011
New Revision: 1126782

URL: http://svn.apache.org/viewvc?rev=1126782&view=rev
Log:
svn merge -c 1096988 from trunk for HADOOP-7235.

Added:
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Tail.java
      - copied unchanged from r1096988, hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Tail.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/Command.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 Mon May 23 22:13:27 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1100026
+/hadoop/common/trunk:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1100026
 /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=1126782&r1=1126781&r2=1126782&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/CHANGES.txt (original)
+++ hadoop/common/branches/yahoo-merge/CHANGES.txt Mon May 23 22:13:27 2011
@@ -35,6 +35,9 @@ Trunk (unreleased changes)
     HADOOP-7233. Refactor ls to conform to new FsCommand class.  (Daryn Sharp
     via szetszwo)
 
+    HADOOP-7235. Refactor the tail command 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 Mon May 23 22:13:27 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/CHANGES.txt:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1100026
+/hadoop/common/trunk/CHANGES.txt:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1100026
 /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 Mon May 23 22:13:27 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/contrib/ec2:1043117,1078148,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1100026
+/hadoop/common/trunk/src/contrib/ec2:1043117,1078148,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1100026
 /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 Mon May 23 22:13:27 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk/src/docs:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1100026
+/hadoop/common/trunk/src/docs:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1100026
 /hadoop/core/branches/branch-0.19/src/docs:713112

Propchange: hadoop/common/branches/yahoo-merge/src/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 22:13:27 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/java:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1100026
+/hadoop/common/trunk/src/java:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1100026
 /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=1126782&r1=1126781&r2=1126782&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 Mon May
23 22:13:27 2011
@@ -72,7 +72,6 @@ public class FsShell extends Configured 
   static final String GET_SHORT_USAGE = "-get [-ignoreCrc] [-crc] <src> <localdst>";
   static final String COPYTOLOCAL_SHORT_USAGE = GET_SHORT_USAGE.replace(
       "-get", "-copyToLocal");
-  static final String TAIL_USAGE="-tail [-f] <file>";
   static final String DU_USAGE="-du [-s] [-h] <paths...>";
 
   /**
@@ -1129,57 +1128,6 @@ public class FsShell extends Configured 
   }
 
   /**
-   * Parse the incoming command string
-   * @param cmd
-   * @param pos ignore anything before this pos in cmd
-   * @throws IOException 
-   */
-  private void tail(String[] cmd, int pos) throws IOException {
-    CommandFormat c = new CommandFormat("tail", 1, 1, "f");
-    String src = null;
-    Path path = null;
-
-    try {
-      List<String> parameters = c.parse(cmd, pos);
-      src = parameters.get(0);
-    } catch(IllegalArgumentException iae) {
-      System.err.println("Usage: java FsShell " + TAIL_USAGE);
-      throw iae;
-    }
-    boolean foption = c.getOpt("f") ? true: false;
-    path = new Path(src);
-    FileSystem srcFs = path.getFileSystem(getConf());
-    FileStatus fileStatus = srcFs.getFileStatus(path);
-    if (fileStatus.isDirectory()) {
-      throw new IOException("Source must be a file.");
-    }
-
-    long fileSize = fileStatus.getLen();
-    long offset = (fileSize > 1024) ? fileSize - 1024: 0;
-
-    while (true) {
-      FSDataInputStream in = srcFs.open(path);
-      try {
-        in.seek(offset);
-        IOUtils.copyBytes(in, System.out, 1024);
-        offset = in.getPos();
-      } finally {
-        in.close();
-      }
-      if (!foption) {
-        break;
-      }
-      fileSize = srcFs.getFileStatus(path).getLen();
-      offset = (fileSize > offset) ? offset: fileSize;
-      try {
-        Thread.sleep(5000);
-      } catch (InterruptedException e) {
-        break;
-      }
-    }
-  }
-
-  /**
    * This class runs a command on a given FileStatus. This can be used for
    * running various commands like chmod, chown etc.
    */
@@ -1315,7 +1263,7 @@ public class FsShell extends Configured 
       "[" + COPYTOLOCAL_SHORT_USAGE + "] [-moveToLocal <src> <localdst>]\n\t"
+
       "[-mkdir <path>] [-report] [" + SETREP_SHORT_USAGE + "]\n\t" +
       "[-touchz <path>] [-test -[ezd] <path>] [-stat [format] <path>]\n\t"
+
-      "[-tail [-f] <path>] [-text <path>]\n\t" +
+      "[-text <path>]\n\t" +
       "[" + FsShellPermissions.CHMOD_USAGE + "]\n\t" +
       "[" + FsShellPermissions.CHOWN_USAGE + "]\n\t" +
       "[" + FsShellPermissions.CHGRP_USAGE + "]";
@@ -1421,10 +1369,6 @@ public class FsShell extends Configured 
       "\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 tail = TAIL_USAGE
-      + ":  Show the last 1KB of the file. \n"
-      + "\t\tThe -f option shows appended data as the file grows. \n";
-
     String chmod = FsShellPermissions.CHMOD_USAGE + "\n" +
       "\t\tChanges permissions of a file.\n" +
       "\t\tThis works similar to shell's chmod with a few exceptions.\n\n" +
@@ -1517,8 +1461,6 @@ public class FsShell extends Configured 
       System.out.println(text);
     } else if ("stat".equals(cmd)) {
       System.out.println(stat);
-    } else if ("tail".equals(cmd)) {
-      System.out.println(tail);
     } else if ("chmod".equals(cmd)) {
       System.out.println(chmod);
     } else if ("chown".equals(cmd)) {
@@ -1553,7 +1495,6 @@ public class FsShell extends Configured 
       System.out.println(moveToLocal);
       System.out.println(mkdir);
       System.out.println(setrep);
-      System.out.println(tail);
       System.out.println(touchz);
       System.out.println(test);
       System.out.println(text);
@@ -1711,8 +1652,6 @@ public class FsShell extends Configured 
     } else if ("-stat".equals(cmd)) {
       System.err.println("Usage: java FsShell" +
                          " [-stat [format] <path>]");
-    } else if ("-tail".equals(cmd)) {
-      System.err.println("Usage: java FsShell [" + TAIL_USAGE + "]");
     } else {
       System.err.println("Usage: java FsShell");
       System.err.println("           [-df [<path>]]");
@@ -1737,7 +1676,6 @@ public class FsShell extends Configured 
       System.err.println("           [-touchz <path>]");
       System.err.println("           [-test -[ezd] <path>]");
       System.err.println("           [-stat [format] <path>]");
-      System.err.println("           [" + TAIL_USAGE + "]");
       System.err.println("           [" + FsShellPermissions.CHMOD_USAGE + "]");      
       System.err.println("           [" + FsShellPermissions.CHOWN_USAGE + "]");
       System.err.println("           [" + FsShellPermissions.CHGRP_USAGE + "]");
@@ -1892,8 +1830,6 @@ public class FsShell extends Configured 
         } else {
           printHelp("");
         }
-      } else if ("-tail".equals(cmd)) {
-        tail(argv, i);           
       } else {
         exitCode = -1;
         System.err.println(cmd.substring(1) + ": Unknown command");

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Command.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Command.java?rev=1126782&r1=1126781&r2=1126782&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Command.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Command.java Mon
May 23 22:13:27 2011
@@ -259,12 +259,13 @@ abstract public class Command extends Co
   /**
    *  TODO: A crutch until the text is standardized across commands...
    *  Eventually an exception that takes the path as an argument will
-   *  replace custom text
+   *  replace custom text, until then, commands can supply custom text
+   *  for backwards compatibility
    *  @param path the thing that doesn't exist
    *  @returns String in printf format
    */
   protected String getFnfText(Path path) {
-    throw new RuntimeException(path + ": No such file or directory");
+    return path + ": No such file or directory";
   }
 
   /**

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=1126782&r1=1126781&r2=1126782&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
Mon May 23 22:13:27 2011
@@ -44,6 +44,7 @@ abstract public class FsCommand extends 
   public static void registerCommands(CommandFactory factory) {
     factory.registerCommands(Count.class);
     factory.registerCommands(Ls.class);
+    factory.registerCommands(Tail.class);
   }
 
   protected FsCommand() {}

Propchange: hadoop/common/branches/yahoo-merge/src/test/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 23 22:13:27 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/test/core:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1100026
+/hadoop/common/trunk/src/test/core:1043117,1078148,1080396,1081598,1082329,1082787-1082788,1084769,1085043,1085122,1086309,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1100026
 /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=1126782&r1=1126781&r2=1126782&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 Mon
May 23 22:13:27 2011
@@ -606,7 +606,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>^-tail \[-f\] &lt;file&gt;:  Show the last 1KB of
the file.( )*</expected-output>
+          <expected-output>^-tail \[-f\] &lt;file&gt;:( |\t)+Show the last
1KB of the file.( )*</expected-output>
         </comparator>
         <comparator>
           <type>RegexpComparator</type>



Mime
View raw message