Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

com::cosylab::logging::engine::ACS::ACSLogRetrieval Class Reference

Inheritance diagram for com::cosylab::logging::engine::ACS::ACSLogRetrieval:

Inheritance graph
[legend]
Collaboration diagram for com::cosylab::logging::engine::ACS::ACSLogRetrieval:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACSLogRetrieval (ACSListenersDispatcher listenersDispatcher, boolean binFormat)
 ACSLogRetrieval (ACSListenersDispatcher listenersDispatcher, boolean binFormat, FiltersVector filters)
 ACSLogRetrieval (ACSListenersDispatcher listenersDispatcher, boolean binFormat, FiltersVector filters, IResourceChecker resCecker)
void addLog (String XMLLogStr)
void run ()
void pause (boolean pause)
void close (boolean sync)
boolean hasPendingEntries ()
int size ()
int getInputRate ()
int getOutputRate ()
int getMaxInputRate ()
void setMaxInputRate (int maxInRate)
int getMaxOutputRate ()
void setMaxOutputRate (int maxOutRate)
void enableDynamicDiscarding (int threshold, int damping, int interval)
void setDiscardLevel (LogTypeHelper newLevel)
LogTypeHelper getDiscardLevel ()

Private Member Functions

void initialize ()
void publishLog (String xmlLog, ILogEntry log)
void checkMemory (long freeMem)

Private Attributes

ACSListenersDispatcher listenersDispatcher = null
volatile boolean paused = false
volatile boolean terminateThread = false
volatile boolean closed = false
ACSLogParser parser = null
boolean binaryFormat
EngineCache cache = new EngineCache()
Thread thread
Timer timerThread
int maxInputRate = Integer.MAX_VALUE
volatile int inputRate = 0
volatile int receivedCounter
int maxOutputRate = Integer.MAX_VALUE
volatile int outputRate = 0
volatile int readCounter
int threshold
int damping
int dynamicDiscardingTime = 10
long lastDiscardingUpdateTime
LogTypeHelper userDiscardLevel = null
IResourceChecker resourceChecker = new ResourceChecker()

Static Private Attributes

final int DELAY_NUMBER = 1000

Detailed Description

ACSLogRetrieval stores the XML string (or a String in case of binary logs) representing logs on a file when the engine is not able to follow the flow of the incoming logs The strings are stored on disk and the logs published to the listeners when there is enough CPU available.

ACSLogRetrieval allows to set the rate (i.e. number of logs per second) for the logs to receive and push in cache. All the logs received after this limit has been reached are discarded regardless of their content. This option must be used very carefully because can cause loss of logs.

It also allows to set the rate i.e. number of logs per second) for the logs read from the cache and published to listener. When the limit has been reached, no logs are pushed anymore out of the cache until the current second has elapsed. This limitation must be used very carefully because it can cause a uncontrolled growth of the cache that could lead to an out of memory.
By default, the input and output rates are unlimited (Integer.MAX_VALUE)

The available memory is checked every second. To avoid out of memory the user can enable the dynamic discarding by giving a threshold (in bytes). If a threshold is defined, the thread that checks the amount of available memory increases the discard level. To avoid oscillations, the user can define a a damping factor: the discard level is decreased when the amount of available memory is greater the the threshold plus the damping.

See also:
ACSRemoteLogListener

ACSRemoteRawLogListener

ACSLogConnectionListener


Constructor & Destructor Documentation

com::cosylab::logging::engine::ACS::ACSLogRetrieval::ACSLogRetrieval ACSListenersDispatcher  listenersDispatcher,
boolean  binFormat
[inline]
 

Constructor

Parameters:
listenersDispatcher The object to send messages to the listeners Can't be null
binFormat true if the lags are binary, false if XML format is used

com::cosylab::logging::engine::ACS::ACSLogRetrieval::ACSLogRetrieval ACSListenersDispatcher  listenersDispatcher,
boolean  binFormat,
FiltersVector  filters
[inline]
 

Constructor

