/** * Call when application exits, if you have previously called initNetcdfFileCache. * This shuts down any background threads in order to get a clean process shutdown. */ static public void shutdown() { FileCache.shutdown(); }
public synchronized void close() throws java.io.IOException { if (objCache != null) { if (objCache.release(this)) return; } }
/** * Acquire a FileCacheable, and lock it so no one else can use it. * call FileCacheable.close when done. * * @param factory use this factory to open the file; may not be null * @param durl file location, also used as the cache name, will be passed to the NetcdfFileFactory * @param cancelTask user can cancel, ok to be null. * @return NetcdfFile corresponding to location. * @throws IOException on error */ public FileCacheable acquire(FileFactory factory, DatasetUrl durl, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquire(factory, durl.trueurl, durl, -1, cancelTask, null); }
static public GribCollectionImmutable acquireGribCollection(FileFactory factory, Object hashKey, String location, int buffer_size, CancelTask cancelTask, Object spiObject) throws IOException { FileCacheable result; DatasetUrl durl = new DatasetUrl(null, location); if (gribCollectionCache != null) { // FileFactory factory, Object hashKey, String location, int buffer_size, CancelTask cancelTask, Object spiObject result = GribCdmIndex.gribCollectionCache.acquire(factory, hashKey, durl, buffer_size, cancelTask, spiObject); } else { // String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object iospMessage result = factory.open(durl, buffer_size, cancelTask, spiObject); } return (GribCollectionImmutable) result; }
public String toString() { return isLocked + " " + ncfile.getLocation(); }
public void run() { cleanup(softLimit); } }
static public void disableNetcdfFileCache() { if (null != fileCache) fileCache.disable(); fileCache = null; }
static public void disableGribCollectionCache() { if (null != gribCollectionCache) gribCollectionCache.disable(); gribCollectionCache = null; }
static public void initDefaultCollectionCache(int minElementsInMemory, int maxElementsInMemory, int period) { // gribCollectionCache = new ucar.nc2.util.cache.FileCache("DefaultGribCollectionCache", minElementsInMemory, maxElementsInMemory, -1, period); gribCollectionCache = new ucar.nc2.util.cache.FileCacheGuava("DefaultGribCollectionCache", maxElementsInMemory); }
@Override public void disable() { clearCache(true); cache = null; }
/** * Acquire a FileCacheable, and lock it so no one else can use it. * call FileCacheable.close() when done. * * @param factory use this factory to open the file; may not be null * @param location file location, also used as the cache name, will be passed to the NetcdfFileFactory * @param cancelTask user can cancel, ok to be null. * @return NetcdfFile corresponding to location. * @throws IOException on error */ public FileCacheable acquire(FileFactory factory, String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquire(factory, location, location, -1, cancelTask, null); }
/** * Call when application exits, if you have previously called initNetcdfFileCache. * This shuts down any background threads in order to get a clean process shutdown. */ static public void shutdown() { FileCache.shutdown(); }
static public synchronized void disableNetcdfFileCache() { if (null != netcdfFileCache) netcdfFileCache.disable(); netcdfFileCache = null; }
static public synchronized void setGlobalFileCache(FileCacheIF _cache) { if (cache != null) cache.disable(); cache = _cache; }
@Override public FileCacheable acquire(FileFactory factory, DatasetUrl durl) throws IOException { return acquire(factory, durl.trueurl, durl, -1, null, null); }
static public void disableNetcdfFileCache() { if (null != fileCache) fileCache.disable(); fileCache = null; }
static public void setGribCollectionCache(FileCacheIF cache) { if (null != gribCollectionCache) gribCollectionCache.disable(); gribCollectionCache = cache; }
/** * Acquire a FileCacheable, and lock it so no one else can use it. * call FileCacheable.close() when done. * * @param factory use this factory to open the file; may not be null * @param location file location, also used as the cache name, will be passed to the NetcdfFileFactory * @param cancelTask user can cancel, ok to be null. * @return NetcdfFile corresponding to location. * @throws IOException on error */ public FileCacheable acquire(FileFactory factory, String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquire(factory, location, location, -1, cancelTask, null); }
@Override public FileCacheable acquire(FileFactory factory, String location) throws IOException { return acquire(factory, location, location, -1, null, null); }