private static void deleteCache ( Configuration conf , MRAsyncDiskService asyncDiskService ) throws IOException { List < CacheStatus > deleteSet = new LinkedList < CacheStatus > ( ) ; // try deleting cache Status with refcount of zero synchronized ( cachedArchives ) { for ( Iterator < String > it = cachedArchives . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { String cacheId = ( String ) it . next ( ) ; CacheStatus lcacheStatus = cachedArchives . get ( cacheId ) ; if ( lcacheStatus . refcount == 0 ) { // delete this cache entry from the global list // and mark the localized file for deletion deleteSet . add ( lcacheStatus ) ; it . remove ( ) ; } } } // do the deletion asynchronously, after releasing the global lock Thread cacheFileCleaner = new Thread ( new CacheFileCleanTask ( asyncDiskService , FileSystem . getLocal ( conf ) , deleteSet ) ) ; cacheFileCleaner . start ( ) ; }
To delete the caches which have a refcount of zero