Ejemplo n.º 1
0
 /// <summary>
 /// This method will reduce the file count for the directory represented by
 /// path.
 /// </summary>
 /// <remarks>
 /// This method will reduce the file count for the directory represented by
 /// path. The root directory of this Local cache directory manager is
 /// represented by an empty string.
 /// </remarks>
 public virtual void DecrementFileCountForPath(string relPath)
 {
     lock (this)
     {
         relPath = relPath == null ? string.Empty : relPath.Trim();
         LocalCacheDirectoryManager.Directory subDir = knownDirectories[relPath];
         int oldCount = subDir.GetCount();
         if (subDir.DecrementAndGetCount() < perDirectoryFileLimit && oldCount >= perDirectoryFileLimit)
         {
             nonFullDirectories.AddItem(subDir);
         }
     }
 }
Ejemplo n.º 2
0
 public LocalCacheDirectoryManager(Configuration conf)
 {
     // total 36 = a to z plus 0 to 9
     totalSubDirectories = 0;
     LocalCacheDirectoryManager.Directory rootDir = new LocalCacheDirectoryManager.Directory
                                                        (totalSubDirectories);
     nonFullDirectories             = new List <LocalCacheDirectoryManager.Directory>();
     knownDirectories               = new Dictionary <string, LocalCacheDirectoryManager.Directory>();
     knownDirectories[string.Empty] = rootDir;
     nonFullDirectories.AddItem(rootDir);
     this.perDirectoryFileLimit = conf.GetInt(YarnConfiguration.NmLocalCacheMaxFilesPerDirectory
                                              , YarnConfiguration.DefaultNmLocalCacheMaxFilesPerDirectory) - 36;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// This method will return relative path from the first available vacant
 /// directory.
 /// </summary>
 /// <returns>
 ///
 /// <see cref="string"/>
 /// relative path for localization
 /// </returns>
 public virtual string GetRelativePathForLocalization()
 {
     lock (this)
     {
         if (nonFullDirectories.IsEmpty())
         {
             totalSubDirectories++;
             LocalCacheDirectoryManager.Directory newDir = new LocalCacheDirectoryManager.Directory
                                                               (totalSubDirectories);
             nonFullDirectories.AddItem(newDir);
             knownDirectories[newDir.GetRelativePath()] = newDir;
         }
         LocalCacheDirectoryManager.Directory subDir = nonFullDirectories.Peek();
         if (subDir.IncrementAndGetCount() >= perDirectoryFileLimit)
         {
             nonFullDirectories.Remove();
         }
         return(subDir.GetRelativePath());
     }
 }
Ejemplo n.º 4
0
 /// <summary>Increment the file count for a relative directory within the cache</summary>
 /// <param name="relPath">the relative path</param>
 public virtual void IncrementFileCountForPath(string relPath)
 {
     lock (this)
     {
         relPath = relPath == null ? string.Empty : relPath.Trim();
         LocalCacheDirectoryManager.Directory subDir = knownDirectories[relPath];
         if (subDir == null)
         {
             int dirnum = LocalCacheDirectoryManager.Directory.GetDirectoryNumber(relPath);
             totalSubDirectories = Math.Max(dirnum, totalSubDirectories);
             subDir = new LocalCacheDirectoryManager.Directory(dirnum);
             nonFullDirectories.AddItem(subDir);
             knownDirectories[subDir.GetRelativePath()] = subDir;
         }
         if (subDir.IncrementAndGetCount() >= perDirectoryFileLimit)
         {
             nonFullDirectories.Remove(subDir);
         }
     }
 }