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; }
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); }
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)); }
public void run() { try { DatasetUrl durl = new DatasetUrl(null, location); FileCacheable fc = cache.acquire(factory, durl); NetcdfFile ncfile = (NetcdfFile) fc; //assert ncfile.isLocked(); assert (null != ncfile.getIosp()); Thread.sleep(wait); ncfile.close(); int d = done.incrementAndGet(); if (d % PRINT_EVERY == 0) System.out.printf(" done %d%n", d); } catch (InterruptedException e) { System.out.println(" InterruptedException="+e.getMessage()); } catch (Throwable e) { System.out.println(" fail="+e.getMessage()); e.printStackTrace(); assert false; } } }