Search in sources :

Example 6 with IgfsPathNotFoundException

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();
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) IgfsInputStream(org.apache.ignite.igfs.IgfsInputStream) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

Example 7 with IgfsPathNotFoundException

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);
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException) IgfsFile(org.apache.ignite.igfs.IgfsFile) LocalFileSystemIgfsFile(org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile) File(java.io.File) IgfsPathAlreadyExistsException(org.apache.ignite.igfs.IgfsPathAlreadyExistsException) IgfsException(org.apache.ignite.igfs.IgfsException) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) IgfsPathIsNotDirectoryException(org.apache.ignite.igfs.IgfsPathIsNotDirectoryException) FileNotFoundException(java.io.FileNotFoundException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

Example 8 with IgfsPathNotFoundException

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);
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) FileStatus(org.apache.hadoop.fs.FileStatus) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

Example 9 with IgfsPathNotFoundException

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);
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) FileStatus(org.apache.hadoop.fs.FileStatus) ArrayList(java.util.ArrayList) IgfsEntryInfo(org.apache.ignite.internal.processors.igfs.IgfsEntryInfo) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException) IgfsFile(org.apache.ignite.igfs.IgfsFile) IgfsFileImpl(org.apache.ignite.internal.processors.igfs.IgfsFileImpl)

Example 10 with IgfsPathNotFoundException

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;
}
Also used : IgfsPathSummary(org.apache.ignite.igfs.IgfsPathSummary) IgfsFile(org.apache.ignite.igfs.IgfsFile) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

Aggregations

IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)13 IgfsFile (org.apache.ignite.igfs.IgfsFile)7 IgfsException (org.apache.ignite.igfs.IgfsException)6 IOException (java.io.IOException)5 IgniteException (org.apache.ignite.IgniteException)5 IgfsPath (org.apache.ignite.igfs.IgfsPath)5 File (java.io.File)4 IgfsPathAlreadyExistsException (org.apache.ignite.igfs.IgfsPathAlreadyExistsException)4 IgfsPathIsDirectoryException (org.apache.ignite.igfs.IgfsPathIsDirectoryException)4 IgfsPathIsNotDirectoryException (org.apache.ignite.igfs.IgfsPathIsNotDirectoryException)4 LocalFileSystemIgfsFile (org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile)4 FileNotFoundException (java.io.FileNotFoundException)3 ArrayList (java.util.ArrayList)3 TreeSet (java.util.TreeSet)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)3 IgniteUuid (org.apache.ignite.lang.IgniteUuid)3 FileStatus (org.apache.hadoop.fs.FileStatus)2 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)2 ClusterTopologyException (org.apache.ignite.cluster.ClusterTopologyException)2