static public DiskCache2 getNoop() { DiskCache2 noop = new DiskCache2(); noop.neverUseCache = true; return noop; }
static public DiskCache2 getNoop() { DiskCache2 noop = new DiskCache2(); noop.neverUseCache = true; return noop; }
/** * Create a ForecastModelRun Collection from the datasets in a catalog. * @param catURL scan this catalog * @throws Exception on bad */ public static FmrcInventory makeFromCatalog(String catURL, String collectionName, int maxDatasets, int mode) throws Exception { DiskCache2 cache = new DiskCache2("fmrcInventory/", true, 0, -1); // dont scour - messes up the TDS! return makeFromCatalog(cache, catURL, collectionName, maxDatasets, mode); }
/** * Default DiskCache2 strategy: use $user_home/.unidata/cache/, no scouring, alwaysUseCache = false * Mimics default DiskCache static class */ static public DiskCache2 getDefault() { String root = System.getProperty("nj22.cache"); if (root == null) { String home = System.getProperty("user.home"); if (home == null) home = System.getProperty("user.dir"); if (home == null) home = "."; root = home + "/.unidata/cache/"; } DiskCache2 result = new DiskCache2(); result.setRootDirectory(root); result.alwaysUseCache = false; return result; }
/** * Default DiskCache2 strategy: use $user_home/.unidata/cache/, no scouring, alwaysUseCache = false * Mimics default DiskCache static class */ static public DiskCache2 getDefault() { String root = System.getProperty("nj22.cache"); if (root == null) { String home = System.getProperty("user.home"); if (home == null) home = System.getProperty("user.dir"); if (home == null) home = "."; root = home + "/.unidata/cache/"; } DiskCache2 result = new DiskCache2(); result.setRootDirectory(root); result.alwaysUseCache = false; return result; }
/** debug */ static public void main(String[] args) throws IOException { DiskCache2 dc = new DiskCache2("C:/TEMP/test/", false, 0, 0); dc.setRootDirectory("C:/temp/chill/"); make(dc, "C:/junk.txt"); make(dc, "C:/some/enchanted/evening/joots+3478.txt"); make(dc, "http://www.unidata.ucar.edu/some/enc hanted/eve'ning/nowrite.gibberish"); dc.showCache( System.out); StringBuilder sbuff = new StringBuilder(); dc.cleanCache(new File( dc.getRootDirectory()), sbuff, true); System.out.println(sbuff); }
public static void main(String args[]) throws IOException { if (args.length == 1) { ForecastModelRunInventory.open(null, args[0], ForecastModelRunInventory.OPEN_FORCE_NEW, true); ForecastModelRunInventory.readXML( args[0] +".fmrInv.xml" ); return; } DiskCache2 cache = new DiskCache2("fmrcInventory/", true, 5 * 24 * 3600, 3600); String url = "http://motherlode.ucar.edu:9080/thredds/dodsC/fmrc/NCEP/NAM/CONUS_12km/files/NAM_CONUS_12km_20070419_1800.grib2"; ForecastModelRunInventory fmr = ForecastModelRunInventory.open(cache, url, ForecastModelRunInventory.OPEN_NORMAL, false); fmr.writeXML(System.out); }
@Test public void testDiskCache() throws Exception { String cacheDirName = tempFolder.newFolder().getAbsolutePath() + "/"; DiskCache2 cache = new DiskCache2(cacheDirName, false, 0, 0); cache.setAlwaysUseCache(true); Assert.assertEquals(cache.getRootDirectory(), cacheDirName);
DiskCache2 cache = new DiskCache2(cacheDirName, false, 0, 0); cache.setAlwaysUseCache(true); Assert.assertEquals(cache.getRootDirectory(), cacheDirName);
@Test public void testCacheIsUsed() throws IOException, InvalidRangeException { String filename = "file:TestAggExistingCache.xml"; System.out.printf("%s%n", filename); String cacheDirName = tempFolder.newFolder().getAbsolutePath() + "/"; System.out.printf("cacheDir=%s%n", cacheDirName); File cacheDir = new File(cacheDirName); FileUtils.deleteDirectory(cacheDir); // from commons-io assert !cacheDir.exists(); DiskCache2 cache = new DiskCache2(cacheDirName, false, 0, 0); cache.setAlwaysUseCache(true); Assert.assertEquals(cache.getRootDirectory(), cacheDirName); assert new File(cache.getRootDirectory()).exists(); Aggregation.setPersistenceCache(cache); AggregationExisting.countCacheUse = 0; try (NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncml), filename, null)) { System.out.println(" TestNcmlAggExisting.open " + filename); Array ATssta = ncfile.readSection("ATssta(:,0,0,0)"); Assert.assertEquals(4, ATssta.getSize()); } Assert.assertEquals(0, AggregationExisting.countCacheUse); AggregationExisting.countCacheUse = 0; try (NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncml), filename, null)) { System.out.println(" TestNcmlAggExisting.open " + filename); Array ATssta = ncfile.readSection("ATssta(:,0,0,0)"); Assert.assertEquals(4, ATssta.getSize()); } Assert.assertEquals(8, AggregationExisting.countCacheUse); }