Public Member Functions | |
LogMultiFileCache (long fileSize) throws LogCacheException | |
LogMultiFileCache () throws LogCacheException | |
ILogEntry | getLog (Integer logKey) throws LogCacheException |
synchronized int | add (ILogEntry log) throws LogCacheException |
synchronized void | deleteLog (Integer logKey) throws LogCacheException |
int | getSize () |
Integer | getLastLog () |
Integer | getFirstLog () |
void | deleteLogs (Collection< Integer > keys) throws LogCacheException |
synchronized void | clear () throws LogCacheException |
void | replaceLog (Integer key, ILogEntry log) throws LogCacheException |
Iterator< ILogEntry > | iterator () |
Set< Integer > | keySet () |
int | getFirstLogs (int n, Collection< Integer > keys) |
long | getLogFileSize () throws LogCacheException |
long | getMaxFileSize () throws LogCacheException |
void | setDebugTrace (boolean flag) throws LogCacheException |
void | printFileTableInfo () throws LogCacheException |
int | getActiveCacheFiles () |
Static Public Attributes | |
final String | FILEMAXSIZE_PROPERTY_NAME = "jlog.cache.fileMaxSize" |
final long | DEFAULT_FILEMAXSIZE = 1000000 |
Private Member Functions | |
void | printDebugTrace (String traceInfo) |
MultiFileTableRecord | createNewFileRecord () throws LogCacheException |
MultiFileTableRecord | searchFileLogTable (Integer logKey) throws LogCacheException |
Static Private Member Functions | |
long | getDefaultMaxFileSize () |
Private Attributes | |
boolean | debugTrace = false |
long | fileMaxSize |
Vector< MultiFileTableRecord > | logFileTable = new Vector<MultiFileTableRecord>() |
volatile int | logsInCache = 0 |
int | ID = -1 |
This is due to the fact that files can grow up to a given size and hence setting a limit on the number of logs that can be collected.
Logs are added to a file until it reaches a given size, then a new file is created. Logs have different length and therefore the number of logs in each File Buffered Cache will be different (see example below).
Logs are accessible by the user through a keyword (logKey) which is implemented as an increased running number. On the other hand, within each File Buffered Cache they have their own numbering system which starts from 0 to the maximum number of logs.
Example :
logKey logCounter Buffered File Range Cache Range -------------------------------------------------------- 0 - 10 11 0 - 10 file1 11 - 25 15 0 - 14 file2 26 - 32 7 0 - 6 file3 33 - 50 18 0 - 18 file4
When logs are deleted they are no longer accessible : when all logs stored in a single file are marked as deleted the corresponding logCounter = 0 and as consequence the file itself is removed.
Using the example let's assume we delete the logs with the following keyword : 26,27,28,31,32, from now on these logs will not be accessible for the user.
logKey logCounter Buffered File Range Cache Range -------------------------------------------------------- 0 - 10 11 0 - 10 file1 11 - 25 15 0 - 14 file2 26 - 32 2 0 - 6 file3 33 - 50 18 0 - 18 file4
If we delete also logs with keywords 29 and 30 the logCounter will be zero and file3 will be deleted.
logKey Mapping When retrieving the log we need to re-map the global log keyword into the keyword used to add the log to the specific Buffered File Cache. This is done by simply subtracting the minimum key value from the logKey.
Example : Retrieve logKey 20. logKey 20 is stored in the second Buffered File Cache and it is accessible with the local key = (20 - 11) = 9
|
Builds a LogMultiFileCache objects setting the maximum size of the cache files
|
|
Constructor The maximum size of the files is read from the system properties. If the property is not found a default value is used. |
|
Add a log to the cache
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogCache.
|
|
Clear the Map i.e. remove all the logs and keys from the map
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogCache.
|
|
Creates a new record for the log file table : min/max log indexes are initialized according to the total number of received logs.
The create |
|
Delete a log with the given key.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogCache.
|
|
Delete a set of logs
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
|
|
Get the max size of the file out of the system properties or uses the default value if the property does not exist |
|
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.
|
|
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.
|
|
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 change if such log has been deleted
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Retrieves a log by means of its keyword.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogCache.
|
|
Return the current size of the log file
|
|
Return the current maximum size of the log file
|
|
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Return an Iterator to browse the logs in the map. The order the iterator returns the logs is that of the keys.
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogCache.
|
|
The keys in the map
Implements com::cosylab::logging::client::cache::ILogMap.
Reimplemented in com::cosylab::logging::client::cache::LogCache.
|
|
Prints trace info if traceDebug flag is true |
|
Return the current maximum size of the log file
|
|
Replace the log in the given position with the new one
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Looks in the log file table in which file buffered cache the log has been stored. The search is made by checking the min and max key of the logs contained in each record against the key of the searched log. As a consequence the record returned by this method is the only one record that can contain this log but it could be that the log is not there (for example it has been deleted)
|
|
Return the current maximum size of the log file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|