Browse Source

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)
(cherry picked from commit 6f445408022f210e01f826499d447d4e7792b429)
Brahma Reddy Battula 8 years ago
parent
commit
a1421de70e

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

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

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

@@ -64,7 +64,6 @@ public class TestFilterFileSystem {
     public FSDataOutputStream append(Path f, int bufferSize) throws
     public FSDataOutputStream append(Path f, int bufferSize) throws
         IOException;
         IOException;
     public long getLength(Path f);
     public long getLength(Path f);
-    public void rename(Path src, Path dst, Rename... options);
     public boolean exists(Path f);
     public boolean exists(Path f);
     public boolean isDirectory(Path f);
     public boolean isDirectory(Path f);
     public boolean isFile(Path f);
     public boolean isFile(Path f);
@@ -262,6 +261,17 @@ public class TestFilterFileSystem {
     verify(mockFs).setWriteChecksum(eq(true));
     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)
   private void checkInit(FilterFileSystem fs, boolean expectInit)
       throws Exception {
       throws Exception {
     URI uri = URI.create("filter:/");
     URI uri = URI.create("filter:/");