hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r646947 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FsShell.java src/test/org/apache/hadoop/dfs/TestDFSShell.java
Date Thu, 10 Apr 2008 20:39:33 GMT
Author: rangadi
Date: Thu Apr 10 13:39:32 2008
New Revision: 646947

URL: http://svn.apache.org/viewvc?rev=646947&view=rev
Log:
 HADOOP-3224. 'dfs -du /dir' does not return correct size. (Lohit Vjayarenu via rangadi)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=646947&r1=646946&r2=646947&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Apr 10 13:39:32 2008
@@ -16,6 +16,9 @@
    HADOOP-2905. 'fsck -move' triggers NPE in NameNode. 
    (Lohit Vjayarenu via rangadi)
 
+   HADOOP-3224. 'dfs -du /dir' does not return correct size.
+   (Lohit Vjayarenu via rangadi)
+
 Release 0.17.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java?rev=646947&r1=646946&r2=646947&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java Thu Apr 10 13:39:32 2008
@@ -671,7 +671,9 @@
     } else {
       System.out.println("Found " + items.length + " items");
       for (int i = 0; i < items.length; i++) {
-        System.out.println(items[i].getPath() + "\t" + items[i].getLen());
+        System.out.println(items[i].getPath() + "\t" + 
+                           srcFs.getContentSummary(items[i].getPath()).
+                           getLength());
       }
     }
   }

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java?rev=646947&r1=646946&r2=646947&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java Thu Apr 10 13:39:32
2008
@@ -134,7 +134,55 @@
     }
   }
     
-  
+  public void testDu() throws IOException {
+    Configuration conf = new Configuration();
+    MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
+    FileSystem fs = cluster.getFileSystem();
+    assertTrue("Not a HDFS: "+fs.getUri(),
+                fs instanceof DistributedFileSystem);
+    final DistributedFileSystem dfs = (DistributedFileSystem)fs;
+    PrintStream psBackup = System.out;
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    PrintStream psOut = new PrintStream(out);
+    System.setOut(psOut);
+    FsShell shell = new FsShell();
+    shell.setConf(conf);
+    
+    try {
+      Path myPath = new Path("/test/dir");
+      assertTrue(fs.mkdirs(myPath));
+      assertTrue(fs.exists(myPath));
+      Path myFile = new Path("/test/dir/file");
+      writeFile(fs, myFile);
+      assertTrue(fs.exists(myFile));
+      Path myFile2 = new Path("/test/dir/file2");
+      writeFile(fs, myFile2);
+      assertTrue(fs.exists(myFile2));
+      
+      String[] args = new String[2];
+      args[0] = "-du";
+      args[1] = "/test/dir";
+      int val = -1;
+      try {
+        val = shell.run(args);
+      } catch (Exception e) {
+        System.err.println("Exception raised from DFSShell.run " +
+                            e.getLocalizedMessage());
+      }
+      assertTrue(val == 0);
+      String returnString = out.toString();
+      out.reset();
+      // Check if size matchs as expected
+      assertTrue(returnString.contains("22"));
+      assertTrue(returnString.contains("23"));
+      
+    } finally {
+      try {dfs.close();} catch (Exception e) {}
+      System.setOut(psBackup);
+      cluster.shutdown();
+    }
+                                  
+  }
   public void testPut() throws IOException {
     Configuration conf = new Configuration();
     MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);



Mime
View raw message