private CacheFile(FileCacheable ncfile) { this.ncfile = ncfile; ncfile.setFileCache(FileCacheARC.this); if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCacheARC " + name + " add to cache " + hashKey); if (debugPrint) System.out.println(" FileCacheARC " + name + " add to cache " + hashKey); }
private CacheFile(FileCacheable ncfile) { this.ncfile = ncfile; ncfile.setFileCache(FileCacheARC.this); if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCacheARC " + name + " add to cache " + hashKey); if (debugPrint) System.out.println(" FileCacheARC " + name + " add to cache " + hashKey); }
private void expireFromCache(CacheElement elem) { for (CacheElement.CacheFile cacheFile : elem.list) { cacheFile.ncfile.setFileCache(null); // next time it closes, it will really close LOOK race condition ?? cacheSize.getAndDecrement(); } cache.remove(elem.hashKey); shadowCache.remove(elem); }
private CacheFile(FileCacheable ncfile) { this.ncfile = ncfile; this.lastModified = ncfile.getLastModified(); this.lastAccessed = System.currentTimeMillis(); ncfile.setFileCache(FileCache.this); if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCache " + name + " add to cache " + hashKey); if (debugPrint) System.out.println(" FileCache " + name + " add to cache " + hashKey); }
private CacheFile(FileCacheable ncfile) { this.ncfile = ncfile; this.lastModified = ncfile.getLastModified(); this.lastAccessed = System.currentTimeMillis(); ncfile.setFileCache(FileCache.this); if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCache " + name + " add to cache " + hashKey); if (debugPrint) System.out.printf(" FileCache %s add to cache %s (hash %d)%n", name, hashKey, this.hashCode()); }
private CacheFile(FileCacheable ncfile) { this.ncfile = ncfile; this.lastModified = ncfile.getLastModified(); this.lastAccessed = System.currentTimeMillis(); ncfile.setFileCache(FileCache.this); if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCache " + name + " add to cache " + hashKey); if (debugPrint) System.out.println(" FileCache " + name + " add to cache " + hashKey); }
private void expireFromCache(CacheElement elem) { for (CacheElement.CacheFile cacheFile : elem.list) { cacheFile.ncfile.setFileCache(null); // next time it closes, it will really close LOOK race condition ?? cacheSize.getAndDecrement(); } cache.remove(elem.hashKey); shadowCache.remove(elem); }
void close() { // really close the file ncfile.setFileCache(null); try { ncfile.close(); } catch (IOException e) { log.error("close failed on "+ncfile.getLocation(), e); } if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCacheARC " + name + " remove " + ncfile.getLocation()); if (debugPrint) System.out.println(" FileCacheARC " + name + " remove " + ncfile.getLocation()); ncfile = null; }
private void remove(CacheElement.CacheFile want) { want.remove(); files.remove(want.ncfile); try { want.ncfile.setFileCache(null); // unhook the caching want.ncfile.close(); } catch (IOException e) { log.error("close failed on "+want.ncfile.getLocation(), e); } want.ncfile = null; }
void close() { // really close the file ncfile.setFileCache(null); try { ncfile.close(); } catch (IOException e) { log.error("close failed on "+ncfile.getLocation(), e); } if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCacheARC " + name + " remove " + ncfile.getLocation()); if (debugPrint) System.out.println(" FileCacheARC " + name + " remove " + ncfile.getLocation()); ncfile = null; }
file.ncfile.setFileCache(null); file.ncfile.close();
/** * Remove all instances of object from the cache * @param hashKey the object */ public void remove(Object hashKey) { if (disabled.get()) return; // see if its in the cache CacheElement wantCacheElem = cache.get(hashKey); if (wantCacheElem == null) return; synchronized (wantCacheElem) { // synch in order to traverse the list for (CacheElement.CacheFile want : wantCacheElem.list) { files.remove(want.ncfile); want.ncfile.setFileCache(null); // unhook the caching try { want.ncfile.close(); // really close the file log.debug("close "+want.ncfile.getLocation()); } catch (IOException e) { log.error("close failed on "+want.ncfile.getLocation(), e); } want.ncfile = null; } wantCacheElem.list.clear(); } cache.remove(hashKey); }
/** * Remove all instances of object from the cache * @param hashKey */ public void remove(Object hashKey) { if (disabled.get()) return; // see if its in the cache CacheElement wantCacheElem = cache.get(hashKey); if (wantCacheElem == null) return; synchronized (wantCacheElem) { // synch in order to traverse the list for (CacheElement.CacheFile want : wantCacheElem.list) { files.remove(want.ncfile); want.ncfile.setFileCache(null); // unhook the caching try { want.ncfile.close(); // really close the file log.debug("close "+want.ncfile.getLocation()); } catch (IOException e) { log.error("close failed on "+want.ncfile.getLocation(), e); } want.ncfile = null; } wantCacheElem.list.clear(); } cache.remove(hashKey); }
file.ncfile.setFileCache(null); file.ncfile.close();
ncfile.setFileCache(null); // prevent infinite loops ncfile.close(); return;
/** * Remove all instances of object from the cache * @param hashKey the object */ @Override public void eject(Object hashKey) { if (disabled.get()) return; // see if its in the cache CacheElement wantCacheElem = cache.get(hashKey); if (wantCacheElem == null) return; synchronized (wantCacheElem) { // synch in order to traverse the list for (CacheElement.CacheFile want : wantCacheElem.list) { // LOOK can we use remove(want); ?? files.remove(want.ncfile); try { want.ncfile.setFileCache(null); // unhook the caching want.ncfile.close(); // really close the file log.debug("close "+want.ncfile.getLocation()); } catch (IOException e) { log.error("close failed on "+want.ncfile.getLocation(), e); } want.ncfile = null; if (debugPrint) System.out.println(" FileCache " + name + " eject " + hashKey); } wantCacheElem.list.clear(); } cache.remove(hashKey); }
ncfile.setFileCache(null); // prevent infinite loops ncfile.close(); return;
/** * Release the file. This unlocks it, updates its lastAccessed date. * Normally applications need not call this, just close the file as usual. * * @param ncfile release this file. * @throws IOException if file not in cache. */ public void release(FileCacheable ncfile) throws IOException { if (ncfile == null) return; if (disabled.get()) { ncfile.setFileCache(null); // prevent infinite loops ncfile.close(); return; } // find it in the file cache CacheElement.CacheFile file = files.get(ncfile); // using hashCode of the FileCacheable if (file != null) { if (!file.isLocked.get()) { Exception e = new Exception("Stack trace"); cacheLog.warn("FileCache " + name + " release " + ncfile.getLocation() + " not locked; hash= "+ncfile.hashCode(), e); } file.lastAccessed = System.currentTimeMillis(); file.countAccessed++; file.isLocked.set(false); if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCache " + name + " release " + ncfile.getLocation()+"; hash= "+ncfile.hashCode()); if (debugPrint) System.out.println(" FileCache " + name + " release " + ncfile.getLocation()); return; } throw new IOException("FileCache " + name + " release does not have file in cache = " + ncfile.getLocation()); }
ncfile.setFileCache(null); // prevent infinite loops ncfile.close(); return false;
ncfile.setFileCache(null); // prevent infinite loops ncfile.close(); return false;