Parameters:
listenersDispatcher The object to send messages to the listeners Can't be null
binFormat true if the lags are binary, false if XML format is used
filters The filters to apply to incoming logs If null or empty no filters are applied

com::cosylab::logging::engine::ACS::ACSLogRetrieval::ACSLogRetrieval ACSListenersDispatcher  listenersDispatcher,
boolean  binFormat,
FiltersVector  filters,
IResourceChecker  resCecker
[inline]
 

A construct that allow passing a ResourceChecker.

This is mostly intended for testing purposes to simulate overloading or memory consumption.

Parameters:
listenersDispatcher The object to send messages to the listeners Can't be null
binFormat true if the lags are binary, false if XML format is used
filters The filters to apply to incoming logs If null or empty no filters are applied
roCecher 


Member Function Documentation

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::addLog String  XMLLogStr  )  [inline]
 

Add a log in the file

Parameters:
XMLLogStr The XML string of the new log to add

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::checkMemory long  freeMem  )  [inline, private]
 

Check the available memory against the threshold and the damping factor to increase/decrease the discard level.

Parameters:
freeMem The amount of available memory to the application in bytes.

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::close boolean  sync  )  [inline]
 

Close the threads and free all the resources

Parameters:
sync If it is true wait the termination of the threads before returning

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::enableDynamicDiscarding int  threshold,
int  damping,
int  interval
[inline]
 

Enable dynamic discarding of incoming logs.

Parameters:
threashold The discard level is increased when the available memory for the application is less then the threshold (in bytes). Integer.MAX_VALUE disables this feature.
damping The damping factor is used to avoid oscillations The discard level is decreased when the free memory is is greater then the threshold plus the dumping.
interval The time (in seconds) between two adjustments of the dynamic discard level. interval defaults to 10.
See also:
setDiscardLevel(LogTypeHelper newLevel)

LogTypeHelper com::cosylab::logging::engine::ACS::ACSLogRetrieval::getDiscardLevel  )  [inline]
 

Return the discard level set by the user

Returns:
the discardLevel
See also:
etDiscardLevel(LogTypeHelper newLevel)

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::getInputRate  )  [inline]
 

Return the number of strings received in the last second. Note that the number of received strings can be greater then the max number of input strings.

Returns:
The number of strings received in the last second

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::getMaxInputRate  )  [inline]
 

Returns:
The max number of strings pushed in the cache per second

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::getMaxOutputRate  )  [inline]
 

Returns:
The maximum number of logs published per second

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::getOutputRate  )  [inline]
 

Return the number of strings read from the cache in the last second limited. It can never be greater then the max rate.

Returns:
The number of strings read from the cache in the last second

boolean com::cosylab::logging::engine::ACS::ACSLogRetrieval::hasPendingEntries  )  [inline]
 

Check if there are logs to be published in the cache.

Returns:
true if there are logs to be processed in the file

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::initialize  )  [inline, private]
 

Init the file and the parser

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::pause boolean  pause  )  [inline]
 

Pause/unpause the thread that publishes logs

Parameters:
pause 

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::publishLog String  xmlLog,
ILogEntry  log
[inline, private]
 

Send the logs to the listeners.

The filters are applied before sending the log to the listener.

XML logs are not filtered.

Parameters:
xmlLog The XML (RAW) log
log The log

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::run  )  [inline]
 

The thread to read and notify the logs read from the file to the listeners

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::setDiscardLevel LogTypeHelper  newLevel  )  [inline]
 

Set the discard level

Note: if dynamic filtering by memory is enabled then the discard level effectively used can be greater then this value.

Parameters:
newLevel The new discard level (null means no discard level).
See also:
enableDynamicDiscarding(int threashold)

getDiscardLevel()

Reimplemented from com::cosylab::logging::engine::LogMatcher.

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::setMaxInputRate int  maxInRate  )  [inline]
 

Set the max number of logs to process per second.

All the logs in a second read after this number has been reached are discarded i.e. never pushed in the cache.

Parameters:
maxInRate The max number of logs per second to push in cache. Integer.MAX_VALUE means unlimited

void com::cosylab::logging::engine::ACS::ACSLogRetrieval::setMaxOutputRate int  maxOutRate  )  [inline]
 

