hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r803296 - in /hadoop/common/trunk: CHANGES.txt src/test/core/org/apache/hadoop/fs/TestTrash.java
Date Tue, 11 Aug 2009 21:03:50 GMT
Author: szetszwo
Date: Tue Aug 11 21:03:50 2009
New Revision: 803296

URL: http://svn.apache.org/viewvc?rev=803296&view=rev
Log:
HADOOP-6188. TestTrash uses java.io.File api but not hadoop FileSystem api.  Contributed by
Boris Shkolnik

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=803296&r1=803295&r2=803296&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Tue Aug 11 21:03:50 2009
@@ -914,6 +914,9 @@
     HADOOP-6177. FSInputChecker.getPos() would return position greater 
     than the file size. (Hong Tang via hairong)
 
+    HADOOP-6188. TestTrash uses java.io.File api but not hadoop FileSystem api.
+    (Boris Shkolnik via szetszwo)
+
 Release 0.20.1 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java?rev=803296&r1=803295&r2=803296&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java Tue Aug 11 21:03:50
2009
@@ -61,18 +61,22 @@
   
   // counts how many instances of the file are in the Trash
   // they all are in format fileName*
-  protected static int countSameDeletedFiles(FileSystem fs, final File trashDir,
-      final String fileName) throws IOException {
-    System.out.println("Counting " + fileName + " in " + trashDir.getAbsolutePath());
-    String [] res = trashDir.list(
-          new FilenameFilter() {
-            public boolean accept(File dir, String name) {
-                return name.startsWith(fileName);
-              }
-          }
-      );
+  protected static int countSameDeletedFiles(FileSystem fs, 
+      Path trashDir, Path fileName) throws IOException {
 
-    return res.length;
+    final String prefix = fileName.getName();
+    System.out.println("Counting " + fileName + " in " + trashDir.toString());
+
+    // filter that matches all the files that start with fileName*
+    PathFilter pf = new PathFilter() {
+      public boolean accept(Path file) {
+        return file.getName().startsWith(prefix);
+      }
+    };
+    // run the filter
+    FileStatus [] fss = fs.listStatus(trashDir, pf);
+
+    return fss==null? 0 : fss.length;
   }
 
   // check that the specified file is not in Trash
@@ -358,10 +362,14 @@
         assertTrue(val==0);
       }
       // current trash directory
-      File trashCurrent = new File(trashRoot.toUri().getPath() + myFile.getParent().toUri().getPath());
+      Path trashDir = new Path(trashRoot.toUri().getPath() + myFile.getParent().toUri().getPath());
+      
+      System.out.println("Deleting same myFile: myFile.parent=" + myFile.getParent().toUri().getPath()
+ 
+          "; trashroot="+trashRoot.toUri().getPath() + 
+          "; trashDir=" + trashDir.toUri().getPath());
       
-      int count = countSameDeletedFiles(fs, trashCurrent, myFile.getName());
-      System.out.println("counted " + count + " files " + myFile.getName() + "* in " + trashCurrent);
+      int count = countSameDeletedFiles(fs, trashDir, myFile);
+      System.out.println("counted " + count + " files " + myFile.getName() + "* in " + trashDir);
       assertTrue(count==num_runs);
     }
     



Mime
View raw message