Search in sources :

Example 11 with IgfsException

use of org.apache.ignite.igfs.IgfsException in project ignite by apache.

the class LocalIgfsSecondaryFileSystem method create0.

/**
 * Internal create routine.
 *
 * @param path Path.
 * @param overwrite Overwrite flag.
 * @return Output stream.
 */
private OutputStream create0(IgfsPath path, boolean overwrite) {
    File file = fileForPath(path);
    boolean exists = file.exists();
    if (exists) {
        if (!overwrite)
            throw new IgfsPathAlreadyExistsException("Failed to create a file because it already exists: " + path);
    } else {
        File parent = file.getParentFile();
        if (!mkdirs0(parent))
            throw new IgfsException("Failed to create parent directory for file (underlying file system " + "returned false): " + path);
    }
    try {
        return new FileOutputStream(file);
    } catch (IOException e) {
        throw handleSecondaryFsError(e, "Failed to create file [path=" + path + ", overwrite=" + overwrite + ']');
    }
}
Also used : IgfsException(org.apache.ignite.igfs.IgfsException) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) 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)

Aggregations

IgfsException (org.apache.ignite.igfs.IgfsException)11 IOException (java.io.IOException)4 TreeSet (java.util.TreeSet)3 IgfsPath (org.apache.ignite.igfs.IgfsPath)3 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)3 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)3 IgniteUuid (org.apache.ignite.lang.IgniteUuid)3 File (java.io.File)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgfsDirectoryNotEmptyException (org.apache.ignite.igfs.IgfsDirectoryNotEmptyException)2 IgfsFile (org.apache.ignite.igfs.IgfsFile)2 IgfsParentNotDirectoryException (org.apache.ignite.igfs.IgfsParentNotDirectoryException)2 IgfsPathAlreadyExistsException (org.apache.ignite.igfs.IgfsPathAlreadyExistsException)2 IgfsPathIsDirectoryException (org.apache.ignite.igfs.IgfsPathIsDirectoryException)2 IgfsPathIsNotDirectoryException (org.apache.ignite.igfs.IgfsPathIsNotDirectoryException)2 LocalFileSystemIgfsFile (org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile)2 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1 GroupPrincipal (java.nio.file.attribute.GroupPrincipal)1