Beispiel #1
0
 /// <exception cref="System.IO.IOException"/>
 private void AssertAttributesChanged()
 {
     Assert.True(ModificationTime != fs.GetFileStatus(To).GetModificationTime
                     ());
     Assert.True(!Permissions.Equals(fs.GetFileStatus(To).GetPermission
                                         ()));
 }
Beispiel #2
0
 /// <exception cref="System.IO.IOException"/>
 private void CreateDir(Path path, FsPermission perm)
 {
     files.Mkdir(path, perm, false);
     if (!perm.Equals(files.GetUMask().ApplyUMask(perm)))
     {
         files.SetPermission(path, perm);
     }
 }
 /// <exception cref="System.IO.IOException"/>
 private static void CreateDir(FileContext lfs, Path dirPath, FsPermission perms,
                               bool createParent)
 {
     lfs.Mkdir(dirPath, perms, createParent);
     if (!perms.Equals(perms.ApplyUMask(lfs.GetUMask())))
     {
         lfs.SetPermission(dirPath, perms);
     }
 }
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual void CreateDir(Path dirPath, FsPermission perms, bool
                                           createParent, string user)
 {
     lfs.Mkdir(dirPath, perms, createParent);
     if (!perms.Equals(perms.ApplyUMask(lfs.GetUMask())))
     {
         lfs.SetPermission(dirPath, perms);
     }
 }
Beispiel #5
0
        /// <exception cref="System.IO.IOException"/>
        private void CreateDir(FileSystem fs, Path path, FsPermission fsPerm)
        {
            FsPermission dirPerm = new FsPermission(fsPerm);

            fs.Mkdirs(path, dirPerm);
            FsPermission umask = FsPermission.GetUMask(fs.GetConf());

            if (!dirPerm.Equals(dirPerm.ApplyUMask(umask)))
            {
                fs.SetPermission(path, new FsPermission(fsPerm));
            }
        }
Beispiel #6
0
        internal virtual void VerifyAndCreateRemoteLogDir(Configuration conf)
        {
            // Checking the existence of the TLD
            FileSystem remoteFS = null;

            try
            {
                remoteFS = GetFileSystem(conf);
            }
            catch (IOException e)
            {
                throw new YarnRuntimeException("Unable to get Remote FileSystem instance", e);
            }
            bool remoteExists = true;

            try
            {
                FsPermission perms = remoteFS.GetFileStatus(this.remoteRootLogDir).GetPermission(
                    );
                if (!perms.Equals(TldirPermissions))
                {
                    Log.Warn("Remote Root Log Dir [" + this.remoteRootLogDir + "] already exist, but with incorrect permissions. "
                             + "Expected: [" + TldirPermissions + "], Found: [" + perms + "]." + " The cluster may have problems with multiple users."
                             );
                }
            }
            catch (FileNotFoundException)
            {
                remoteExists = false;
            }
            catch (IOException e)
            {
                throw new YarnRuntimeException("Failed to check permissions for dir [" + this.remoteRootLogDir
                                               + "]", e);
            }
            if (!remoteExists)
            {
                Log.Warn("Remote Root Log Dir [" + this.remoteRootLogDir + "] does not exist. Attempting to create it."
                         );
                try
                {
                    Path qualified = this.remoteRootLogDir.MakeQualified(remoteFS.GetUri(), remoteFS.
                                                                         GetWorkingDirectory());
                    remoteFS.Mkdirs(qualified, new FsPermission(TldirPermissions));
                    remoteFS.SetPermission(qualified, new FsPermission(TldirPermissions));
                }
                catch (IOException e)
                {
                    throw new YarnRuntimeException("Failed to create remoteLogDir [" + this.remoteRootLogDir
                                                   + "]", e);
                }
            }
        }
Beispiel #7
0
        /// <exception cref="System.IO.IOException"/>
        private bool CheckExists(FileSystem fs, Path path, FsPermission fsPerm)
        {
            bool exists = true;

            try
            {
                FileStatus appDirStatus = fs.GetFileStatus(path);
                if (!AppDirPermissions.Equals(appDirStatus.GetPermission()))
                {
                    fs.SetPermission(path, AppDirPermissions);
                }
            }
            catch (FileNotFoundException)
            {
                exists = false;
            }
            return(exists);
        }
 /// <exception cref="System.IO.IOException"/>
 private void CreateDir(FileContext localFs, Path dir, FsPermission perm)
 {
     if (dir == null)
     {
         return;
     }
     try
     {
         localFs.GetFileStatus(dir);
     }
     catch (FileNotFoundException)
     {
         CreateDir(localFs, dir.GetParent(), perm);
         localFs.Mkdir(dir, perm, false);
         if (!perm.Equals(perm.ApplyUMask(localFs.GetUMask())))
         {
             localFs.SetPermission(dir, perm);
         }
     }
 }