Public Member Functions | Static Public Attributes

com.cosylab.logging.client.cache.LogCache Class Reference

Inheritance diagram for com.cosylab.logging.client.cache.LogCache:
com.cosylab.logging.client.cache.LogMultiFileCache com.cosylab.logging.client.cache.ILogMap com.cosylab.logging.client.cache.ILogMap

List of all members.

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< ILogEntryiterator ()

Static Public Attributes

static final String CACHESIZE_PROPERTY_NAME = "jlog.cache.size"
static final int DEFAULT_CACHESIZE = 16384

Detailed Description

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.

Author:
acaproni

Constructor & Destructor Documentation

com.cosylab.logging.client.cache.LogCache.LogCache (  )  throws LogCacheException

Build a LogCache object

Exceptions:
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

Parameters:
size The size of the cache
Exceptions:
LogCacheException 

Member Function Documentation

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

Parameters:
log The log to add in the cache
Returns:
The key of the added log in the cache
Exceptions:
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
synchronized void com.cosylab.logging.client.cache.LogCache.deleteLog ( Integer  key  )  throws LogCacheException

Delete a log with the given key

Parameters:
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

Parameters:
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.

Returns:
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

See also:
java.util.LinkedList
java.util.HashMap
Parameters:
pos The key of the log
Returns:
The LogEntryXML or null in case of error

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

Parameters:
timeframe The time frame to check in millisecond
Returns:
A collection of number of logs exceedding the given timeframe
Long com.cosylab.logging.client.cache.LogCache.getLogTimestamp ( Integer  key  )  throws LogCacheException
Parameters:
pos The key of the log
Returns:
The timestamp of the log with the given key

Referenced by alma.acs.logging.table.LogEntryTableModelBase.getValueAt().

LogTypeHelper com.cosylab.logging.client.cache.LogCache.getLogType ( Integer  key  )  throws LogCacheException
Parameters:
pos The key of the log
Returns:
The type of the log with the given key

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.

Returns:
The time frame

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

Returns:
The keys in the map

Implements com.cosylab.logging.client.cache.ILogMap.


Member Data Documentation

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

The default size of the buffer of logs


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties