/** * Returns the closest ancestor of the target inode (last inode in the full path). * * @return the closest ancestor inode * @throws FileDoesNotExistException if an ancestor does not exist */ public Inode getAncestorInode() throws FileDoesNotExistException { int ancestorIndex = mPathComponents.length - 2; if (ancestorIndex < 0) { throw new FileDoesNotExistException(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(mUri)); } ancestorIndex = Math.min(ancestorIndex, mExistingInodes.size() - 1); return mExistingInodes.get(ancestorIndex); }
/** * {@inheritDoc} * * If the file does not exist in Alluxio, query it from HDFS. */ @Override public FileStatus getFileStatus(Path path) throws IOException { LOG.debug("getFileStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); URIStatus fileStatus; try { fileStatus = mFileSystem.getStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(e.getMessage()); } catch (AlluxioException e) { throw new IOException(e); } return new FileStatus(fileStatus.getLength(), fileStatus.isFolder(), getReplica(fileStatus), fileStatus.getBlockSizeBytes(), fileStatus.getLastModificationTimeMs(), fileStatus.getCreationTimeMs(), new FsPermission((short) fileStatus.getMode()), fileStatus.getOwner(), fileStatus.getGroup(), new Path(mAlluxioHeader + uri)); }
response.setFatalError("Error: File does not exist " + e.getLocalizedMessage()); return response; } catch (AccessControlException e) {
UIFileInfo currentFileInfo = new UIFileInfo(fileInfo); if (currentFileInfo.getAbsolutePath() == null) { throw new FileDoesNotExistException(currentPath.toString()); ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.ALWAYS))); } catch (FileDoesNotExistException e) { response.setInvalidPathError("Error: Invalid Path " + e.getMessage()); return response; } catch (InvalidPathException e) { response.setFileDoesNotExistException("Error: non-existing file " + e.getMessage()); return response; } catch (InvalidPathException e) {
FileInfo fileInfo = mFsMaster.getFileInfo(fileId); if (fileInfo == null) { throw new FileDoesNotExistException(currentPath.toString()); request.setAttribute("invalidPathError", "Error: Invalid Path " + e.getMessage()); getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response); } catch (InvalidPathException e) {
/** * @return the target inode * @throws FileDoesNotExistException if the target inode does not exist */ public Inode getInode() throws FileDoesNotExistException { Inode inode = getInodeOrNull(); if (inode == null) { throw new FileDoesNotExistException(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(mUri)); } return inode; }
UIFileInfo currentFileInfo = new UIFileInfo(fileInfo); if (currentFileInfo.getAbsolutePath() == null) { throw new FileDoesNotExistException(currentPath.toString()); ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Always)); } catch (FileDoesNotExistException e) { request.setAttribute("invalidPathError", "Error: Invalid Path " + e.getMessage()); getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response); return; "Error: non-existing file " + e.getMessage()); getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response); return;
mFileSystem.rename(srcPath, dstPath); } catch (FileDoesNotExistException e) { LOG.warn("rename failed: {}", e.getMessage()); return false; } catch (AlluxioException e) {
"Error: File does not exist " + e.getLocalizedMessage()); getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response); return;
/** * Checks the {@link LoadMetadataPType} to determine whether or not to proceed in loading * metadata. This method assumes that the path does not exist in Alluxio namespace, and will * throw an exception if metadata should not be loaded. * * @param loadMetadataType the {@link LoadMetadataPType} to check * @param path the path that does not exist in Alluxio namespace (used for exception message) */ private void checkLoadMetadataOptions(LoadMetadataPType loadMetadataType, AlluxioURI path) throws FileDoesNotExistException { if (loadMetadataType == LoadMetadataPType.NEVER || (loadMetadataType == LoadMetadataPType.ONCE && mUfsAbsentPathCache.isAbsent(path))) { throw new FileDoesNotExistException(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(path)); } }
LOG.warn("Failed to check replication level for inode id {} : {}", inodeId, e.getMessage());
/** * Tells the mock to throw FileDoesNotExistException when the given path is queried. */ private void setPathToNotExist(String path) throws Exception { AlluxioURI uri = new AlluxioURI(path); when(mMockFileSystem.getStatus(uri)).thenThrow(new FileDoesNotExistException(uri)); when(mMockFileSystem.listStatus(uri)).thenThrow(new FileDoesNotExistException(uri)); } }
.setBlockSizeBytes(uiFileInfo.getBlockSizeBytes()).setPath(requestPath); } catch (FileDoesNotExistException e) { response.setFatalError("Error: Invalid Path " + e.getMessage()); } catch (IOException e) { response.setInvalidPathError(
@Override protected void runPlainPath(AlluxioURI plainPath, CommandLine cl) throws AlluxioException, IOException { URIStatus status = mFileSystem.getStatus(plainPath); if (status.isFolder()) { throw new FileDoesNotExistException( ExceptionMessage.PATH_MUST_BE_FILE.getMessage(plainPath.getPath())); } String str = calculateChecksum(plainPath); System.out.println("md5sum: " + str + "\n"); }
@Test public void moveMissingSource() throws Exception { setPathToNotExist("/notExist"); try { assignMovesFail("/notExist", "/dst"); } catch (FileDoesNotExistException e) { Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/notExist"), e.getMessage()); } }
/** * @return the target inode as an {@link MutableInodeFile} * @throws FileDoesNotExistException if the target inode does not exist, or it is not a file */ public InodeFile getInodeFile() throws FileDoesNotExistException { Inode inode = getInode(); if (!inode.isFile()) { throw new FileDoesNotExistException(ExceptionMessage.PATH_MUST_BE_FILE.getMessage(mUri)); } return inode.asFile(); }
/** * Attempts to delete the file or directory with the specified path. * * @param cPath path to delete * @param recursive if true, will attempt to delete all children of the path * @return true if one or more files/directories were deleted; false otherwise * @throws IOException if the path failed to be deleted due to some constraint (ie. non empty * directory with recursive flag disabled) */ @Override public boolean delete(Path cPath, boolean recursive) throws IOException { LOG.info("delete({}, {})", cPath, recursive); if (mStatistics != null) { mStatistics.incrementWriteOps(1); } AlluxioURI path = new AlluxioURI(HadoopUtils.getPathWithoutScheme(cPath)); DeleteOptions options = DeleteOptions.defaults().setRecursive(recursive); try { mFileSystem.delete(path, options); return true; } catch (InvalidPathException e) { LOG.info("delete failed: {}", e.getMessage()); return false; } catch (FileDoesNotExistException e) { LOG.info("delete failed: {}", e.getMessage()); return false; } catch (AlluxioException e) { throw new IOException(e); } }
Optional<Inode> parentInode = mInodeStore.get(parentId); if (!parentInode.isPresent()) { throw new FileDoesNotExistException( ExceptionMessage.INODE_DOES_NOT_EXIST.getMessage(parentId));
/** * {@inheritDoc} * * If the file does not exist in Alluxio, query it from HDFS. */ @Override public FileStatus getFileStatus(Path path) throws IOException { LOG.debug("getFileStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); URIStatus fileStatus; try { fileStatus = mFileSystem.getStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(e.getMessage()); } catch (AlluxioException e) { throw new IOException(e); } return new FileStatus(fileStatus.getLength(), fileStatus.isFolder(), getReplica(fileStatus), fileStatus.getBlockSizeBytes(), fileStatus.getLastModificationTimeMs(), fileStatus.getCreationTimeMs(), new FsPermission((short) fileStatus.getMode()), fileStatus.getOwner(), fileStatus.getGroup(), new Path(mAlluxioHeader + uri)); }
/** * Locks a path and throws an exception if the path does not exist. * * @param uri a uri to lock * @param lockPattern the pattern to lock with * @return a locked inode path for the uri */ public LockedInodePath lockFullInodePath(AlluxioURI uri, LockPattern lockPattern) throws InvalidPathException, FileDoesNotExistException { LockedInodePath inodePath = lockInodePath(uri, lockPattern); if (!inodePath.fullPathExists()) { inodePath.close(); throw new FileDoesNotExistException(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(uri)); } return inodePath; }