Пример #1
0
        /// <exception cref="System.IO.IOException"/>
        internal static HdfsFileStatus SetTimes(FSDirectory fsd, string src, long mtime,
                                                long atime)
        {
            if (!fsd.IsAccessTimeSupported() && atime != -1)
            {
                throw new IOException("Access time for hdfs is not configured. " + " Please set "
                                      + DFSConfigKeys.DfsNamenodeAccesstimePrecisionKey + " configuration parameter."
                                      );
            }
            FSPermissionChecker pc = fsd.GetPermissionChecker();

            byte[][]     pathComponents = FSDirectory.GetPathComponentsForReservedPath(src);
            INodesInPath iip;

            fsd.WriteLock();
            try
            {
                src = fsd.ResolvePath(pc, src, pathComponents);
                iip = fsd.GetINodesInPath4Write(src);
                // Write access is required to set access and modification times
                if (fsd.IsPermissionEnabled())
                {
                    fsd.CheckPathAccess(pc, iip, FsAction.Write);
                }
                INode inode = iip.GetLastINode();
                if (inode == null)
                {
                    throw new FileNotFoundException("File/Directory " + src + " does not exist.");
                }
                bool changed = UnprotectedSetTimes(fsd, inode, mtime, atime, true, iip.GetLatestSnapshotId
                                                       ());
                if (changed)
                {
                    fsd.GetEditLog().LogTimes(src, mtime, atime);
                }
            }
            finally
            {
                fsd.WriteUnlock();
            }
            return(fsd.GetAuditFileInfo(iip));
        }