|
@@ -17,9 +17,13 @@
|
|
*/
|
|
*/
|
|
package org.apache.hadoop.hdfs;
|
|
package org.apache.hadoop.hdfs;
|
|
|
|
|
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
|
+import org.apache.hadoop.fs.Path;
|
|
|
|
+import org.apache.hadoop.fs.PathHandle;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.test.Whitebox;
|
|
import org.apache.hadoop.test.Whitebox;
|
|
|
|
+import org.junit.Test;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
|
@@ -44,4 +48,23 @@ public class TestViewDistributedFileSystem extends TestDistributedFileSystem{
|
|
data.set(null);
|
|
data.set(null);
|
|
super.testStatistics();
|
|
super.testStatistics();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testOpenWithPathHandle() throws Exception {
|
|
|
|
+ Configuration conf = getTestConfiguration();
|
|
|
|
+ MiniDFSCluster cluster = null;
|
|
|
|
+ try {
|
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
|
|
|
|
+ FileSystem fileSys = cluster.getFileSystem();
|
|
|
|
+ Path openTestPath = new Path("/testOpen");
|
|
|
|
+ fileSys.create(openTestPath).close();
|
|
|
|
+ PathHandle pathHandle =
|
|
|
|
+ fileSys.getPathHandle(fileSys.getFileStatus(openTestPath));
|
|
|
|
+ fileSys.open(pathHandle, 1024).close();
|
|
|
|
+ } finally {
|
|
|
|
+ if (cluster != null) {
|
|
|
|
+ cluster.shutdown();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|