|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.archive.EventsArchiver
The EventsArchiver is responsible for archiving and removing events from the 'events' table. The archival/deletion depends on the 'eventLog' and the 'eventDisplay' values for the event - If the 'eventLog == N and the eventDisplay == N', the event is simply deleted from the events table If the 'eventLog == N and the eventDisplay == Y', the event is deleted ONLY if the event has been acknowledged If the 'eventLog == Y and the eventDisplay == N', the event is sent to the archive file and deleted from the table If the 'eventLog == Y and the eventDisplay == Y', the event is sent to the archive file and deleted from the table ONLY if the event has been acknowledged An event is considered acknowledged if the 'eventAckUser' column has a non-null value An EventsArchiver run depends on attributes in the events archiver configuration file. The following are the properties that govern a run - - archiveAge This determines which events are to be removed - i.e events older than current time minus this time are removed - separator This is the separator used in between event table column values when an event is written to the archive file The EventsArchiver uses Apache's log4j both for its output logs and for the actual archiving itself - the set up for the log4j appenders for this archiver are all doneexclusively in the 'events.archiver.properties' property file ARollingFileAppender
is used for the archive file with the defaults for this being to roll when the size is 100KB with the number of backups set to 4.
Field Summary | |
private static java.lang.String |
DB_DELETE_EVENT
The SQL statement to delete events based on their eventID |
private static java.lang.String |
DB_SELECT_EVENTS_TO_ARCHIVE
The SQL statement to select events that have their eventCreateTime earlier than a specified age |
private static java.lang.String |
EVENT_ACK_USER
The column name for 'eventAckUser' in the events table |
private static java.lang.String |
EVENT_DISPLAY
The column name for 'eventDisplay' in the events table |
private static java.lang.String |
EVENT_ID
The column name for eventID in the events table |
private static java.lang.String |
EVENT_LOG
The column name for 'eventLog' in the events table |
private long |
m_archAge
The archive age in milliseconds. |
private org.apache.log4j.Category |
m_archCat
The log4j category for the archive file |
private java.lang.String |
m_archSeparator
The separator to be used when writing events into the archive |
private java.sql.Connection |
m_dbConn
The database connection |
private java.sql.PreparedStatement |
m_eventDeleteStmt
The prepared statement to delete the events |
private java.sql.PreparedStatement |
m_eventsGetStmt
The prepared statement to select the events |
private org.apache.log4j.Category |
m_logCat
The log4j category for this class' output logs |
private static java.lang.String |
MSG_NO
The value for the event log or display field if set to false |
private static java.lang.String |
MSG_YES
The value for the event log or display field if set to true |
Constructor Summary | |
EventsArchiver()
The events archiver constructor - reads required properties, initializes the database connection and the prepared statements to select and delete events |
Method Summary | |
private void |
archiveEvents()
Select the events created before 'age', log them to the archive file if required and delete these events. |
private void |
close()
Close the database statements and the connection and close log4j Appenders and categories |
private void |
init()
Read the required properties and set up the logs, the archive etc. |
static void |
main(java.lang.String[] args)
|
private boolean |
removeEvent(java.lang.String eventID)
Remove event with eventID from events table. |
private void |
sendToArchive(java.sql.ResultSet eventsRS,
int colCount)
Archive the current row of the result set |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String DB_SELECT_EVENTS_TO_ARCHIVE
private static final java.lang.String DB_DELETE_EVENT
private static final java.lang.String EVENT_ID
private static final java.lang.String EVENT_LOG
private static final java.lang.String EVENT_DISPLAY
private static final java.lang.String EVENT_ACK_USER
private static final java.lang.String MSG_YES
private static final java.lang.String MSG_NO
private org.apache.log4j.Category m_logCat
private org.apache.log4j.Category m_archCat
private long m_archAge
private java.lang.String m_archSeparator
private java.sql.Connection m_dbConn
private java.sql.PreparedStatement m_eventsGetStmt
private java.sql.PreparedStatement m_eventDeleteStmt
Constructor Detail |
public EventsArchiver() throws ArchiverException
Method Detail |
private void init() throws ArchiverException
ArchiverException
- thrown if a required property is not specified or is
incorrectprivate boolean removeEvent(java.lang.String eventID)
private void archiveEvents()
private void sendToArchive(java.sql.ResultSet eventsRS, int colCount) throws java.sql.SQLException
java.sql.SQLException
- thrown if there is an error getting column values from the
result setprivate void close()
public static void main(java.lang.String[] args)
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |