Public Member Functions | |
LogCache () throws LogCacheException | |
LogCache (int size) throws LogCacheException | |
synchronized int | add (ILogEntry log) throws LogCacheException |
LogTypeHelper | getLogType (Integer key) throws LogCacheException |
Long | getLogTimestamp (Integer key) throws LogCacheException |
synchronized ILogEntry | getLog (Integer key) throws LogCacheException |
synchronized void | clear () throws LogCacheException |
int | getCacheSize () |
synchronized Calendar | getTimeFrame () |
synchronized void | deleteLog (Integer key) throws LogCacheException |
void | deleteLogs (final Integer[] keys) throws LogCacheException |
synchronized Collection< Integer > | getLogExceedingTimeFrame (long timeframe) |
Set< Integer > | keySet () |
Iterator< ILogEntry > | iterator () |
Static Public Attributes | |
final String | CACHESIZE_PROPERTY_NAME = "jlog.cache.size" |
final int | DEFAULT_CACHESIZE = 16384 |
Private Member Functions | |
synchronized ILogEntry | loadNewLog (Integer idx) throws LogCacheException |
void | initCache () |
Static Private Member Functions | |
int | getDefaultCacheSize () |
Private Attributes | |
final int | actualCacheSize |
Map< Integer, ILogEntry > | cache |
LinkedList< Integer > | manager = null |
Map< Integer, LogTypeHelper > | logTypes |
Map< Integer, Long > | logTimes |
The cache stores the logs into an HashMap using their indexes as keys. It also stores an array of times and level of logs to speed up the sorting done by the table.
|
Build a LogCache object
|
|
Build a logCache object of the given size
|
|
Adds a log in the cache. It does nothing because the adding is done by its parent class. What it does is to store the level and time of the log in the arrays
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Empty the cache Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Delete a log with the given key
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Delete a collection of logs
|
|
Gets the actual cache size, which may come from getDefaultCacheSize() or may be given in the constructor.
|
|
Gets the default cache size, which comes either from the system property
|
|
Return the log with the given key. The method is synchronized because both the HashMap and the LinkedList must be synchronized if there is a chance to acces these objects from more then one thread in the same time
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Returns a set of number of logs (i.e. their position in cache) exceeding the given time frame. This operation is quite slow because it requires a double scan of the logTimes array
|
|
|
|
|
|
Calculate and return the time frame of the logs managed by the GUI The time frame is the number of hours/minutes/seconds between the newest and the oldest log in the GUI I prefer to evaluate the frame instead of storing the min and max value because it works even if one log is deleted from the cache.
|
|
Build the |
|
Return an iterator over the logs in cache Implements com::cosylab::logging::client::cache::ILogMap.
|
|
The keys in the map
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Get a log from the cache on disk updating all the internal lists
|
|
The size of the buffer of logs |
|
The logs are stored into an HashMap. The key is the index of the log. This choice make inefficient the deletion of a log. In fact when a log is removed, the logs having a greater position are shifted one position toward 0 (newPos=oldPos-1) but it is not possible to change the key of an entry in the HashMap. |
|
The name of the property to set the size of the cache. This is the size oif the logs buffered by LogCache |
|
The default size of the buffer of logs |
|
The times of the logs Integer is the key of the log, Long is its timestamp |
|
The array with the level of each log in the cache (useful for setting the log level) |
|
The following list is used to keep ordered the indexes in such a way it is fast to insert/remove logs in the cache.
The indexes contained in this object are the indexes in the cache TreeMap and the size of the TreeMap and the ArrayBlockingQueue is always the same.
|