Public Member Functions | |
EngineCache (boolean binary) | |
EngineCache (long size, boolean binary) | |
EngineCache (ILogQueueFileHandler handler, boolean binary) | |
void | run () |
int | size () |
int | getActiveFilesSize () |
synchronized void | push (String string) throws IOException, LogEngineException |
String | pop () throws IOException, InterruptedException |
void | close (boolean sync) |
Objects from this class implement a FIFO cache of String objects. The strings are written on disk by using several files: a new file is created whenever the dimension of the current file becomes greater then a fixed size. For each entry in cache, a record is created and kept in a in-memory list.
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.
com.cosylab.logging.engine.cache.EngineCache.EngineCache | ( | boolean | binary | ) |
Build a cache.
binary | true if the string of logs are in binary format and false if XML strings |
com.cosylab.logging.engine.cache.EngineCache.EngineCache | ( | long | size, | |
boolean | binary | |||
) |
Build the cache with the passed maximum size for each file of the cache
size | The max size of each file of the cache | |
binary | true if the string of logs are in binary format and false if XML strings |
com.cosylab.logging.engine.cache.EngineCache.EngineCache | ( | ILogQueueFileHandler | handler, | |
boolean | binary | |||
) |
Build the cache by setting the size of the files and the handler to create and delete the files.
handler | The handler to create and delete the files | |
binary | true if the string of logs are in binary format and false if XML strings |
void com.cosylab.logging.engine.cache.EngineCache.close | ( | boolean | sync | ) |
Close the cache: delete all the entries and all the files the exit.
Note: this must be the last operation executed by the cache
sync | true if must wait the termination of the threads before exiting |
References com.cosylab.logging.engine.cache.CacheFile.close().
Referenced by com.cosylab.logging.engine.ACS.ACSLogRetrieval.close().
int com.cosylab.logging.engine.cache.EngineCache.getActiveFilesSize | ( | ) |
String com.cosylab.logging.engine.cache.EngineCache.pop | ( | ) | throws IOException, InterruptedException |
Get and remove the next string from the cache.
null
If the timeout happened IOException | In case of error reading from the file | |
InterruptedException | When the call to poll is interrupted |
References com.cosylab.logging.engine.cache.CacheEntriesQueue.get(), com.cosylab.logging.engine.cache.CacheFile.key, com.cosylab.logging.engine.cache.CacheEntry.key, com.cosylab.logging.engine.cache.CacheFile.readFromFile(), and com.cosylab.logging.engine.cache.CacheFile.setReadingMode().
Referenced by com.cosylab.logging.engine.ACS.ACSLogRetrieval.run().
synchronized void com.cosylab.logging.engine.cache.EngineCache.push | ( | String | string | ) | throws IOException, LogEngineException |
Push an entry in the cache. If the current file is null
or its size is greater then maxSize
, then a new file is created.
string | The string to write in the cache |
IOException | In case of error writing the string on disk |
References com.cosylab.logging.engine.cache.CacheFile.getFileLength(), com.cosylab.logging.engine.cache.ILogQueueFileHandler.getMaxFileSize(), com.cosylab.logging.engine.cache.CacheFile.key, com.cosylab.logging.engine.cache.CacheEntriesQueue.put(), com.cosylab.logging.engine.cache.CacheFile.setWritingMode(), and com.cosylab.logging.engine.cache.CacheFile.writeOnFile().
Referenced by com.cosylab.logging.engine.ACS.ACSLogRetrieval.addLog().
void com.cosylab.logging.engine.cache.EngineCache.run | ( | ) |
The method to get and delete unused files
int com.cosylab.logging.engine.cache.EngineCache.size | ( | ) |
Return the number of entries in cache.
References com.cosylab.logging.engine.cache.CacheEntriesQueue.size().
Referenced by com.cosylab.logging.engine.ACS.ACSLogRetrieval.hasPendingEntries(), com.cosylab.logging.engine.ACS.ACSLogRetrieval.run(), and com.cosylab.logging.engine.ACS.ACSLogRetrieval.size().