public class LogCache extends LogMultiFileCache implements ILogMap
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.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CACHESIZE_PROPERTY_NAME
The name of the property to set the size of the cache.
|
static int |
DEFAULT_CACHESIZE
The default size of the buffer of logs
|
DEFAULT_FILEMAXSIZE, FILEMAXSIZE_PROPERTY_NAME| Constructor and Description |
|---|
LogCache()
Build a LogCache object
|
LogCache(int size)
Build a logCache object of the given size
|
| Modifier and Type | Method and Description |
|---|---|
int |
add(ILogEntry log)
Adds a log in the cache.
|
void |
clear()
Empty the cache
|
void |
deleteLog(java.lang.Integer key)
Delete a log with the given key
|
void |
deleteLogs(java.lang.Integer[] keys)
Delete a collection of logs
|
int |
getCacheSize()
Gets the actual cache size, which may come from
getDefaultCacheSize() or
may be given in the constructor. |
ILogEntry |
getLog(java.lang.Integer key)
Return the log with the given key.
|
java.util.Collection<java.lang.Integer> |
getLogExceedingTimeFrame(long timeframe)
Returns a set of number of logs (i.e.
|
java.lang.Long |
getLogTimestamp(java.lang.Integer key) |
LogTypeHelper |
getLogType(java.lang.Integer key) |
java.util.Calendar |
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.
|
java.util.Iterator<ILogEntry> |
iterator()
Return an iterator over the logs in cache
|
java.util.Set<java.lang.Integer> |
keySet()
The keys in the map
|
deleteLogs, getFilesSize, getFirstLog, getFirstLogs, getLastLog, getLogFileSize, getMaxFileSize, getNumberOfCacheFiles, getSize, printFileTableInfo, replaceLog, setDebugTraceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeleteLogs, getFirstLog, getFirstLogs, getLastLog, getSize, replaceLogpublic static final java.lang.String CACHESIZE_PROPERTY_NAME
public static final int DEFAULT_CACHESIZE
public LogCache()
throws LogCacheException
java.io.IOException - The exception is thrown if the base class
is not able to create the cache on a fileLogCacheExceptionpublic LogCache(int size)
throws LogCacheException
size - The size of the cacheLogCacheExceptionpublic int add(ILogEntry log) throws LogCacheException
add in interface ILogMapadd in class LogMultiFileCachelog - The log to add in the cacheLogCacheException - If an error happened while adding the logpublic LogTypeHelper getLogType(java.lang.Integer key) throws LogCacheException
pos - The key of the logLogCacheExceptionpublic java.lang.Long getLogTimestamp(java.lang.Integer key)
throws LogCacheException
pos - The key of the logLogCacheExceptionpublic ILogEntry getLog(java.lang.Integer key) throws LogCacheException
getLog in interface ILogMapgetLog in class LogMultiFileCachepos - The key of the logLogCacheExceptionLinkedList,
HashMappublic void clear()
throws LogCacheException
clear in interface ILogMapclear in class LogMultiFileCacheLogCacheExceptionILogMappublic int getCacheSize()
getDefaultCacheSize() or
may be given in the constructor.public java.util.Calendar getTimeFrame()
public void deleteLog(java.lang.Integer key)
throws LogCacheException
deleteLog in interface ILogMapdeleteLog in class LogMultiFileCachepos - The key of the log to deleteLogCacheExceptionpublic void deleteLogs(java.lang.Integer[] keys)
throws LogCacheException
keys - The keys of the logs to deleteLogCacheExceptionpublic java.util.Collection<java.lang.Integer> getLogExceedingTimeFrame(long timeframe)
timeframe - The time frame to check in millisecondpublic java.util.Set<java.lang.Integer> keySet()
keySet in interface ILogMapkeySet in class LogMultiFileCacheILogMap