use of alluxio.underfs.UfsDirectoryStatus in project alluxio by Alluxio.
the class CephFSUnderFileSystem method getDirectoryStatus.
@Override
public UfsDirectoryStatus getDirectoryStatus(String path) throws IOException {
path = stripPath(path);
CephStat stat = new CephStat();
lstat(path, stat);
return new UfsDirectoryStatus(path, "", "", (short) stat.mode);
}
use of alluxio.underfs.UfsDirectoryStatus in project alluxio by Alluxio.
the class UnderFileSystemCommonOperations method getDirectoryStatusTest.
/**
* Test for getting directory status.
*/
@RelatedS3Operations(operations = { "putObject", "getObjectMetadata" })
public void getDirectoryStatusTest() throws IOException {
String testDir = PathUtils.concatPath(mTopLevelTestDirectory, "testDir");
mUfs.mkdirs(testDir);
UfsStatus status = mUfs.getStatus(testDir);
if (!(status instanceof UfsDirectoryStatus)) {
throw new IOException("Failed to get ufs directory status");
}
}
use of alluxio.underfs.UfsDirectoryStatus in project alluxio by Alluxio.
the class UnderFileSystemCommonOperations method createThenGetExistingDirectoryStatusTest.
/**
* Test for getting existing directory status.
*/
@RelatedS3Operations(operations = { "putObject", "getObjectMetadata" })
public void createThenGetExistingDirectoryStatusTest() throws IOException {
String testDir = PathUtils.concatPath(mTopLevelTestDirectory, "testDir");
mUfs.mkdirs(testDir);
UfsStatus status = mUfs.getExistingStatus(testDir);
if (!(status instanceof UfsDirectoryStatus)) {
throw new IOException("Failed to get ufs directory status");
}
}
use of alluxio.underfs.UfsDirectoryStatus in project alluxio by Alluxio.
the class WebUnderFileSystem method getStatus.
/**
* Get the file status of a http url.
*
* @param path the http url
* @param fileName the file name
* @return a UfsStatus object related to the http url
*/
private UfsStatus getStatus(String path, String fileName) throws IOException {
long contentLength = 0;
long lastModified = new Date().getTime();
Header[] headers = HttpUtils.head(path, mTimeout);
if (headers == null) {
throw new IOException("Failed to getStatus: " + path);
}
for (Header header : headers) {
String headerName = header.getName();
if (headerName.equalsIgnoreCase("Content-Length")) {
contentLength = Long.parseLong(header.getValue());
} else if (headerName.equalsIgnoreCase("Last-Modified")) {
lastModified = parseTimestamp(header.getValue(), mUfsConf.getString(PropertyKey.UNDERFS_WEB_HEADER_LAST_MODIFIED));
}
}
if (isFile(path)) {
// Return file status.
String contentHash = UnderFileSystemUtils.approximateContentHash(contentLength, lastModified);
return new UfsFileStatus(fileName == null ? path : fileName, contentHash, contentLength, lastModified, "", "", (short) 288, mUfsConf.getBytes(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT));
}
// Return directory status.
return new UfsDirectoryStatus(fileName == null ? path : fileName, "", "", (short) 800, lastModified);
}
use of alluxio.underfs.UfsDirectoryStatus in project alluxio by Alluxio.
the class LocalUnderFileSystemTest method getDirStatus.
@Test
public void getDirStatus() throws IOException {
String dir = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());
mLocalUfs.mkdirs(dir);
UfsDirectoryStatus s = mLocalUfs.getDirectoryStatus(dir);
assertTrue(s.isDirectory());
assertFalse(s.isFile());
}
Aggregations