/** * Create directory and it's parents. * * @param pathIds Path IDs. * @param lockInfos Lock infos. * @param dirProps Directory properties. * @return Result or {@code} if the first parent already contained child with the same name. * @throws IgniteCheckedException If failed. */ @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos, Map<String, String> dirProps) throws IgniteCheckedException { // Check if entry we are going to write to is directory. if (lockInfos.get(pathIds.lastExistingId()).isFile()) throw new IgfsParentNotDirectoryException("Failed to create directory (parent " + "element is not a directory)"); return createFileOrDirectory(true, pathIds, lockInfos, dirProps, null, 0, null, false, null, null); }
/** * Create file and all it's parents. * * @param pathIds Paths IDs. * @param lockInfos Lock infos. * @param dirProps Directory properties. * @param fileProps File propertris. * @param blockSize Block size. * @param affKey Affinity key (optional) * @param evictExclude Evict exclude flag. * @param secondaryCtx Secondary file system create context. * @param secondaryOutHolder Holder for the secondary output stream. * @return Result or {@code} if the first parent already contained child with the same name. * @throws IgniteCheckedException If failed. */ @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude, @Nullable IgfsSecondaryFileSystemCreateContext secondaryCtx, @Nullable T1<OutputStream> secondaryOutHolder) throws IgniteCheckedException{ // Check if entry we are going to write to is directory. if (lockInfos.get(pathIds.lastExistingId()).isFile()) throw new IgfsParentNotDirectoryException("Failed to open file for write " + "(parent element is not a directory): " + pathIds.path()); return createFileOrDirectory(false, pathIds, lockInfos, dirProps, fileProps, blockSize, affKey, evictExclude, secondaryCtx, secondaryOutHolder); }
/** * Cast IO exception to IGFS exception. * * @param msg Error message. * @param e IO exception. * @return IGFS exception. */ public static IgfsException cast(String msg, IOException e) { if (e instanceof FileNotFoundException) return new IgfsPathNotFoundException(e); else if (e instanceof ParentNotDirectoryException) return new IgfsParentNotDirectoryException(msg, e); else if (e instanceof PathIsNotEmptyDirectoryException) return new IgfsDirectoryNotEmptyException(e); else if (e instanceof PathExistsException) return new IgfsPathAlreadyExistsException(msg, e); else return new IgfsException(msg, e); }
/** * @param errCode Error code. * @param err Error. * @throws IgniteCheckedException Based on error code. */ public static void throwError(Integer errCode, String err) throws IgniteCheckedException { assert err != null; assert errCode != -1; if (errCode == ERR_FILE_NOT_FOUND) throw new IgfsPathNotFoundException(err); else if (errCode == ERR_PATH_ALREADY_EXISTS) throw new IgfsPathAlreadyExistsException(err); else if (errCode == ERR_DIRECTORY_NOT_EMPTY) throw new IgfsDirectoryNotEmptyException(err); else if (errCode == ERR_PARENT_NOT_DIRECTORY) throw new IgfsParentNotDirectoryException(err); else if (errCode == ERR_INVALID_HDFS_VERSION) throw new IgfsInvalidHdfsVersionException(err); else if (errCode == ERR_CORRUPTED_FILE) throw new IgfsCorruptedFileException(err); else if (errCode == ERR_IGFS_GENERIC) throw new IgfsException(err); throw new IgniteCheckedException(err); }
return false; else throw new IgfsParentNotDirectoryException("Failed to create directory (parent " + "element is not a directory)");
/** * Create directory and it's parents. * * @param pathIds Path IDs. * @param lockInfos Lock infos. * @param dirProps Directory properties. * @return Result or {@code} if the first parent already contained child with the same name. * @throws IgniteCheckedException If failed. */ @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos, Map<String, String> dirProps) throws IgniteCheckedException { // Check if entry we are going to write to is directory. if (lockInfos.get(pathIds.lastExistingId()).isFile()) throw new IgfsParentNotDirectoryException("Failed to create directory (parent " + "element is not a directory)"); return createFileOrDirectory(true, pathIds, lockInfos, dirProps, null, 0, null, false, null, null); }
/** * Create file and all it's parents. * * @param pathIds Paths IDs. * @param lockInfos Lock infos. * @param dirProps Directory properties. * @param fileProps File propertris. * @param blockSize Block size. * @param affKey Affinity key (optional) * @param evictExclude Evict exclude flag. * @param secondaryCtx Secondary file system create context. * @param secondaryOutHolder Holder for the secondary output stream. * @return Result or {@code} if the first parent already contained child with the same name. * @throws IgniteCheckedException If failed. */ @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude, @Nullable IgfsSecondaryFileSystemCreateContext secondaryCtx, @Nullable T1<OutputStream> secondaryOutHolder) throws IgniteCheckedException{ // Check if entry we are going to write to is directory. if (lockInfos.get(pathIds.lastExistingId()).isFile()) throw new IgfsParentNotDirectoryException("Failed to open file for write " + "(parent element is not a directory): " + pathIds.path()); return createFileOrDirectory(false, pathIds, lockInfos, dirProps, fileProps, blockSize, affKey, evictExclude, secondaryCtx, secondaryOutHolder); }
/** * @param errCode Error code. * @param err Error. * @throws IgniteCheckedException Based on error code. */ public static void throwError(Integer errCode, String err) throws IgniteCheckedException { assert err != null; assert errCode != -1; if (errCode == ERR_FILE_NOT_FOUND) throw new IgfsPathNotFoundException(err); else if (errCode == ERR_PATH_ALREADY_EXISTS) throw new IgfsPathAlreadyExistsException(err); else if (errCode == ERR_DIRECTORY_NOT_EMPTY) throw new IgfsDirectoryNotEmptyException(err); else if (errCode == ERR_PARENT_NOT_DIRECTORY) throw new IgfsParentNotDirectoryException(err); else if (errCode == ERR_INVALID_HDFS_VERSION) throw new IgfsInvalidHdfsVersionException(err); else if (errCode == ERR_CORRUPTED_FILE) throw new IgfsCorruptedFileException(err); else if (errCode == ERR_IGFS_GENERIC) throw new IgfsException(err); throw new IgniteCheckedException(err); }
return false; else throw new IgfsParentNotDirectoryException("Failed to create directory (parent " + "element is not a directory)");