Search in sources :

Example 11 with CephStat

use of com.ceph.fs.CephStat in project alluxio by Alluxio.

the class CephFSUnderFileSystem method listStatus.

/**
 * Each string is a name rather than a complete path.
 *
 * @param path the path to list
 * @return An array with the statuses of the files and directories in the directory
 * denoted by this path. The array will be empty if the directory is empty. Returns
 * null if this path does not denote a directory
 */
@Override
@Nullable
public UfsStatus[] listStatus(String path) throws IOException {
    path = stripPath(path);
    String[] lst = listDirectory(path);
    if (lst != null) {
        UfsStatus[] status = new UfsStatus[lst.length];
        for (int i = 0; i < status.length; i++) {
            CephStat stat = new CephStat();
            lstat(PathUtils.concatPath(path, lst[i]), stat);
            if (!stat.isDir()) {
                String contentHash = UnderFileSystemUtils.approximateContentHash(stat.size, stat.m_time);
                status[i] = new UfsFileStatus(lst[i], contentHash, stat.size, stat.m_time, "", "", (short) stat.mode);
            } else {
                status[i] = new UfsDirectoryStatus(lst[i], "", "", (short) stat.mode);
            }
        }
        return status;
    }
    return null;
}
Also used : UfsFileStatus(alluxio.underfs.UfsFileStatus) UfsStatus(alluxio.underfs.UfsStatus) CephStat(com.ceph.fs.CephStat) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus) Nullable(javax.annotation.Nullable)

Example 12 with CephStat

use of com.ceph.fs.CephStat in project alluxio by Alluxio.

the class CephFSUnderFileSystem method exists.

@Override
public boolean exists(String path) throws IOException {
    path = stripPath(path);
    try {
        CephStat stat = new CephStat();
        lstat(path, stat);
        return true;
    } catch (FileNotFoundException e) {
        return false;
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) CephStat(com.ceph.fs.CephStat)

Aggregations

CephStat (com.ceph.fs.CephStat)12 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)4 CountingRetry (alluxio.retry.CountingRetry)2 RetryPolicy (alluxio.retry.RetryPolicy)2 UfsDirectoryStatus (alluxio.underfs.UfsDirectoryStatus)2 UfsFileStatus (alluxio.underfs.UfsFileStatus)2 UfsStatus (alluxio.underfs.UfsStatus)1 Nullable (javax.annotation.Nullable)1