/// <summary>Add the given symbolic link to the fs.</summary> /// <remarks>Add the given symbolic link to the fs. Record it in the edits log.</remarks> /// <exception cref="System.IO.IOException"/> private static INodeSymlink AddSymlink(FSDirectory fsd, string path, INodesInPath iip, string target, PermissionStatus dirPerms, bool createParent, bool logRetryCache ) { long mtime = Time.Now(); byte[] localName = iip.GetLastLocalName(); if (createParent) { KeyValuePair <INodesInPath, string> e = FSDirMkdirOp.CreateAncestorDirectories(fsd , iip, dirPerms); if (e == null) { return(null); } iip = INodesInPath.Append(e.Key, null, localName); } string userName = dirPerms.GetUserName(); long id = fsd.AllocateNewInodeId(); PermissionStatus perm = new PermissionStatus(userName, null, FsPermission.GetDefault ()); INodeSymlink newNode = UnprotectedAddSymlink(fsd, iip.GetExistingINodes(), localName , id, target, mtime, mtime, perm); if (newNode == null) { NameNode.stateChangeLog.Info("addSymlink: failed to add " + path); return(null); } fsd.GetEditLog().LogSymlink(path, target, mtime, mtime, newNode, logRetryCache); if (NameNode.stateChangeLog.IsDebugEnabled()) { NameNode.stateChangeLog.Debug("addSymlink: " + path + " is added"); } return(newNode); }
/// <exception cref="System.IO.IOException"/> private static INodesInPath CreateSingleDirectory(FSDirectory fsd, INodesInPath existing , string localName, PermissionStatus perm) { System.Diagnostics.Debug.Assert(fsd.HasWriteLock()); existing = UnprotectedMkdir(fsd, fsd.AllocateNewInodeId(), existing, Sharpen.Runtime.GetBytesForString (localName, Charsets.Utf8), perm, null, Time.Now()); if (existing == null) { return(null); } INode newNode = existing.GetLastINode(); // Directory creation also count towards FilesCreated // to match count of FilesDeleted metric. NameNode.GetNameNodeMetrics().IncrFilesCreated(); string cur = existing.GetPath(); fsd.GetEditLog().LogMkDir(cur, newNode); if (NameNode.stateChangeLog.IsDebugEnabled()) { NameNode.stateChangeLog.Debug("mkdirs: created directory " + cur); } return(existing); }