Quellcode durchsuchen

HADOOP-13867. FilterFileSystem should override rename(.., options) to take effect of Rename options called via FilterFileSystem implementations. Contributed By Vinayakumar B.

(cherry picked from commit 0ef796174ecb5383f79cfecfcbfc4f309d093cd7)
Brahma Reddy Battula vor 8 Jahren
Ursprung
Commit
ef371dd187

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -182,6 +182,9 @@ Release 2.7.4 - UNRELEASED
     HADOOP-14356. Update CHANGES.txt to reflect all the changes in branch-2.7.
     (Brahma Reddy Battula)
 
+    HADOOP-13867. FilterFileSystem should override rename(.., options) to take effect of Rename options called via
+    FilterFileSystem implementations. (Vinayakumar B via Brahma Reddy Battula)
+
 Release 2.7.3 - 2016-08-25
 
   INCOMPATIBLE CHANGES

+ 7 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java

@@ -33,6 +33,7 @@ import org.apache.hadoop.fs.permission.AclStatus;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.Options.ChecksumOpt;
+import org.apache.hadoop.fs.Options.Rename;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.util.Progressable;
 
@@ -226,6 +227,12 @@ public class FilterFileSystem extends FileSystem {
     return fs.rename(src, dst);
   }
 
+  @Override
+  protected void rename(Path src, Path dst, Rename... options)
+      throws IOException {
+    fs.rename(src, dst, options);
+  }
+
   @Override
   public boolean truncate(Path f, final long newLength) throws IOException {
     return fs.truncate(f, newLength);

+ 12 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java

@@ -52,7 +52,7 @@ public class TestFilterFileSystem {
     conf.setBoolean("fs.flfs.impl.disable.cache", true);
     conf.setBoolean("fs.file.impl.disable.cache", true);
   }
-  
+
   public static class DontCheck {
     public BlockLocation[] getFileBlockLocations(Path p, 
         long start, long len) { return null; }
@@ -334,6 +334,17 @@ public class TestFilterFileSystem {
     verify(mockFs).setWriteChecksum(eq(true));
   }
 
+  @Test
+  public void testRenameOptions() throws Exception {
+    FileSystem mockFs = mock(FileSystem.class);
+    FileSystem fs = new FilterFileSystem(mockFs);
+    Path src = new Path("/src");
+    Path dst = new Path("/dest");
+    Rename opt = Rename.TO_TRASH;
+    fs.rename(src, dst, opt);
+    verify(mockFs).rename(eq(src), eq(dst), eq(opt));
+  }
+
   private void checkInit(FilterFileSystem fs, boolean expectInit)
       throws Exception {
     URI uri = URI.create("filter:/");