use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class TestFileStatus method constructorNoSymlink.
/**
* Check that the non-symlink constructor works correctly.
*/
@Test
public void constructorNoSymlink() throws IOException {
boolean isdir = true;
FileStatus fileStatus = new FileStatus(LENGTH, isdir, REPLICATION, BLKSIZE, MTIME, ATIME, PERMISSION, OWNER, GROUP, PATH);
validateAccessors(fileStatus, LENGTH, isdir, REPLICATION, BLKSIZE, MTIME, ATIME, PERMISSION, OWNER, GROUP, null, PATH);
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class TestFileStatus method toStringDir.
/**
* Check that toString produces the expected output for a directory.
*/
@Test
public void toStringDir() throws IOException {
FileStatus fileStatus = new FileStatus(LENGTH, true, REPLICATION, BLKSIZE, MTIME, ATIME, PERMISSION, OWNER, GROUP, null, PATH);
validateToString(fileStatus);
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class TestFileStatus method testFileStatusWritable.
/**
* Check that the write and readField methods work correctly.
*/
@Test
public void testFileStatusWritable() throws Exception {
FileStatus[] tests = { new FileStatus(1, false, 5, 3, 4, 5, null, "", "", new Path("/a/b")), new FileStatus(0, false, 1, 2, 3, new Path("/")), new FileStatus(1, false, 5, 3, 4, 5, null, "", "", new Path("/a/b")) };
LOG.info("Writing FileStatuses to a ByteArrayOutputStream");
// Writing input list to ByteArrayOutputStream
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(baos);
for (FileStatus fs : tests) {
fs.write(out);
}
LOG.info("Creating ByteArrayInputStream object");
DataInput in = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
LOG.info("Testing if read objects are equal to written ones");
FileStatus dest = new FileStatus();
int iterator = 0;
for (FileStatus fs : tests) {
dest.readFields(in);
assertEquals("Different FileStatuses in iteration " + iterator, dest, fs);
iterator++;
}
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class TestFileStatus method constructorNoOwner.
/**
* Check that the constructor without owner, group and permissions works
* correctly.
*/
@Test
public void constructorNoOwner() throws IOException {
boolean isdir = true;
FileStatus fileStatus = new FileStatus(LENGTH, isdir, REPLICATION, BLKSIZE, MTIME, PATH);
validateAccessors(fileStatus, LENGTH, isdir, REPLICATION, BLKSIZE, MTIME, 0, FsPermission.getDirDefault(), "", "", null, PATH);
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class GenericOptionsParser method expandWildcard.
private void expandWildcard(List<String> finalPaths, Path path, FileSystem fs) throws IOException {
FileStatus status = fs.getFileStatus(path);
if (!status.isDirectory()) {
throw new FileNotFoundException(path + " is not a directory.");
}
// get all the jars in the directory
List<Path> jars = FileUtil.getJarsInDirectory(path.toString(), fs.equals(FileSystem.getLocal(conf)));
if (jars.isEmpty()) {
LOG.warn(path + " does not have jars in it. It will be ignored.");
} else {
for (Path jar : jars) {
finalPaths.add(jar.makeQualified(fs.getUri(), fs.getWorkingDirectory()).toString());
}
}
}
Aggregations