[netcdf-java] NetcdfFileCache doesn't release OPeNDAP datasets

Hi John (and list),

I've come across some behaviour in nj4 that was unexpected to me, but
is possibly a feature not a bug!  In ncWMS I'm using the cache of
datasets, which I'm initializing like so:

    // Hold between 50 and 500 datasets, refresh cache every 5 minutes
    NetcdfDataset.initNetcdfFileCache(50, 500, 500, 5 * 60);

Then I use NetcdfDataset.acquireDataset() to open datasets.
Everything seems to work fine for datasets that are read from local
files.  However, for datasets that are read from OPeNDAP locations,
the cache appears to hold on to the dataset forever: every call to
acquireDataset() returns the same dataset, even well after the
5-minute expiry period (in fact the dataset is only evicted on a
reboot of the server).

Therefore I use a function like this to get the behaviour I expect:

    public static NetcdfDataset openDataset(String location) {
        if (location.startsWith("http://";)) {
            return NetcdfDataset.openDataset(location);  // don't use the cache
        } else {
            // this is a local dataset: use the cache
            return NetcdfDataset.acquireDataset(location, null);
        }
    }

Is this a bug in nj4?

Cheers, Jon

-- 
Dr Jon Blower
Technical Director, Reading e-Science Centre
Environmental Systems Science Centre
University of Reading
Harry Pitt Building, 3 Earley Gate
Reading RG6 6AL. UK
Tel: +44 (0)118 378 5213
Fax: +44 (0)118 378 6413
j.d.blower@xxxxxxxxxxxxx
http://www.nerc-essc.ac.uk/People/Staff/Blower_J.htm



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: