Public Member Functions | |
synchronized int | getSize () |
long | getFileSize () throws IOException |
synchronized void | clear () throws LogCacheException |
synchronized ILogEntry | getLog (Integer key) throws LogCacheException |
synchronized int | add (ILogEntry log) throws LogCacheException |
void | replaceLog (Integer key, ILogEntry log) throws LogCacheException |
synchronized void | deleteLog (Integer key) throws LogCacheException |
synchronized void | deleteLogs (Collection< Integer > keys) throws LogCacheException |
Integer | getFirstLog () |
int | getFirstLogs (int n, Collection< Integer > keys) |
Integer | getLastLog () |
Set< Integer > | keySet () |
Iterator< ILogEntry > | iterator () |
Protected Member Functions | |
void | initCache () throws IOException |
String | toCacheString (ILogEntry log) |
Protected Attributes | |
RandomAccessFile | file = null |
int | logID = 0 |
TreeMap< Integer, LogCacheInfo > | index = new TreeMap<IntegerLogCacheInfo>() |
HashMap< Integer, ILogEntry > | replacedLogs = new HashMap<IntegerILogEntry>() |
Private Member Functions | |
String | getFile () |
String | getLogAsString (int idx) |
ILogEntry | fromCacheString (String str) |
Private Attributes | |
String | logFileName |
StringBuilder | sb = new StringBuilder() |
final String | SEPARATOR = new String (""+((char)0)) |
Actually it is not possible to remove a log from the file. To effectively delete logs from disk we need some kind of garbage collector that removes the logs marked as delete from the file. This garbage collector is needed to avoid the file on disk grows indefinitely.
Another potential problem is given by the integer identifier of the logs that grows indefinitely. A temporary solution could be that of using long instad of integers.
|
Append a log to the end of the cache
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Empty the cache.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Delete a log The log is marked as deleted and moved from the index to the deleteLogIndex. The log still exists in the file but is not accessible.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Delete a set of logs
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
|
|
Create the file for the cache trying in several places before giving up. @ return The name of the file for the temporary log file |
|
Return the length of the file on disk
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Return the key of the first valid log (FIFO). The key of the first log is 0 but it can change if the log 0 has been deleted.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Append at most n keys from the first valid logs to the collection. First here means first in the FIFO policy. The number of added keys can be less then n if the cache doesn't contain enough logs.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Return the key of the last valid log (FIFO) The key of the last log is the key of the last inserted log but it can cheang if such log has been deleted
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Return the log in the given position
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Return the string representation (XML) of the log in position idx The string is read from the temporary file
|
|
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Init the file where the cache stores the logs If the file already exists it is truncated to 0 length this situation might happen whenever the cache is cleared
|
|
Return an iterator over the logs in cache Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Return a set with all the keys of the logs in cache
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
Replace the log in the given position with the new one NOTE: the new log is kept in memory
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogBufferedFileCache.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|