/** * Enable file caching. call this before calling acquireFile(). * When application terminates, call NetcdfDataset.shutdown(). * * @param minElementsInMemory keep this number in the cache * @param maxElementsInMemory trigger a cleanup if it goes over this number. * @param hardLimit if > 0, never allow more than this many elements. This causes a cleanup to be done in * the calling thread. * @param period (secs) do periodic cleanups every this number of seconds. */ static public synchronized void initNetcdfFileCache( int minElementsInMemory, int maxElementsInMemory, int hardLimit, int period) { netcdfFileCache = new ucar.nc2.util.cache.FileCache( "NetcdfFileCache ", minElementsInMemory, maxElementsInMemory, hardLimit, period); }
/** * Enable file caching. call this before calling acquireFile(). * When application terminates, call NetcdfDataset.shutdown(). * * @param minElementsInMemory keep this number in the cache * @param maxElementsInMemory trigger a cleanup if it goes over this number. * @param period (secs) do periodic cleanups every this number of seconds. */ static public void initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int period) { fileCache = new ucar.nc2.util.cache.FileCache("NetcdfFileCache ", minElementsInMemory, maxElementsInMemory, -1, period); defaultNetcdfFileFactory = new MyNetcdfFileFactory(); }
static public synchronized void enableDefaultGlobalFileCache() { if (cache != null) cache.disable(); cache = new FileCache("RandomAccessFile", 200, 300, 400, 60 * 60); // default; override for higher performance, or set to null for no caching; }
/** * Enable file caching. call this before calling acquireFile(). * When application terminates, call NetcdfDataset.shutdown(). * * @param minElementsInMemory keep this number in the cache * @param maxElementsInMemory trigger a cleanup if it goes over this number. * @param period (secs) do periodic cleanups every this number of seconds. set to < 0 to not cleanup */ static public void initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int period) { fileCache = new ucar.nc2.util.cache.FileCache("NetcdfFileCache ", minElementsInMemory, maxElementsInMemory, -1, period); defaultNetcdfFileFactory = new MyNetcdfFileFactory(); }
/** * Enable file caching. call this before calling acquireFile(). * When application terminates, call NetcdfDataset.shutdown(). * * @param minElementsInMemory keep this number in the cache * @param maxElementsInMemory trigger a cleanup if it goes over this number. * @param hardLimit if > 0, never allow more than this many elements. This causes a cleanup to be done in the calling thread. * @param period (secs) do periodic cleanups every this number of seconds. */ static public void initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int hardLimit, int period) { fileCache = new ucar.nc2.util.cache.FileCache("NetcdfFileCache ", minElementsInMemory, maxElementsInMemory, hardLimit, period); defaultNetcdfFileFactory = new MyNetcdfFileFactory(); }
/** * Enable file caching. call this before calling acquireFile(). * When application terminates, call NetcdfDataset.shutdown(). * * @param minElementsInMemory keep this number in the cache * @param maxElementsInMemory trigger a cleanup if it goes over this number. * @param hardLimit if > 0, never allow more than this many elements. This causes a cleanup to be done in the calling thread. * @param period (secs) do periodic cleanups every this number of seconds. */ static public void initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int hardLimit, int period) { fileCache = new ucar.nc2.util.cache.FileCache("NetcdfFileCache ", minElementsInMemory, maxElementsInMemory, hardLimit, period); defaultNetcdfFileFactory = new MyNetcdfFileFactory(); }
@BeforeClass static public void setUp() throws java.lang.Exception { cache = new FileCache(5, 100, 60 * 60); }
@Test public void testPeriodicClear() throws IOException { FileCache cache = new FileCache(0, 10, 60 * 60); testPeriodicCleanup(cache); Map<Object, FileCache.CacheElement> map = cache.getCache(); assert map.values().size() == 0 : map.values().size(); cache = new FileCache(5, 10, 60 * 60); testPeriodicCleanup(cache); map = cache.getCache(); assert map.values().size() == 5 : map.values().size(); }