use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class BaseTestHttpFSWith method assertSameListing.
private static void assertSameListing(FileSystem expected, FileSystem actual, Path p) throws IOException {
// Consume all the entries from both iterators
RemoteIterator<FileStatus> exIt = expected.listStatusIterator(p);
List<FileStatus> exStatuses = new ArrayList<>();
while (exIt.hasNext()) {
exStatuses.add(exIt.next());
}
RemoteIterator<FileStatus> acIt = actual.listStatusIterator(p);
List<FileStatus> acStatuses = new ArrayList<>();
while (acIt.hasNext()) {
acStatuses.add(acIt.next());
}
assertEquals(exStatuses.size(), acStatuses.size());
for (int i = 0; i < exStatuses.size(); i++) {
FileStatus expectedStatus = exStatuses.get(i);
FileStatus actualStatus = acStatuses.get(i);
// Path URIs are fully qualified, so compare just the path component
assertEquals(expectedStatus.getPath().toUri().getPath(), actualStatus.getPath().toUri().getPath());
}
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class BaseTestHttpFSWith method testEncryption.
private void testEncryption() throws Exception {
if (isLocalFS()) {
return;
}
FileSystem proxyFs = FileSystem.get(getProxiedFSConf());
FileSystem httpFs = getHttpFSFileSystem();
FileStatus proxyStatus = proxyFs.getFileStatus(TestHdfsHelper.ENCRYPTED_FILE);
assertTrue(proxyStatus.isEncrypted());
FileStatus httpStatus = httpFs.getFileStatus(TestHdfsHelper.ENCRYPTED_FILE);
assertTrue(httpStatus.isEncrypted());
proxyStatus = proxyFs.getFileStatus(new Path("/"));
httpStatus = httpFs.getFileStatus(new Path("/"));
assertFalse(proxyStatus.isEncrypted());
assertFalse(httpStatus.isEncrypted());
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class BaseTestHttpFSWith method assertSameAclBit.
private static void assertSameAclBit(FileSystem expected, FileSystem actual, Path path) throws IOException {
FileStatus expectedFileStatus = expected.getFileStatus(path);
FileStatus actualFileStatus = actual.getFileStatus(path);
assertEquals(actualFileStatus.getPermission().getAclBit(), expectedFileStatus.getPermission().getAclBit());
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class BaseTestHttpFSWith method testSetTimes.
private void testSetTimes() throws Exception {
if (!isLocalFS()) {
FileSystem fs = FileSystem.get(getProxiedFSConf());
Path path = new Path(getProxiedFSTestDir(), "foo.txt");
OutputStream os = fs.create(path);
os.write(1);
os.close();
FileStatus status1 = fs.getFileStatus(path);
fs.close();
long at = status1.getAccessTime();
long mt = status1.getModificationTime();
fs = getHttpFSFileSystem();
fs.setTimes(path, mt - 10, at - 20);
fs.close();
fs = FileSystem.get(getProxiedFSConf());
status1 = fs.getFileStatus(path);
fs.close();
long atNew = status1.getAccessTime();
long mtNew = status1.getModificationTime();
assertEquals(mtNew, mt - 10);
assertEquals(atNew, at - 20);
}
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class BaseTestHttpFSWith method testSetPermission.
protected void testSetPermission() throws Exception {
FileSystem fs = FileSystem.get(getProxiedFSConf());
Path path = new Path(getProxiedFSTestDir(), "foodir");
fs.mkdirs(path);
fs = getHttpFSFileSystem();
FsPermission permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE);
fs.setPermission(path, permission1);
fs.close();
fs = FileSystem.get(getProxiedFSConf());
FileStatus status1 = fs.getFileStatus(path);
fs.close();
FsPermission permission2 = status1.getPermission();
assertEquals(permission2, permission1);
//sticky bit
fs = getHttpFSFileSystem();
permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE, true);
fs.setPermission(path, permission1);
fs.close();
fs = FileSystem.get(getProxiedFSConf());
status1 = fs.getFileStatus(path);
fs.close();
permission2 = status1.getPermission();
assertTrue(permission2.getStickyBit());
assertEquals(permission2, permission1);
}
Aggregations