Search in sources :

Example 6 with UfsDirectoryStatus

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);
}
Also used : CephStat(com.ceph.fs.CephStat) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus)

Example 7 with UfsDirectoryStatus

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");
    }
}
Also used : UfsStatus(alluxio.underfs.UfsStatus) IOException(java.io.IOException) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus)

Example 8 with UfsDirectoryStatus

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");
    }
}
Also used : UfsStatus(alluxio.underfs.UfsStatus) IOException(java.io.IOException) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus)

Example 9 with UfsDirectoryStatus

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);
}
Also used : UfsFileStatus(alluxio.underfs.UfsFileStatus) Header(org.apache.http.Header) IOException(java.io.IOException) Date(java.util.Date) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus)

Example 10 with UfsDirectoryStatus

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());
}
Also used : UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus) Test(org.junit.Test)

Aggregations

UfsDirectoryStatus (alluxio.underfs.UfsDirectoryStatus)15 UfsFileStatus (alluxio.underfs.UfsFileStatus)8 UfsStatus (alluxio.underfs.UfsStatus)5 IOException (java.io.IOException)5 AlluxioURI (alluxio.AlluxioURI)3 UnderFileSystem (alluxio.underfs.UnderFileSystem)3 File (java.io.File)3 PosixFileAttributes (java.nio.file.attribute.PosixFileAttributes)3 FileStatus (org.apache.hadoop.fs.FileStatus)3 Test (org.junit.Test)3 ConsistentUnderFileSystem (alluxio.underfs.ConsistentUnderFileSystem)2 FileInfo (alluxio.wire.FileInfo)2 CephStat (com.ceph.fs.CephStat)2 FileNotFoundException (java.io.FileNotFoundException)2 FileSystemException (java.nio.file.FileSystemException)2 Nullable (javax.annotation.Nullable)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 AccessControlException (alluxio.exception.AccessControlException)1