hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1090485 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FsShell.java src/java/org/apache/hadoop/fs/shell/Command.java src/java/org/apache/hadoop/fs/shell/Count.java src/java/org/apache/hadoop/fs/shell/FsCommand.java
Date Fri, 08 Apr 2011 23:07:35 GMT
Author: szetszwo
Date: Fri Apr  8 23:07:34 2011
New Revision: 1090485

URL: http://svn.apache.org/viewvc?rev=1090485&view=rev
Log:
HADOOP-7216. Add FsCommand.runAll() with deprecated annotation for the transition of Command
base class improvement.  Contributed by Daryn Sharp

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Command.java
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Count.java
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/FsCommand.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1090485&r1=1090484&r2=1090485&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Fri Apr  8 23:07:34 2011
@@ -130,6 +130,9 @@ Trunk (unreleased changes)
     HADOOP-7019. Refactor build targets to enable faster cross project dev
     cycles. (Luke Lu via cos)
 
+    HADOOP-7216. Add FsCommand.runAll() with deprecated annotation for the
+    transition of Command base class improvement.  (Daryn Sharp via szetszwo)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java?rev=1090485&r1=1090484&r2=1090485&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java Fri Apr  8 23:07:34 2011
@@ -1954,11 +1954,9 @@ public class FsShell extends Configured 
       } else if ("-count".equals(cmd)) {
         // TODO: next two lines are a temporary crutch until this entire
         // block is overhauled
-        LinkedList<String> args = new LinkedList<String>(Arrays.asList(argv));
-        String cmdName = args.removeFirst();
         Count runner = ReflectionUtils.newInstance(Count.class, getConf());
-        runner.setCommandName(cmdName); // TODO: will change with factory
-        exitCode = runner.run(args);
+        runner.setCommandName(cmd); // TODO: will change with factory
+        exitCode = runner.run(Arrays.copyOfRange(argv, 1, argv.length));
       } else if ("-mkdir".equals(cmd)) {
         exitCode = doall(cmd, argv, i);
       } else if ("-touchz".equals(cmd)) {

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Command.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Command.java?rev=1090485&r1=1090484&r2=1090485&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Command.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Command.java Fri Apr  8 23:07:34
2011
@@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -124,11 +125,12 @@ abstract public class Command extends Co
    * Most commands will chose to implement just
    * {@link #processOptions(LinkedList)} and {@link #processPath(PathData)}
    * 
-   * @param args the list of command line arguments
+   * @param argv the list of command line arguments
    * @return the exit code for the command
    * @throws IllegalArgumentException if called with invalid arguments
    */
-  public int run(LinkedList<String> args) {
+  public int run(String...argv) {
+    LinkedList<String> args = new LinkedList<String>(Arrays.asList(argv));
     try {
       processOptions(args);
       processArguments(expandArguments(args));

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Count.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Count.java?rev=1090485&r1=1090484&r2=1090485&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Count.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/Count.java Fri Apr  8 23:07:34
2011
@@ -60,10 +60,7 @@ public class Count extends FsCommand {
   public Count(String[] cmd, int pos, Configuration conf) {
     super(conf);
     setCommandName(NAME);
-    LinkedList<String> parameters = new LinkedList<String>(Arrays.asList(cmd));
-    parameters.subList(0, pos).clear();
-    processOptions(parameters);
-    this.args = parameters.toArray(new String[0]);
+    this.args = Arrays.copyOfRange(cmd, pos, cmd.length);
   }
 
   @Override

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/FsCommand.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/FsCommand.java?rev=1090485&r1=1090484&r2=1090485&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/FsCommand.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/FsCommand.java Fri Apr  8 23:07:34
2011
@@ -47,7 +47,16 @@ abstract public class FsCommand extends 
     return name.startsWith("-") ? name.substring(1) : name; 
   }
   
+  // abstract method that normally is invoked by runall() which is
+  // overridden below
   protected void run(Path path) throws IOException {
     throw new RuntimeException("not supposed to get here");
   }
+  
+  /** @deprecated use {@link #run(String...argv)} */
+  @Deprecated
+  @Override
+  public int runAll() {
+    return run(args);
+  }
 }



Mime
View raw message