Set the max number of logs to read from the cache per second.

All the logs in a second read after this number has been reached are discarded i.e. never published to listeners.

Parameters:
maxOutRate The max number of logs per second to read from cache. Integer.MAX_VALUE means unlimited

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::size  )  [inline]
 

Return the number of entries in the cache

Returns:
the number of entries in the cache


Member Data Documentation

boolean com::cosylab::logging::engine::ACS::ACSLogRetrieval::binaryFormat [private]
 

EngineCache com::cosylab::logging::engine::ACS::ACSLogRetrieval::cache = new EngineCache() [private]
 

volatile boolean com::cosylab::logging::engine::ACS::ACSLogRetrieval::closed = false [private]
 

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::damping [private]
 

damping is used to avoid oscillations in the discard level.

When the available memory is below the threshold, the discard level is immediately increased. To decrease the discard level instead the free memory must be greater then threshold+damping.

damping must be greater or equal to 0.

final int com::cosylab::logging::engine::ACS::ACSLogRetrieval::DELAY_NUMBER = 1000 [static, private]
 

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::dynamicDiscardingTime = 10 [private]
 

The time (in seconds) between two adjustments of the dynamic discard level.

volatile int com::cosylab::logging::engine::ACS::ACSLogRetrieval::inputRate = 0 [private]
 

The number of logs per second pushed in the cache.

This is changed by the thread every second to be equal to receivedCounter

long com::cosylab::logging::engine::ACS::ACSLogRetrieval::lastDiscardingUpdateTime [private]
 

The time when the dynamic discard level has been updated the last time (msec)

ACSListenersDispatcher com::cosylab::logging::engine::ACS::ACSLogRetrieval::listenersDispatcher = null [private]
 

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::maxInputRate = Integer.MAX_VALUE [private]
 

The max input rate (i.e. the max number of strings to push in the cache per second.

If the number of logs received in the current second is greater then this number, then the strings are discarded.

Note: maxinputRate should be used carefully because it causes the loss of information

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::maxOutputRate = Integer.MAX_VALUE [private]
 

The max output rate (i.e. the max number of strings to read from in the cache per second).

If the number of logs received in the current second is greater then this number, then the strings are removed from the cache but discarded without being sent to the listener

Note: maxOutputRate should be used carefully because it causes the loss of information

volatile int com::cosylab::logging::engine::ACS::ACSLogRetrieval::outputRate = 0 [private]
 

The number of logs per second popped from the cache

This is changed by the thread every second to be equal to readCounter

ACSLogParser com::cosylab::logging::engine::ACS::ACSLogRetrieval::parser = null [private]
 

volatile boolean com::cosylab::logging::engine::ACS::ACSLogRetrieval::paused = false [private]
 

volatile int com::cosylab::logging::engine::ACS::ACSLogRetrieval::readCounter [private]
 

Counts the number of logs popped every second

volatile int com::cosylab::logging::engine::ACS::ACSLogRetrieval::receivedCounter [private]
 

Counts the number of logs received every second

IResourceChecker com::cosylab::logging::engine::ACS::ACSLogRetrieval::resourceChecker = new ResourceChecker() [private]
 

resourceChecker gets the details of the memory allocation

volatile boolean com::cosylab::logging::engine::ACS::ACSLogRetrieval::terminateThread = false [private]
 

Thread com::cosylab::logging::engine::ACS::ACSLogRetrieval::thread [private]
 

int com::cosylab::logging::engine::ACS::ACSLogRetrieval::threshold [private]
 

The threshold, in bytes, to dynamically increase the discard level.

The discard level is increased of one step whenever the available memory for the application is greater then this number.

Timer com::cosylab::logging::engine::ACS::ACSLogRetrieval::timerThread [private]
 

The timer to update the input and output rates

LogTypeHelper com::cosylab::logging::engine::ACS::ACSLogRetrieval::userDiscardLevel = null [private]
 

The discard level set by the user


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 03:13:08 2009 for ACS Java API by doxygen 1.3.8