Prechádzať zdrojové kódy

HDFS-1089. Remove uses of FileContext#isFile, isDirectory and exists. Contributed by Eli Collins.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@939803 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 15 rokov pred
rodič
commit
18a65f4327

+ 3 - 0
CHANGES.txt

@@ -162,6 +162,9 @@ Trunk (unreleased changes)
     HDFS-1100. Override unwrapException in TestFcHdfsSymlink to test 
     symlink API conformance. (Eli Collins via suresh).
 
+    HDFS-1089. Remove uses of FileContext#isFile, isDirectory, and exists.
+    (Eli Collins via hairong)
+
   OPTIMIZATIONS
 
     HDFS-946. NameNode should not return full path name when lisitng a

+ 10 - 8
src/test/aop/org/apache/hadoop/fs/TestFiRename.java

@@ -31,6 +31,8 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.hadoop.fs.FileContextTestHelper.*;
+
 /**
  * Rename names src to dst. Rename is done using following steps:
  * <ul>
@@ -206,7 +208,7 @@ public class TestFiRename {
     dst = getTestPath("testDeletionOfDstFile/newdir/dst");
     while (exception && count < 5) {
       try {
-        fc.exists(src);
+        exists(fc, src);
         exception = false;
       } catch (Exception e) {
         LOG.warn("Exception " + " count " + count + " " + e.getMessage());
@@ -214,8 +216,8 @@ public class TestFiRename {
         count++;
       }
     }
-    Assert.assertFalse(fc.exists(src));
-    Assert.assertTrue(fc.exists(dst));
+    Assert.assertFalse(exists(fc, src));
+    Assert.assertTrue(exists(fc, dst));
   }
 
   /** Rename test where both src and dst are directories */
@@ -242,7 +244,7 @@ public class TestFiRename {
     boolean exception = true;
     while (exception && count < 5) {
       try {
-        fc.exists(src);
+        exists(fc, src);
         exception = false;
       } catch (Exception e) {
         LOG.warn("Exception " + " count " + count + " " + e.getMessage());
@@ -250,8 +252,8 @@ public class TestFiRename {
         count++;
       }
     }
-    Assert.assertFalse(fc.exists(src));
-    Assert.assertTrue(fc.exists(dst));
+    Assert.assertFalse(exists(fc, src));
+    Assert.assertTrue(exists(fc, dst));
   }
 
   private void rename(Path src, Path dst, boolean exception, boolean srcExists,
@@ -263,7 +265,7 @@ public class TestFiRename {
       LOG.warn("Exception ", e);
       Assert.assertTrue(exception);
     }
-    Assert.assertEquals(srcExists, fc.exists(src));
-    Assert.assertEquals(dstExists, fc.exists(dst));
+    Assert.assertEquals(srcExists, exists(fc, src));
+    Assert.assertEquals(dstExists, exists(fc, dst));
   }
 }

+ 5 - 5
src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java

@@ -40,7 +40,7 @@ import org.junit.Test;
 import static org.apache.hadoop.fs.FileContextTestHelper.*;
 
 public class TestHDFSFileContextMainOperations extends
-                                  FileContextMainOperationsBaseTest {
+    FileContextMainOperationsBaseTest {
   private static MiniDFSCluster cluster;
   private static Path defaultWorkingDirectory;
   private static HdfsConfiguration CONF = new HdfsConfiguration();
@@ -259,8 +259,8 @@ public class TestHDFSFileContextMainOperations extends
     } catch (Exception ex) {
       Assert.assertTrue(exception);
     }
-    Assert.assertEquals(renameSucceeds, !fc.exists(src));
-    Assert.assertEquals(renameSucceeds, fc.exists(dst));
+    Assert.assertEquals(renameSucceeds, !exists(fc, src));
+    Assert.assertEquals(renameSucceeds, exists(fc, dst));
   }
   
   private void rename(Path src, Path dst, boolean dstExists,
@@ -272,7 +272,7 @@ public class TestHDFSFileContextMainOperations extends
     } catch (Exception ex) {
       Assert.assertTrue(exception);
     }
-    Assert.assertEquals(renameSucceeds, !fc.exists(src));
-    Assert.assertEquals((dstExists||renameSucceeds), fc.exists(dst));
+    Assert.assertEquals(renameSucceeds, !exists(fc, src));
+    Assert.assertEquals((dstExists||renameSucceeds), exists(fc, dst));
   }
 }