public class ACSLogRetrieval extends LogMatcher implements java.lang.Runnable
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.
Life cycle: start() must be called at the beginning and #stop() at the end. *
| Modifier and Type | Class and Description |
|---|---|
class |
ACSLogRetrieval.RateUpdater |
actualDiscardLevel| Constructor and Description |
|---|
ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher)
Constructor
|
ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher,
boolean binFormat,
FiltersVector filters)
Constructor
|
ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher,
boolean binFormat,
FiltersVector filters,
IResourceChecker resCecker)
A construct that allow passing a
ResourceChecker. |
ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher,
TimestampedStringQueueFileHandler fileHandler)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLog(java.lang.String XMLLogStr)
Add a log in the file
|
void |
close(boolean sync)
Close the threads and free all the resources
|
void |
enableDynamicDiscarding(int threshold,
int damping,
int interval)
Enable dynamic discarding of incoming logs.
|
LogTypeHelper |
getDiscardLevel()
Return the discard level set by the user
|
int |
getInputRate()
Return the number of strings received in the last second.
|
int |
getMaxInputRate() |
int |
getMaxOutputRate() |
int |
getOutputRate()
Return the number of strings read from the cache in the last second limited.
|
boolean |
hasPendingEntries()
Check if there are logs to be published in the cache.
|
void |
pause(boolean pause)
Pause/unpause the thread that publishes logs
|
void |
run()
The thread to read and notify the logs read from the file to the listeners
|
void |
setDiscardLevel(LogTypeHelper newLevel)
Set the discard level
|
void |
setMaxInputRate(int maxInRate)
Set the max number of logs to process per second.
|
void |
setMaxOutputRate(int maxOutRate)
Set the max number of logs to read from the cache per second.
|
int |
size()
Return the number of entries in the cache
|
void |
start()
Init the file and the parser
|
getActualDiscardLevel, getAudience, getFilters, match, setAudience, setFilterspublic ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher)
listenersDispatcher - The object to send messages to the listeners
Can't be nullpublic ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher, TimestampedStringQueueFileHandler fileHandler)
listenersDispatcher - The not null object to send messages to the listenersThe - fileHandler the files of the cachepublic ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher, boolean binFormat, FiltersVector filters)
listenersDispatcher - The object to send messages to the listeners
Can't be nullbinFormat - true if the lags are binary,
false if XML format is usedfilters - The filters to apply to incoming logs
If null or empty no filters are appliedpublic ACSLogRetrieval(ACSListenersDispatcher listenersDispatcher, boolean binFormat, FiltersVector filters, IResourceChecker resCecker)
ResourceChecker.
This is mostly intended for testing purposes to simulate overloading or memory consumption.
listenersDispatcher - The object to send messages to the listeners
Can't be nullbinFormat - true if the lags are binary,
false if XML format is usedfilters - The filters to apply to incoming logs
If null or empty no filters are appliedroCecher - public void start()
throws LogEngineException
LogEngineExceptionpublic void addLog(java.lang.String XMLLogStr)
XMLLogStr - The XML string of the new log to addpublic void run()
run in interface java.lang.Runnablepublic void pause(boolean pause)
pause - public void close(boolean sync)
sync - If it is true wait the termination of the threads before returningpublic boolean hasPendingEntries()
public int size()
public int getInputRate()
public int getOutputRate()
public int getMaxInputRate()
public void setMaxInputRate(int maxInRate)
All the logs in a second read after this number has been reached are discarded i.e. never pushed in the cache.
maxInRate - The max number of logs per second to push in cache.
Integer.MAX_VALUE means unlimitedpublic int getMaxOutputRate()
public void setMaxOutputRate(int maxOutRate)
All the logs in a second read after this number has been reached are discarded i.e. never published to listeners.
maxOutRate - The max number of logs per second to read from cache.
Integer.MAX_VALUE means unlimitedpublic void enableDynamicDiscarding(int threshold,
int damping,
int interval)
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.setDiscardLevel(LogTypeHelper newLevel)public void setDiscardLevel(LogTypeHelper newLevel)
Note: if dynamic filtering by memory is enabled then the discard level effectively used can be greater then this value.
setDiscardLevel in class LogMatchernewLevel - The new discard level (null means
no discard level).enableDynamicDiscarding(int threashold),
getDiscardLevel()public LogTypeHelper getDiscardLevel()
etDiscardLevel(LogTypeHelper newLevel)