hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r646478 - in /hadoop/core/branches/branch-0.17: CHANGES.txt src/java/org/apache/hadoop/fs/FsShell.java src/test/org/apache/hadoop/fs/TestFileSystem.java
Date Wed, 09 Apr 2008 18:42:27 GMT
Author: rangadi
Date: Wed Apr  9 11:42:23 2008
New Revision: 646478

URL: http://svn.apache.org/viewvc?rev=646478&view=rev
Log:
HADOOP-3175. Fix FsShell.CommandFormat to handle - in arguments. (Edward J. Yoon via rangadi)

Modified:
    hadoop/core/branches/branch-0.17/CHANGES.txt
    hadoop/core/branches/branch-0.17/src/java/org/apache/hadoop/fs/FsShell.java
    hadoop/core/branches/branch-0.17/src/test/org/apache/hadoop/fs/TestFileSystem.java

Modified: hadoop/core/branches/branch-0.17/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.17/CHANGES.txt?rev=646478&r1=646477&r2=646478&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.17/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.17/CHANGES.txt Wed Apr  9 11:42:23 2008
@@ -530,6 +530,9 @@
     since cygwin symlinks are unsupported.
     (Mahadev konar via cdouglas)
 
+    HADOOP-3175. Fix FsShell.CommandFormat to handle "-" in arguments.
+    (Edward J. Yoon via rangadi)
+
 Release 0.16.3 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/branches/branch-0.17/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.17/src/java/org/apache/hadoop/fs/FsShell.java?rev=646478&r1=646477&r2=646478&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.17/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/branches/branch-0.17/src/java/org/apache/hadoop/fs/FsShell.java Wed Apr  9
11:42:23 2008
@@ -428,7 +428,7 @@
     final int minPar, maxPar;
     final Map<String, Boolean> options = new HashMap<String, Boolean>();
 
-    private CommandFormat(String n, int min, int max, String ... possibleOpt) {
+    CommandFormat(String n, int min, int max, String ... possibleOpt) {
       name = n;
       minPar = min;
       maxPar = max;
@@ -439,7 +439,7 @@
     List<String> parse(String[] args, int pos) {
       List<String> parameters = new ArrayList<String>();
       for(; pos < args.length; pos++) {
-        if (args[pos].charAt(0) == '-') {
+        if (args[pos].charAt(0) == '-' && args[pos].length() > 1) {
           String opt = args[pos].substring(1);
           if (options.containsKey(opt))
             options.put(opt, Boolean.TRUE);

Modified: hadoop/core/branches/branch-0.17/src/test/org/apache/hadoop/fs/TestFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.17/src/test/org/apache/hadoop/fs/TestFileSystem.java?rev=646478&r1=646477&r2=646478&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.17/src/test/org/apache/hadoop/fs/TestFileSystem.java (original)
+++ hadoop/core/branches/branch-0.17/src/test/org/apache/hadoop/fs/TestFileSystem.java Wed
Apr  9 11:42:23 2008
@@ -31,6 +31,7 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.dfs.MiniDFSCluster;
+import org.apache.hadoop.fs.FsShell.CommandFormat;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.UTF8;
@@ -83,6 +84,21 @@
     fs.delete(DATA_DIR, true);
     fs.delete(WRITE_DIR, true);
     fs.delete(READ_DIR, true);
+  }
+
+  public static void testCommandFormat() throws Exception {
+    // This should go to TestFsShell.java when it is added.
+    CommandFormat cf;
+    cf= new CommandFormat("copyToLocal", 2,2,"crc","ignoreCrc");
+    assertEquals(cf.parse(new String[] {"-get","file", "-"}, 1).get(1), "-");
+    assertEquals(cf.parse(new String[] {"-get","file","-ignoreCrc","/foo"}, 1).get(1),"/foo");
+    cf = new CommandFormat("tail", 1, 1, "f");
+    assertEquals(cf.parse(new String[] {"-tail","fileName"}, 1).get(0),"fileName");
+    assertEquals(cf.parse(new String[] {"-tail","-f","fileName"}, 1).get(0),"fileName");
+    cf = new CommandFormat("setrep", 2, 2, "R", "w");
+    assertEquals(cf.parse(new String[] {"-setrep","-R","2","/foo/bar"}, 1).get(1), "/foo/bar");
+    cf = new CommandFormat("put", 2, 10000);
+    assertEquals(cf.parse(new String[] {"-put", "-", "dest"}, 1).get(1), "dest"); 
   }
 
   public static void createControlFile(FileSystem fs,



Mime
View raw message