Public Member Functions | |
EngineCache () | |
EngineCache (long size) | |
void | run () |
int | size () |
int | getActiveFilesSize () |
void | push (String string) throws IOException |
String | pop (int timeout) throws IOException, InterruptedException |
void | close (boolean sync) |
Static Public Attributes | |
long | DEFAULT_SIZE = 1073741824 |
String | MAXSIZE_PROPERTY_NAME = "jlog.enine.cache.maxFilesSize" |
Private Member Functions | |
File | getNewFile () |
boolean | releaseFile (CacheFile itemToDel) |
Integer | getNextFileKey () |
Static Private Member Functions | |
long | getDefaultMaxFileSize () |
Private Attributes | |
long | maxSize |
int | fileKey = 0 |
volatile CacheFile | outCacheFile = null |
volatile CacheFile | inCacheFile = null |
CacheEntriesQueue | entries = new CacheEntriesQueue() |
LinkedBlockingQueue< CacheFile > | filesToDelete = new LinkedBlockingQueue<CacheFile>() |
LinkedHashMap< Integer, CacheFile > | files = new LinkedHashMap<IntegerCacheFile>() |
volatile boolean | closed = false |
The cache is used by com.cosylab.logging.engine.ACS.ACSLogRetrieval
, but can be used wherever a set of strings needs to be stored because there is no assumption about the content of the strings.
The logs are stored in a set of files and their ending position saved. When all the logs in a file have been red, the file is deleted optimizing the usage disk space. The deletion of unused files is done by a thread.
The length of each file of cache can be specified by a parameter in the constructor or by a java property. If both those values are not given, a default length is used.
files
contains all the files used by the cache, identified by a key. When a file does not contain unread entries then its key is pushed into filesToDelete
and deleted. The thread that deletes the files from disk, removes the CacheFile object from files
too.
entries
contains all the entries of in cache.
|
Build a cache. The max size of each file of the cache is calculated in the following way: 1. if the java property is present, the size is taken from suc a property 2. the default size is used |
|
Build the cache with the passed maximum size for each file of the cache
|
|
Close the cache: delete all the entries and all the files the exit. Note: this must be the last operation executed by the cache
|
|
|
|
Get the max size of the files out of the system properties or uses the default value if the property does not exist |
|
Attempts to create the file for the strings in several places before giving up.
|
|
Generate a new key for a file. Each new key is generated by increasing the value of the current key. If the max integer value is reached then the key rests to the min value.
|
|
Get and remove the next string from the cache.
|
|
Push an entry in the cache. If the current file is
|
|
Close and delete a file.
|
|
The method to get and delete unused files |
|
Return the number of entries in cache.
|
|
|
|
The default max size for each file of the cache. The default value is used when the java property is not found and the size is not given explicitly. NFS could be limited to 2GB depending on the installed version |
|
The entries in the cache. The items of the list are organized in a FIFO policy. This is particularly important because this order is used to know when a file is not used anymore and can be deleted.
|
|
Each file of the cache is identified by a key. The key is always positive. |
|
The files used by the cache. The entries in this vector have the same order of the creation of the files: the last created file is in the last position of the vector. This property can be used to verify for the correctness of the computation because every time we have to delete a file, it must be the first item of this vector
|
|
A list of keys of unused files to delete. |
|
The file used to read the previous record. It is used to know when all the records in a file have been read. |
|
The max length of each file of the cache |
|
|
|
The file used to write the strings into. When the size of this file is greater then |