|
@@ -31,8 +31,10 @@ import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.security.PrivilegedExceptionAction;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.EnumSet;
|
|
import java.util.EnumSet;
|
|
|
|
+import java.util.List;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
@@ -47,9 +49,11 @@ import org.apache.hadoop.fs.FSDataOutputStream;
|
|
import org.apache.hadoop.fs.FileChecksum;
|
|
import org.apache.hadoop.fs.FileChecksum;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
|
+import org.apache.hadoop.fs.LocatedFileStatus;
|
|
import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum;
|
|
import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum;
|
|
import org.apache.hadoop.fs.Options.ChecksumOpt;
|
|
import org.apache.hadoop.fs.Options.ChecksumOpt;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
|
|
+import org.apache.hadoop.fs.RemoteIterator;
|
|
import org.apache.hadoop.fs.VolumeId;
|
|
import org.apache.hadoop.fs.VolumeId;
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
|
|
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
|
|
@@ -226,7 +230,7 @@ public class TestDistributedFileSystem {
|
|
final long millis = Time.now();
|
|
final long millis = Time.now();
|
|
|
|
|
|
{
|
|
{
|
|
- DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
|
|
|
|
|
|
+ final DistributedFileSystem dfs = cluster.getFileSystem();
|
|
dfs.dfs.getLeaseRenewer().setGraceSleepPeriod(grace);
|
|
dfs.dfs.getLeaseRenewer().setGraceSleepPeriod(grace);
|
|
assertFalse(dfs.dfs.getLeaseRenewer().isRunning());
|
|
assertFalse(dfs.dfs.getLeaseRenewer().isRunning());
|
|
|
|
|
|
@@ -326,7 +330,7 @@ public class TestDistributedFileSystem {
|
|
}
|
|
}
|
|
|
|
|
|
{
|
|
{
|
|
- DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem();
|
|
|
|
|
|
+ final DistributedFileSystem dfs = cluster.getFileSystem();
|
|
assertFalse(dfs.dfs.getLeaseRenewer().isRunning());
|
|
assertFalse(dfs.dfs.getLeaseRenewer().isRunning());
|
|
|
|
|
|
//open and check the file
|
|
//open and check the file
|
|
@@ -835,4 +839,25 @@ public class TestDistributedFileSystem {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test(timeout=60000)
|
|
|
|
+ public void testListFiles() throws IOException {
|
|
|
|
+ Configuration conf = new HdfsConfiguration();
|
|
|
|
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ DistributedFileSystem fs = cluster.getFileSystem();
|
|
|
|
+
|
|
|
|
+ final Path relative = new Path("relative");
|
|
|
|
+ fs.create(new Path(relative, "foo")).close();
|
|
|
|
+
|
|
|
|
+ final List<LocatedFileStatus> retVal = new ArrayList<LocatedFileStatus>();
|
|
|
|
+ final RemoteIterator<LocatedFileStatus> iter = fs.listFiles(relative, true);
|
|
|
|
+ while (iter.hasNext()) {
|
|
|
|
+ retVal.add(iter.next());
|
|
|
|
+ }
|
|
|
|
+ System.out.println("retVal = " + retVal);
|
|
|
|
+ } finally {
|
|
|
|
+ cluster.shutdown();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|