use of org.apache.ignite.igfs.IgfsPathNotFoundException in project ignite by apache.
the class HadoopIgfsSecondaryFileSystemDelegateImpl method listPaths.
/**
* {@inheritDoc}
*/
@Override
public Collection<IgfsPath> listPaths(IgfsPath path) {
try {
FileStatus[] statuses = fileSystemForUser().listStatus(convert(path));
if (statuses == null)
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
Collection<IgfsPath> res = new ArrayList<>(statuses.length);
for (FileStatus status : statuses) res.add(new IgfsPath(path, status.getPath().getName()));
return res;
} catch (FileNotFoundException ignored) {
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
} catch (IOException e) {
throw handleSecondaryFsError(e, "Failed to list statuses due to secondary file system exception: " + path);
}
}
use of org.apache.ignite.igfs.IgfsPathNotFoundException in project ignite by apache.
the class LocalIgfsSecondaryFileSystem method append.
/**
* {@inheritDoc}
*/
@Override
public OutputStream append(IgfsPath path, int bufSize, boolean create, @Nullable Map<String, String> props) {
try {
File file = fileForPath(path);
boolean exists = file.exists();
if (exists) {
OutputStream os = new FileOutputStream(file, true);
try {
updatePropertiesIfNeeded(path, props);
return os;
} catch (Exception err) {
try {
os.close();
throw err;
} catch (IOException closeErr) {
err.addSuppressed(closeErr);
throw err;
}
}
} else {
if (create)
return create(path, bufSize, false, 0, 0, props);
else
throw new IgfsPathNotFoundException("Failed to append to file because it doesn't exist: " + path);
}
} catch (IOException e) {
throw handleSecondaryFsError(e, "Failed to append to file because it doesn't exist: " + path);
}
}
Aggregations