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

This commit is contained in:
Brahma Reddy Battula 2016-12-08 18:57:43 +05:30
parent 4c2cf5560f
commit 0ef796174e
2 changed files with 18 additions and 1 deletions

View File

@ -34,6 +34,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;
@ -234,6 +235,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);

View File

@ -64,7 +64,6 @@ public class TestFilterFileSystem {
public FSDataOutputStream append(Path f, int bufferSize) throws
IOException;
public long getLength(Path f);
public void rename(Path src, Path dst, Rename... options);
public boolean exists(Path f);
public boolean isDirectory(Path f);
public boolean isFile(Path f);
@ -264,6 +263,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:/");