public synchronized void close() throws java.io.IOException { if (objCache != null) { if (objCache.release(this)) return; } }
static public void shutdown() { if (cache != null) cache.clearCache(true); }
static public void disableGribCollectionCache() { if (null != gribCollectionCache) gribCollectionCache.disable(); gribCollectionCache = null; }
@AfterClass static public void after() { Grib.setDebugFlags(new DebugFlagsImpl()); Formatter out = new Formatter(System.out); FileCacheIF cache = GribCdmIndex.gribCollectionCache; if (cache != null) { cache.showTracking(out); cache.showCache(out); cache.clearCache(false); } FileCacheIF rafCache = RandomAccessFile.getGlobalFileCache(); if (rafCache != null) { rafCache.showCache(out); } System.out.printf(" countGC=%7d%n", GribCollectionImmutable.countGC); System.out.printf(" countPC=%7d%n", PartitionCollectionImmutable.countPC); System.out.printf(" countDataAccess=%7d%n", GribIosp.debugIndexOnlyCount); System.out.printf(" total files needed=%7d%n", GribCollectionImmutable.countGC + PartitionCollectionImmutable.countPC + GribIosp.debugIndexOnlyCount); FileCache.shutdown(); RandomAccessFile.setGlobalFileCache(null); TestDir.checkLeaks(); RandomAccessFile.setDebugLeaks(false); }
static public RandomAccessFile acquire(String location, int buffer_size) throws IOException { if (cache == null) return new RandomAccessFile(location, "r", buffer_size); else return (RandomAccessFile) cache.acquire(factory, location, new DatasetUrl(null, location), buffer_size, null, null); }
@BeforeClass static public void before() throws IOException { GribIosp.debugIndexOnlyCount = 0; GribCollectionImmutable.countGC = 0; PartitionCollectionImmutable.countPC = 0; RandomAccessFile.enableDefaultGlobalFileCache(); RandomAccessFile.setDebugLeaks(true); // GribIosp.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly")); GribCdmIndex.setGribCollectionCache(new ucar.nc2.util.cache.FileCacheGuava("GribCollectionCacheGuava", 100)); GribCdmIndex.gribCollectionCache.resetTracking(); }
public static Count read(String filename) { long start = System.currentTimeMillis(); System.out.println("\n\nReading File " + filename); Count allCount = new Count(); try (GridDataset gds = GridDataset.open(filename)) { for (GridDatatype gdt : gds.getGrids()) { Count count = read(gdt); System.out.printf("%80s == %d/%d%n", gdt.getFullName(), count.nmiss, count.nread); allCount.add(count); } long took = System.currentTimeMillis() - start; float r = ((float) took) / allCount.nread; System.out.printf("%n%80s == %d/%d%n", "total", allCount.nmiss, allCount.nread); System.out.printf("%n that took %d secs total, %f msecs per record%n", took / 1000, r); } catch (IOException ioe) { ioe.printStackTrace(); Formatter out = new Formatter(System.out); GribCdmIndex.gribCollectionCache.showCache(out); } return allCount; }
static public void eject(String location) { if (cache != null) cache.eject(location); }
@AfterClass static public void after() { Grib.setDebugFlags(new DebugFlagsImpl()); Formatter out = new Formatter(System.out); FileCacheIF cache = GribCdmIndex.gribCollectionCache; if (cache != null) { cache.showTracking(out); cache.showCache(out); cache.clearCache(false); } FileCacheIF rafCache = RandomAccessFile.getGlobalFileCache(); if (rafCache != null) { rafCache.showCache(out); } System.out.printf(" countGC=%7d%n", GribCollectionImmutable.countGC); System.out.printf(" countPC=%7d%n", PartitionCollectionImmutable.countPC); System.out.printf(" countDataAccess=%7d%n", GribIosp.debugIndexOnlyCount); System.out.printf(" total files needed=%7d%n", GribCollectionImmutable.countGC + PartitionCollectionImmutable.countPC + GribIosp.debugIndexOnlyCount); FileCache.shutdown(); RandomAccessFile.setGlobalFileCache(null); TestDir.checkLeaks(); RandomAccessFile.setDebugLeaks(false); }
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; }
@BeforeClass static public void before() { GribIosp.debugIndexOnlyCount = 0; GribCollectionImmutable.countGC = 0; PartitionCollectionImmutable.countPC = 0; RandomAccessFile.enableDefaultGlobalFileCache(); RandomAccessFile.setDebugLeaks(true); // Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly")); GribCdmIndex.setGribCollectionCache(new ucar.nc2.util.cache.FileCacheGuava("GribCollectionCacheGuava", 100)); GribCdmIndex.gribCollectionCache.resetTracking(); }
cache.showCache();
@Override public synchronized void close() throws java.io.IOException { if (cache != null) { if (cache.release(this)) return; } if (null != dodsConnection) { dodsConnection.close(); dodsConnection = null; } }
@AfterClass static public void after() { Grib.setDebugFlags(new DebugFlagsImpl()); Formatter out = new Formatter(System.out); FileCacheIF cache = GribCdmIndex.gribCollectionCache; if (cache != null) { cache.showTracking(out); cache.showCache(out); cache.clearCache(false); } FileCacheIF rafCache = RandomAccessFile.getGlobalFileCache(); if (rafCache != null) { rafCache.showCache(out); } System.out.printf(" countGC=%7d%n", GribCollectionImmutable.countGC); System.out.printf(" countPC=%7d%n", PartitionCollectionImmutable.countPC); System.out.printf(" countDataAccess=%7d%n", GribIosp.debugIndexOnlyCount); System.out.printf(" total files needed=%7d%n", GribCollectionImmutable.countGC + PartitionCollectionImmutable.countPC + GribIosp.debugIndexOnlyCount); FileCache.shutdown(); RandomAccessFile.setGlobalFileCache(null); TestDir.checkLeaks(); RandomAccessFile.setDebugLeaks(false); }
static public RandomAccessFile acquire(String location) throws IOException { if (cache == null) return new RandomAccessFile(location, "r"); else return (RandomAccessFile) cache.acquire(factory, new DatasetUrl(null, location)); }
static public void shutdown() { if (gribCollectionCache != null) gribCollectionCache.clearCache(true); }
static public synchronized void setGlobalFileCache(FileCacheIF _cache) { if (cache != null) cache.disable(); cache = _cache; }
@BeforeClass static public void before() { GribIosp.debugIndexOnlyCount = 0; GribCollectionImmutable.countGC = 0; PartitionCollectionImmutable.countPC = 0; RandomAccessFile.enableDefaultGlobalFileCache(); RandomAccessFile.setDebugLeaks(true); Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly")); GribCdmIndex.setGribCollectionCache(new ucar.nc2.util.cache.FileCacheGuava("GribCollectionCacheGuava", 100)); GribCdmIndex.gribCollectionCache.resetTracking(); }
@Override public synchronized void close() throws java.io.IOException { if (fileCache != null) { if (fileCache.release(this)) return; } try { if (netcdfDataset != null) netcdfDataset.close(); } finally { netcdfDataset = null; } }