use of alluxio.exception.OpenDirectoryException in project alluxio by Alluxio.
the class BaseFileSystem method openFile.
@Override
public FileInStream openFile(URIStatus status, OpenFilePOptions options) throws FileDoesNotExistException, OpenDirectoryException, FileIncompleteException, IOException, AlluxioException {
AlluxioURI path = new AlluxioURI(status.getPath());
if (status.isFolder()) {
throw new OpenDirectoryException(path);
}
if (!status.isCompleted()) {
throw new FileIncompleteException(path);
}
AlluxioConfiguration conf = mFsContext.getPathConf(path);
OpenFilePOptions mergedOptions = FileSystemOptions.openFileDefaults(conf).toBuilder().mergeFrom(options).build();
InStreamOptions inStreamOptions = new InStreamOptions(status, mergedOptions, conf);
return new AlluxioFileInStream(status, inStreamOptions, mFsContext);
}
use of alluxio.exception.OpenDirectoryException in project alluxio by Alluxio.
the class AlluxioFuseFileSystem method openInternal.
private int openInternal(String path, FuseFileInfo fi) {
final AlluxioURI uri = mPathResolverCache.getUnchecked(path);
// (see {@code man 2 open} for the structure of the flags bitfield)
// File creation flags are the last two bits of flags
final int flags = fi.flags.get();
if (mOpenFiles.size() >= MAX_OPEN_FILES) {
LOG.error("Cannot open {}: too many open files (MAX_OPEN_FILES: {})", path, MAX_OPEN_FILES);
return ErrorCodes.EMFILE();
}
FileInStream is;
try {
try {
is = mFileSystem.openFile(uri);
} catch (FileIncompleteException e) {
if (AlluxioFuseUtils.waitForFileCompleted(mFileSystem, uri)) {
is = mFileSystem.openFile(uri);
} else {
throw e;
}
}
} catch (OpenDirectoryException e) {
LOG.error("Cannot open folder {}", path);
return -ErrorCodes.EISDIR();
} catch (FileIncompleteException e) {
LOG.error("Cannot open incomplete file {}", path);
return -ErrorCodes.EFAULT();
} catch (FileDoesNotExistException | InvalidPathException e) {
LOG.error("Failed to open file {}, path does not exist or is invalid", path);
return -ErrorCodes.ENOENT();
} catch (Throwable t) {
LOG.error("Failed to open file {}", path, t);
return AlluxioFuseUtils.getErrorCode(t);
}
long fid = mNextOpenFileId.getAndIncrement();
mOpenFiles.add(new OpenFileEntry<>(fid, path, is, null));
fi.fh.set(fid);
return 0;
}
Aggregations