/** * <br> * Note: This is to be used by {@link FSEditLogLoader} only. * <br> */ @Deprecated @SuppressWarnings("deprecation") static boolean renameForEditLog(FSDirectory fsd, String src, String dst, long timestamp) throws IOException { if (fsd.isDir(dst)) { dst += Path.SEPARATOR + new Path(src).getName(); } final INodesInPath srcIIP = fsd.getINodesInPath4Write(src, false); final INodesInPath dstIIP = fsd.getINodesInPath4Write(dst, false); return unprotectedRenameTo(fsd, src, dst, srcIIP, dstIIP, timestamp); }
/** Return if a directory is empty or not **/ boolean isDirEmpty(String src) { boolean dirNotEmpty = true; if (!isDir(src)) { return true; } synchronized(rootDir) { INode targetNode = rootDir.getNode(src); assert targetNode != null : "should be taken care in isDir() above"; if (((INodeDirectory)targetNode).getChildren().size() != 0) { dirNotEmpty = false; } } return dirNotEmpty; }
private void getListingCheck(String src, INode[] inodes) throws IOException { if (isPermissionEnabled) { if (FSDirectory.isDir(inodes[inodes.length-1])) { checkPathAccess(src, inodes, FsAction.READ_EXECUTE); } else { checkTraverse(src, inodes); } } }
/** * <br> * Note: This is to be used by {@link FSEditLogLoader} only. * <br> */ @Deprecated @SuppressWarnings("deprecation") static boolean renameForEditLog(FSDirectory fsd, String src, String dst, long timestamp) throws IOException { if (fsd.isDir(dst)) { dst += Path.SEPARATOR + new Path(src).getName(); } final INodesInPath srcIIP = fsd.getINodesInPath4Write(src, false); final INodesInPath dstIIP = fsd.getINodesInPath4Write(dst, false); return unprotectedRenameTo(fsd, src, dst, srcIIP, dstIIP, timestamp); }
/** * Check whether the path specifies a directory */ boolean isDir(String src) { readLock(); try { INode node = rootDir.getNode(normalizePath(src)); return isDir(node); } finally { readUnlock(); } }
private synchronized boolean renameToInternal(String src, String dst ) throws IOException { NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: " + src + " to " + dst); if (isInSafeMode()) throw new SafeModeException("Cannot rename " + src, safeMode); if (!DFSUtil.isValidName(dst)) { throw new IOException("Invalid name: " + dst); } if (isPermissionEnabled) { //We should not be doing this. This is move() not renameTo(). //but for now, String actualdst = dir.isDir(dst)? dst + Path.SEPARATOR + new Path(src).getName(): dst; checkParentAccess(src, FsAction.WRITE); checkAncestorAccess(actualdst, FsAction.WRITE); } FileStatus dinfo = dir.getFileInfo(dst); if (dir.renameTo(src, dst)) { changeLease(src, dst, dinfo); // update lease with new filename return true; } return false; }
/** * Get a listing of all files at 'src'. The Object[] array * exists so we can return file attributes (soon to be implemented) */ public FileStatus[] getListing(String src) throws IOException { if (isPermissionEnabled) { if (dir.isDir(src)) { checkPathAccess(src, FsAction.READ_EXECUTE); } else { checkTraverse(src); } } if (auditLog.isInfoEnabled()) { logAuditEvent(UserGroupInformation.getCurrentUGI(), Server.getRemoteIp(), "listStatus", src, null, null); } return dir.getListing(src); }
checkTraverse(src); if (dir.isDir(src)) {
return false; if (isDir(dst)) { dst += Path.SEPARATOR + new Path(src).getName();
String dst = dstIIP.getPath(); if (fsd.isDir(dst)) { dstIIP = INodesInPath.append(dstIIP, null, srcIIP.getLastLocalName());
String dst = dstIIP.getPath(); if (fsd.isDir(dst)) { dstIIP = INodesInPath.append(dstIIP, null, srcIIP.getLastLocalName());