Search in sources :

Example 11 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 12 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)

Aggregations

IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)12 IgfsFile (org.apache.ignite.igfs.IgfsFile)7 IgfsException (org.apache.ignite.igfs.IgfsException)6 File (java.io.File)4 IOException (java.io.IOException)4 IgniteException (org.apache.ignite.IgniteException)4 IgfsPath (org.apache.ignite.igfs.IgfsPath)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