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 | |
static final String | CACHESIZE_PROPERTY_NAME = "jlog.cache.size" |
static final int | DEFAULT_CACHESIZE = 16384 |
The class extends the cache on file keeping a set of logs in memory to avoid to access the file for the most frequently accessed logs
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.
com.cosylab.logging.client.cache.LogCache.LogCache | ( | ) | throws LogCacheException |
Build a LogCache object
IOException | The exception is thrown if the base class is not able to create the cache on a file |
com.cosylab.logging.client.cache.LogCache.LogCache | ( | int | size | ) | throws LogCacheException |
Build a logCache object of the given size
size | The size of the cache |
LogCacheException |
synchronized int com.cosylab.logging.client.cache.LogCache.add | ( | ILogEntry | log | ) | throws LogCacheException |
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
log | The log to add in the cache |
LogCacheException | If an error happened while adding the log |
Implements com.cosylab.logging.client.cache.ILogMap.
synchronized void com.cosylab.logging.client.cache.LogCache.clear | ( | ) | throws LogCacheException |
Empty the cache
Implements com.cosylab.logging.client.cache.ILogMap.
Referenced by alma.acs.logging.table.LogEntryTableModelBase.clearAll().
synchronized void com.cosylab.logging.client.cache.LogCache.deleteLog | ( | Integer | key | ) | throws LogCacheException |
Delete a log with the given key
pos | The key of the log to delete |
Implements com.cosylab.logging.client.cache.ILogMap.
Referenced by com.cosylab.logging.client.cache.LogCache.deleteLogs().
void com.cosylab.logging.client.cache.LogCache.deleteLogs | ( | final Integer[] | keys | ) | throws LogCacheException |
Delete a collection of logs
keys | The keys of the logs to delete |
References com.cosylab.logging.client.cache.LogCache.deleteLog().
int com.cosylab.logging.client.cache.LogCache.getCacheSize | ( | ) |
Gets the actual cache size, which may come from getDefaultCacheSize() or may be given in the constructor.
synchronized ILogEntry com.cosylab.logging.client.cache.LogCache.getLog | ( | Integer | key | ) | throws LogCacheException |
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
pos | The key of the log |
Implements com.cosylab.logging.client.cache.ILogMap.
Referenced by alma.acs.logging.table.LogEntryTableModelBase.getVisibleLogEntry().
synchronized Collection<Integer> com.cosylab.logging.client.cache.LogCache.getLogExceedingTimeFrame | ( | long | timeframe | ) |
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
timeframe | The time frame to check in millisecond |
Long com.cosylab.logging.client.cache.LogCache.getLogTimestamp | ( | Integer | key | ) | throws LogCacheException |
pos | The key of the log |
Referenced by alma.acs.logging.table.LogEntryTableModelBase.getValueAt().
LogTypeHelper com.cosylab.logging.client.cache.LogCache.getLogType | ( | Integer | key | ) | throws LogCacheException |
pos | The key of the log |
Referenced by alma.acs.logging.table.LogEntryTableModelBase.getValueAt().
synchronized Calendar com.cosylab.logging.client.cache.LogCache.getTimeFrame | ( | ) |
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.
Referenced by alma.acs.logging.table.LogEntryTableModelBase.getTimeFrame().
Iterator<ILogEntry> com.cosylab.logging.client.cache.LogCache.iterator | ( | ) |
Return an iterator over the logs in cache
Implements com.cosylab.logging.client.cache.ILogMap.
Set<Integer> com.cosylab.logging.client.cache.LogCache.keySet | ( | ) |
The keys in the map
Implements com.cosylab.logging.client.cache.ILogMap.
final String com.cosylab.logging.client.cache.LogCache.CACHESIZE_PROPERTY_NAME = "jlog.cache.size" [static] |
The name of the property to set the size of the cache. This is the size oif the logs buffered by LogCache
final int com.cosylab.logging.client.cache.LogCache.DEFAULT_CACHESIZE = 16384 [static] |
The default size of the buffer of logs