Search in sources :

Example 1 with CephStat

use of com.ceph.fs.CephStat 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 2 with CephStat

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

the class CephFSUnderFileSystem method deleteInternal.

private boolean deleteInternal(String path, boolean recursive) throws IOException {
    CephStat stat = new CephStat();
    try {
        lstat(path, stat);
    } catch (FileNotFoundException e) {
        return false;
    }
    // we're done if it's a file
    if (stat.isFile()) {
        mMount.unlink(path);
        return true;
    }
    // get directory contents
    String[] lst = listDirectory(path);
    if (lst == null) {
        return false;
    }
    if (!recursive && lst.length > 0) {
        throw new IOException("Directory " + path + " is not empty.");
    }
    for (String fname : lst) {
        String fullPath = PathUtils.concatPath(path, fname);
        if (!deleteInternal(fullPath, recursive)) {
            return false;
        }
    }
    mMount.rmdir(path);
    return true;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) CephStat(com.ceph.fs.CephStat)

Example 3 with CephStat

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

the class CephFSUnderFileSystem method isFile.

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

Example 4 with CephStat

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

the class CephFSUnderFileSystem method getFileStatus.

/**
 * Gets stat information on a file. This does not fill owner or group, as
 * Ceph's support for these is a bit different.
 *
 * @param path The path to stat
 * @return FileStatus object containing the stat information
 * @throws FileNotFoundException if the path could not be resolved
 */
@Override
public UfsFileStatus getFileStatus(String path) throws IOException {
    path = stripPath(path);
    CephStat stat = new CephStat();
    lstat(path, stat);
    String contentHash = UnderFileSystemUtils.approximateContentHash(stat.size, stat.m_time);
    return new UfsFileStatus(path, contentHash, stat.size, stat.m_time, "", "", (short) stat.mode);
}
Also used : UfsFileStatus(alluxio.underfs.UfsFileStatus) CephStat(com.ceph.fs.CephStat)

Example 5 with CephStat

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

the class CephFSUnderFileSystem method getStatus.

@Override
public UfsStatus getStatus(String path) throws IOException {
    path = stripPath(path);
    CephStat stat = new CephStat();
    lstat(path, stat);
    if (stat.isFile()) {
        return getFileStatus(path);
    } else if (stat.isDir()) {
        return getDirectoryStatus(path);
    }
    throw new IOException("Failed to getStatus: " + path);
}
Also used : IOException(java.io.IOException) 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