Re: [netcdf-java] Java API: problems with temporary files

Hello Lak,

I just today dealt with this problem, but for me the potential race condition remains.

You can specify where the temporary files are placed with
DiskCache.setRootDirectory("grib_data");

You can purge that directory with
DiskCache.cleanCache(new java.util.Date(),null);
That does an immediate purge, but you could specify a later date that might minimize the potential race condition.

I've only just tried this for a few hours. It works for keeping the *.gbx files out of our data directories.

There's probably a better solution, and I'm looking forward to seeing it.

-Bill

On 2/9/2009 12:41 PM, Valliappa Lakshmanan wrote:
I've been using the Java Netcdf API and am running into several issues with the temporary files that are created.

For example, when a gzipped NetCDF file is read, an uncompressed
version is written to disk before it is read. I assume that this is because the NetCDF API allows for file seeks etc. which wouldn't be possible if the file remained gzipped. But (and this is the problem), the uncompressed file is stored in the SAME directory as the original file. This causes three major problems (in increasing order
of severity):
(a) The data directory (which would be considered read-only) is being modified. This causes problems
        because of the I/O optimizations that we do on real-time systems
(b) The temporary file is not automatically cleaned up, so these temporaries start to fill up the disk. But removing the temporary file when the original file is closed is not enough because of problem (c). (c) if there are two simultaneous programs reading a gzipped file, then a potential for race conditions exists

The same problem seems to exist when reading a Grib1 file (a .gbx temporary file is created).

Is there any work-around for this problem?

Lak

p.s.  I suggest the consistent use of java.io.File's createTempFile() ...


------------------------------------------------------------------------

_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/

--
William R. Moninger         http://www-frd.fsl.noaa.gov/~moninger/
NOAA / Earth Systems Research Laboratory / Global Systems Division
325 Broadway, R/GSD1                           voice: 303-497-6435
Boulder, CO 80305                              fax:   303-497-3329


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