|
deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.deegree.coverage.raster.cache.RasterCache
public class RasterCache
The RasterCache holds references CacheRasterReader which wrap other RasterReaders. This Cache
can have multiple directories for storing cache files. If a new Raster should be created it is recommended to call
the freeMemory(long) method first, so all data which was less recently used will be written to file.
| Nested Class Summary | |
|---|---|
(package private) static class |
RasterCache.CacheComparator
The CacheComparator class compares two raster readers for their last read access time. |
| Field Summary | |
|---|---|
static String |
DEF_RASTER_CACHE
A key which can be given to the JVM to define the amount of memory used for caching. |
static File |
DEFAULT_CACHE_DIR
Default cache dir if no directory was given. |
static String |
FILE_EXTENSION
Standard name for a deegree cache file. |
| Method Summary | |
|---|---|
RasterReader |
addReader(RasterReader reader)
Adds a raster reader to this cache, all cache files will be written to this cache directory. |
static void |
clear()
Writes all data the files and removes all readers from the cache. |
File |
createCacheFile(String id)
Creates a unique cachefile for the given id, if the id already exists in the cache directory an index will be appended. if the given id is null a uuid will be used, this file will be marked to be deleted on
exit. |
SimpleRaster |
createFromCache(RasterReader reader,
String rasterId)
Tries to find the file with given id from the current cache directory and instantiates a cachedraster for it. |
static void |
dispose()
Iterates over all current cache directories and calls dispose on their cache files. |
static void |
flush()
Writes all current caches to their cache files, but leaves the in memory cached rasters alone. |
static long |
freeMemory(long requiredMemory)
Signals the cache to write as much data to cache files so that the memory occupied by rasters can be returned to running process. |
File |
getCacheDirectory()
|
static RasterCache |
getInstance()
Gets an instance of a data cache which uses the default directory as the cache directory. |
static RasterCache |
getInstance(File directory,
boolean create)
Gets an instance of a data cache which uses the given directory as the cache directory. |
static RasterCache |
getInstance(RasterIOOptions options)
Gets an instance of a data cache which uses the given options to instantiate a cache. |
static long |
getMaximumCacheMemory()
|
static void |
updateCurrentlyUsedMemory()
Iterates over all known readers and (re) calculates their in memory data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final File DEFAULT_CACHE_DIR
public static final String DEF_RASTER_CACHE
public static final String FILE_EXTENSION
| Method Detail |
|---|
public RasterReader addReader(RasterReader reader)
reader - to add to the cache.
public static void clear()
public static RasterCache getInstance(File directory,
boolean create)
directory - create - true if the directory should be created if missing.
public static RasterCache getInstance(RasterIOOptions options)
RasterIOOptions keys are evaluated. If the options are null the DEFAULT_CACHE_DIR
will be used.
RasterIOOptions.RASTER_CACHE_DIRRasterIOOptions.LOCAL_RASTER_CACHE_DIRRasterIOOptions.CREATE_RASTER_MISSING_CACHE_DIR
options - which can contain cache information.
public static RasterCache getInstance()
public static void updateCurrentlyUsedMemory()
public static long freeMemory(long requiredMemory)
CacheRasterReaders to write their data to file if they have a file to write to. It may well be that the
required memory can not be freed.
requiredMemory - some process may need.
public final File createCacheFile(String id)
null a uuid will be used, this file will be marked to be deleted on
exit.
id - to be used for the identification for the cache file.
public static void flush()
public SimpleRaster createFromCache(RasterReader reader,
String rasterId)
reader - to be used for reading the original data, if parts of the cachefile are incoherentrasterId - the id of the raster if null no raster cache file will be created.
- Returns:
- the raster created from the cache or
null if no cache file with given id was found. public static long getMaximumCacheMemory()
public static void dispose()
public File getCacheDirectory()
|
deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||