コード例 #1
0
        /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException"/>
        /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaExceededException"/>
        internal static INodeSymlink UnprotectedAddSymlink(FSDirectory fsd, INodesInPath
                                                           iip, byte[] localName, long id, string target, long mtime, long atime, PermissionStatus
                                                           perm)
        {
            System.Diagnostics.Debug.Assert(fsd.HasWriteLock());
            INodeSymlink symlink = new INodeSymlink(id, null, perm, mtime, atime, target);

            symlink.SetLocalName(localName);
            return(fsd.AddINode(iip, symlink) != null ? symlink : null);
        }
コード例 #2
0
 /// <exception cref="System.IO.IOException"/>
 private void Save(OutputStream @out, INodeSymlink n)
 {
     FSImageFormatProtobuf.SaverContext             state = parent.GetSaverContext();
     FsImageProto.INodeSection.INodeSymlink.Builder b     = FsImageProto.INodeSection.INodeSymlink
                                                            .NewBuilder().SetPermission(BuildPermissionStatus(n, state.GetStringMap())).SetTarget
                                                                (ByteString.CopyFrom(n.GetSymlink())).SetModificationTime(n.GetModificationTime(
                                                                                                                              )).SetAccessTime(n.GetAccessTime());
     FsImageProto.INodeSection.INode r = ((FsImageProto.INodeSection.INode)BuildINodeCommon
                                              (n).SetType(FsImageProto.INodeSection.INode.Type.Symlink).SetSymlink(b).Build());
     r.WriteDelimitedTo(@out);
 }
コード例 #3
0
            private INodeSymlink LoadINodeSymlink(FsImageProto.INodeSection.INode n)
            {
                System.Diagnostics.Debug.Assert(n.GetType() == FsImageProto.INodeSection.INode.Type
                                                .Symlink);
                FsImageProto.INodeSection.INodeSymlink s = n.GetSymlink();
                PermissionStatus permissions             = LoadPermission(s.GetPermission(), parent.GetLoaderContext
                                                                              ().GetStringTable());
                INodeSymlink sym = new INodeSymlink(n.GetId(), n.GetName().ToByteArray(), permissions
                                                    , s.GetModificationTime(), s.GetAccessTime(), s.GetTarget().ToStringUtf8());

                return(sym);
            }
コード例 #4
0
 /// <summary>
 /// Serialize a
 /// <see cref="INodeSymlink"/>
 /// node
 /// </summary>
 /// <param name="node">The node to write</param>
 /// <param name="out">
 /// The
 /// <see cref="System.IO.DataOutput"/>
 /// where the fields are written
 /// </param>
 /// <exception cref="System.IO.IOException"/>
 private static void WriteINodeSymlink(INodeSymlink node, DataOutput @out)
 {
     WriteLocalName(node, @out);
     @out.WriteLong(node.GetId());
     @out.WriteShort(0);
     // replication
     @out.WriteLong(0);
     // modification time
     @out.WriteLong(0);
     // access time
     @out.WriteLong(0);
     // preferred block size
     @out.WriteInt(-2);
     // # of blocks
     Text.WriteString(@out, node.GetSymlinkString());
     WritePermissionStatus(node, @out);
 }
コード例 #5
0
        /// <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);
        }