use of org.apache.ignite.igfs.IgfsPathNotFoundException in project ignite by apache.
the class IgfsBenchmark method handleFile.
/** {@inheritDoc} */
@Override
public void handleFile(String strPath) throws Exception {
IgfsPath path = new IgfsPath(strPath);
IgfsInputStream in;
try {
in = fs.open(path);
} catch (IgfsPathNotFoundException ex) {
System.out.println("file " + path.toString() + " not exist: " + ex);
throw ex;
} catch (IgniteException ex) {
System.out.println("open file " + path.toString() + " failed: " + ex);
throw ex;
}
try {
for (int i = 0; i < size / dataBufer.capacity(); i++) in.read(dataBufer.array());
} catch (IOException ex) {
System.out.println("read file " + path.toString() + " failed: " + ex);
throw ex;
} finally {
in.close();
}
}
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);
}
}
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 HadoopIgfsSecondaryFileSystemDelegateImpl method listFiles.
/** {@inheritDoc} */
@Override
public Collection<IgfsFile> listFiles(IgfsPath path) {
try {
FileStatus[] statuses = fileSystemForUser().listStatus(convert(path));
if (statuses == null)
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
Collection<IgfsFile> res = new ArrayList<>(statuses.length);
for (FileStatus s : statuses) {
IgfsEntryInfo fsInfo = s.isDirectory() ? IgfsUtils.createDirectory(IgniteUuid.randomUuid(), null, properties(s), s.getAccessTime(), s.getModificationTime()) : IgfsUtils.createFile(IgniteUuid.randomUuid(), (int) s.getBlockSize(), s.getLen(), null, null, false, properties(s), s.getAccessTime(), s.getModificationTime());
res.add(new IgfsFileImpl(new IgfsPath(path, s.getPath().getName()), fsInfo, 1));
}
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 IgfsImpl method summary0.
/**
* Get summary for path.
*
* @param path Path.
* @return Summary.
* @throws IgniteCheckedException If failed.
*/
private IgfsPathSummary summary0(IgfsPath path) throws IgniteCheckedException {
IgfsFile info = info(path);
if (info == null)
throw new IgfsPathNotFoundException("Failed to get path summary (path not found): " + path);
IgfsPathSummary sum = new IgfsPathSummary(path);
summaryRecursive(info, sum);
return sum;
}
Aggregations