use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method isDirectory.
@Override
public boolean isDirectory(String path) throws IOException {
path = stripPath(path);
try {
CephStat stat = new CephStat();
lstat(path, stat);
return stat.isDir();
} catch (FileNotFoundException e) {
return false;
}
}
use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method openInternal.
private int openInternal(String path, int flags, int mode) throws IOException {
int fd = mMount.open(path, flags, mode);
CephStat stat = new CephStat();
mMount.fstat(fd, stat);
if (stat.isDir()) {
mMount.close(fd);
throw new FileNotFoundException();
}
return fd;
}
use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method getBlockSizeByte.
@Override
public long getBlockSizeByte(String path) throws IOException {
path = stripPath(path);
CephStat stat = new CephStat();
lstat(path, stat);
return stat.blksize;
}
use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method rename.
/**
* Rename a file or folder to a file or folder.
*
* @param src path of source file or directory
* @param dst path of destination file or directory
* @return true if rename succeeds
*/
private boolean rename(String src, String dst) throws IOException {
src = stripPath(src);
dst = stripPath(dst);
IOException te = null;
RetryPolicy retryPolicy = new CountingRetry(MAX_TRY);
while (retryPolicy.attempt()) {
try {
try {
CephStat stat = new CephStat();
lstat(dst, stat);
if (stat.isDir()) {
String fileName = getFileName(src);
mMount.rename(src, PathUtils.concatPath(dst, fileName));
return true;
}
return false;
} catch (FileNotFoundException e) {
// can be ignored safely
}
mMount.rename(src, dst);
return true;
} catch (IOException e) {
LOG.warn("{} try to rename {} to {} : {}", retryPolicy.getAttemptCount(), src, dst, e.toString());
te = e;
}
}
throw te;
}
use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method open.
@Override
public InputStream open(String path, OpenOptions options) throws IOException {
path = stripPath(path);
IOException te = null;
RetryPolicy retryPolicy = new CountingRetry(MAX_TRY);
while (retryPolicy.attempt()) {
try {
int mode = CreateOptions.defaults(mUfsConf).getMode().toShort();
int fd = openInternal(path, CephMount.O_RDONLY, mode);
CephStat stat = new CephStat();
mMount.fstat(fd, stat);
CephInputStream inputStream = new CephInputStream(mMount, fd, stat.size);
try {
inputStream.seek(options.getOffset());
} catch (IOException e) {
inputStream.close();
throw e;
}
return new CephSeekableInputStream(inputStream);
} catch (IOException e) {
LOG.warn("{} try to open {} : {}", retryPolicy.getAttemptCount(), path, e.toString());
te = e;
}
}
throw te;
}
Aggregations