void addCache ( Path hdfsPath , Path localPath , long size ) throws IOException { localMetrics . numAdd ++ ; CacheEntry c = new CacheEntry ( hdfsPath , localPath , size ) ; CacheEntry found = cacheMap . putIfAbsent ( hdfsPath , c ) ; if ( found != null ) { // If entry was already in the cache, update its timestamp assert size == found . entrySize ; assert localPath . equals ( found . localPath ) ; found . setGenstamp ( globalStamp . incrementAndGet ( ) ) ; localMetrics . numAddExisting ++ ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "LookasideCache updating path " + hdfsPath ) ; } } else { // We just inserted an entry in the cache. Increment the // recorded size of the cache. cacheSize . addAndGet ( size ) ; localMetrics . numAddNew ++ ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "LookasideCache add new path:" + hdfsPath + " cachedPath:" + localPath + " size " + size ) ; } } // check if we need to evict because cache is full if ( cacheSize . get ( ) > cacheSizeMax ) { checkEvict ( ) ; } }
Adds an entry into the cache . The size is the virtual size of this entry .