public class StatHashMap
extends java.lang.Object
implements java.lang.Runnable
StatHashMap encapsulate a HashMap where all the alarms
received during a time interval are stored.
The purpose of this class is to provide more detailed statistics then those
published in the log.
Implementation note
To generate and write statistics on file could be quite consuming.
To reduce the impact, when the time interval elapses, alarmsMap point to a newly
created HashMap and the old one is used by a thread to calculate the statistics.
All the maps are stored in the FIFO mapsQueue queue.
The thread waits for a new map in the queue the generate the statistics.
The size of the queue is limited to control the memory usage in the unlikely case
that generation of statistics lasts longer then a time interval.
Writing on file is only partially done through castor to avoid keeping in memory all the statistics. The xml is however always generated by castor to ensure it is well formed and readable through castor itself.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
fileNamePrefix
The name of each file is composed of a prefix plus the index
and the ".xml" extension.
|
| Constructor and Description |
|---|
StatHashMap(java.util.logging.Logger logger,
int intervalLength,
java.io.File folder)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
calcStatistics(int activations,
int terminations)
Create a new structure for the timer task:the eal calculation will be done there
|
void |
processedFS(java.lang.String alarmID,
boolean active)
A new FS has been processed: if not already present,
it is stored in the
alarmsMap map otherwise its state is updated. |
void |
run()
The thread picks maps from the
mapsQueue then calculate and write on file
the statistics. |
void |
shutdown()
Stop the thread to calculate the statistics
and free the resources.
|
void |
start()
Start the thread to evaluate the statistics
|
public static final java.lang.String fileNamePrefix
public StatHashMap(java.util.logging.Logger logger,
int intervalLength,
java.io.File folder)
lgger - The loggerintervalLength - The length of each time interval (in minutes)folder - The folder to write the files of statistics intopublic void processedFS(java.lang.String alarmID,
boolean active)
alarmsMap map otherwise its state is updated.alarmID - the ID of the FSactive - The activation state of the FSpublic void calcStatistics(int activations,
int terminations)
activations - Activations in the given intervalterminations - Terminations in the given intervalpublic void run()
mapsQueue then calculate and write on file
the statistics.run in interface java.lang.Runnablepublic void start()
public void shutdown()