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);
}
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;
}
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;
}
}
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);
}
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);
}
Aggregations