|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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. The cache is kept up-to-date because the RasterReaders
allocate cached memory by using ByteBufferPool.allocate(int, boolean, boolean)
. This will call
freeMemory(long)
which in turn keeps track of reserved memory.
The RasterCache memory size and the amount of disk space can be set by adding the keys
DEF_RASTER_CACHE_MEM_SIZE
and DEF_RASTER_CACHE_DISK_SIZE
to the JVM.
Field Summary | |
---|---|
static String |
DEF_RASTER_CACHE_DISK_SIZE
A key which can be given to the JVM to define the amount of memory used for caching. |
static String |
DEF_RASTER_CACHE_MEM_SIZE
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(boolean deleteCacheFiles)
Clears all Memory buffers from all known cached readers, removes the cache files (if requested) 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 long |
getCurrentlyUsedDisk()
|
static long |
getCurrentlyUsedMemory()
|
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 void |
reset(boolean deleteCachedFile)
Clear the cache of all readers (and optionally delete all cache files) and reevaluate the disk and memory size ( DEF_RASTER_CACHE_DISK_SIZE , DEF_RASTER_CACHE_MEM_SIZE ) properties from the system. |
static int |
size()
|
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_MEM_SIZE
public static final String DEF_RASTER_CACHE_DISK_SIZE
public static final String FILE_EXTENSION
Method Detail |
---|
public static void reset(boolean deleteCachedFile)
DEF_RASTER_CACHE_DISK_SIZE
, DEF_RASTER_CACHE_MEM_SIZE
) properties from the system. This method
is to be called with care.
deleteCachedFile
- true if all cached files should be deleted.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_DIR
RasterIOOptions.LOCAL_RASTER_CACHE_DIR
RasterIOOptions.CREATE_RASTER_MISSING_CACHE_DIR
options
- which can contain cache information.
public static RasterCache getInstance()
public static final long getCurrentlyUsedMemory()
public static final long getCurrentlyUsedDisk()
public static int size()
public static void clear(boolean deleteCacheFiles)
deleteCacheFiles
- true if the currently used files should be removed from cache.public static void flush()
public static void dispose()
public static long freeMemory(long requiredMemory)
CacheRasterReader
s 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 RasterReader addReader(RasterReader reader)
reader
- to add to the cache.
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 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 File getCacheDirectory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |