org.opennms.netmgt.eventd.processor
Class AbstractJdbcPersister

java.lang.Object
  extended by org.opennms.netmgt.eventd.processor.AbstractJdbcPersister
All Implemented Interfaces:
EventProcessor, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
JdbcAlarmWriter, JdbcEventWriter

public abstract class AbstractJdbcPersister
extends Object
implements org.springframework.beans.factory.InitializingBean, EventProcessor

EventWriter loads the information in each 'Event' into the database. While loading mutiple values of the same element into a single DB column, the mutiple values are delimited by MULTIPLE_VAL_DELIM. When an element and its attribute are loaded into a single DB column, the value and the attribute are separated by a DB_ATTRIB_DELIM. When using delimiters to append values, if the values already have the delimiter, the delimiter in the value is escaped as in URLs. Values for the ' ' block are loaded with each parm name and parm value delimited with the NAME_VAL_DELIM.

Author:
David Hustace , Sowmya Nataraj , OpenNMS.org Changes: - Alarm persisting added (many moons ago) - Alarm persisting now removes oldest events by default. Use "auto-clean" attribute in eventconf files.
See Also:
Constants.MULTIPLE_VAL_DELIM, Constants.DB_ATTRIB_DELIM, Constants.NAME_VAL_DELIM

Field Summary
protected static int EVENT_ACKUSER_FIELD_SIZE
           
protected static int EVENT_AUTOACTION_FIELD_SIZE
           
protected static int EVENT_CORRELATION_FIELD_SIZE
           
protected static int EVENT_DESCR_FIELD_SIZE
           
protected static int EVENT_DPNAME_FIELD_SIZE
           
protected static int EVENT_FORWARD_FIELD_SIZE
           
protected static int EVENT_HOST_FIELD_SIZE
           
protected static int EVENT_INTERFACE_FIELD_SIZE
           
protected static int EVENT_LOGGRP_FIELD_SIZE
           
protected static int EVENT_LOGMSG_FIELD_SIZE
           
protected static int EVENT_MOUSEOVERTEXT_FIELD_SIZE
           
protected static int EVENT_OPERACTION_FIELD_SIZE
           
protected static int EVENT_OPERACTION_MENU_FIELD_SIZE
           
protected static int EVENT_OPERINSTRUCT_FIELD_SIZE
           
protected static int EVENT_PATHOUTAGE_FIELD_SIZE
           
protected static int EVENT_SNMP_FIELD_SIZE
           
protected static int EVENT_SNMPHOST_FIELD_SIZE
           
protected static int EVENT_SOURCE_FIELD_SIZE
           
protected static int EVENT_TTICKET_FIELD_SIZE
           
protected static int EVENT_UEI_FIELD_SIZE
           
protected static int EVENT_X733_ALARMTYPE_SIZE
           
protected static char MSG_NO
          The character to put in if the log or display is to be set to no
protected static char MSG_YES
          The character to put in if the log or display is to be set to yes
 
Constructor Summary
AbstractJdbcPersister()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  boolean checkEventSanityAndDoWeProcess(Event event, String logPrefix)
           
 DataSource getDataSource()
           
 EventdServiceManager getEventdServiceManager()
           
protected  Timestamp getEventTime(Event event)
           
 String getGetNextIdString()
           
protected  int getNextId()
           
protected  int getServiceID(String name)
          This method is used to convert the service name into a service id.
protected  Category log()
           
protected  void set(PreparedStatement stmt, int ndx, char value)
          Sets the statement up for a character value.
protected  void set(PreparedStatement stmt, int ndx, int value)
          Sets the statement up for an integer type.
protected  void set(PreparedStatement stmt, int ndx, String value)
          Sets the statement up for a String value.
protected  void set(PreparedStatement stmt, int ndx, Timestamp value)
          Sets the statement up for a timestamp type.
 void setDataSource(DataSource dataSource)
           
 void setEventdServiceManager(EventdServiceManager eventdServiceManager)
           
 void setGetNextIdString(String getNextIdString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opennms.netmgt.eventd.processor.EventProcessor
process
 

Field Detail

EVENT_UEI_FIELD_SIZE

protected static final int EVENT_UEI_FIELD_SIZE
See Also:
Constant Field Values

EVENT_HOST_FIELD_SIZE

protected static final int EVENT_HOST_FIELD_SIZE
See Also:
Constant Field Values

EVENT_INTERFACE_FIELD_SIZE

protected static final int EVENT_INTERFACE_FIELD_SIZE
See Also:
Constant Field Values

EVENT_DPNAME_FIELD_SIZE

protected static final int EVENT_DPNAME_FIELD_SIZE
See Also:
Constant Field Values

EVENT_SNMPHOST_FIELD_SIZE

protected static final int EVENT_SNMPHOST_FIELD_SIZE
See Also:
Constant Field Values

EVENT_SNMP_FIELD_SIZE

protected static final int EVENT_SNMP_FIELD_SIZE
See Also:
Constant Field Values

EVENT_DESCR_FIELD_SIZE

protected static final int EVENT_DESCR_FIELD_SIZE
See Also:
Constant Field Values

EVENT_LOGGRP_FIELD_SIZE

protected static final int EVENT_LOGGRP_FIELD_SIZE
See Also:
Constant Field Values

EVENT_LOGMSG_FIELD_SIZE

protected static final int EVENT_LOGMSG_FIELD_SIZE
See Also:
Constant Field Values

EVENT_PATHOUTAGE_FIELD_SIZE

protected static final int EVENT_PATHOUTAGE_FIELD_SIZE
See Also:
Constant Field Values

EVENT_CORRELATION_FIELD_SIZE

protected static final int EVENT_CORRELATION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_OPERINSTRUCT_FIELD_SIZE

protected static final int EVENT_OPERINSTRUCT_FIELD_SIZE
See Also:
Constant Field Values

EVENT_AUTOACTION_FIELD_SIZE

protected static final int EVENT_AUTOACTION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_OPERACTION_FIELD_SIZE

protected static final int EVENT_OPERACTION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_OPERACTION_MENU_FIELD_SIZE

protected static final int EVENT_OPERACTION_MENU_FIELD_SIZE
See Also:
Constant Field Values

EVENT_TTICKET_FIELD_SIZE

protected static final int EVENT_TTICKET_FIELD_SIZE
See Also:
Constant Field Values

EVENT_FORWARD_FIELD_SIZE

protected static final int EVENT_FORWARD_FIELD_SIZE
See Also:
Constant Field Values

EVENT_MOUSEOVERTEXT_FIELD_SIZE

protected static final int EVENT_MOUSEOVERTEXT_FIELD_SIZE
See Also:
Constant Field Values

EVENT_ACKUSER_FIELD_SIZE

protected static final int EVENT_ACKUSER_FIELD_SIZE
See Also:
Constant Field Values

EVENT_SOURCE_FIELD_SIZE

protected static final int EVENT_SOURCE_FIELD_SIZE
See Also:
Constant Field Values

EVENT_X733_ALARMTYPE_SIZE

protected static final int EVENT_X733_ALARMTYPE_SIZE
See Also:
Constant Field Values

MSG_YES

protected static final char MSG_YES
The character to put in if the log or display is to be set to yes

See Also:
Constant Field Values

MSG_NO

protected static final char MSG_NO
The character to put in if the log or display is to be set to no

See Also:
Constant Field Values
Constructor Detail

AbstractJdbcPersister

public AbstractJdbcPersister()
Method Detail

set

protected void set(PreparedStatement stmt,
                   int ndx,
                   String value)
            throws SQLException
Sets the statement up for a String value.

Parameters:
stmt - The statement to add the value to.
ndx - The ndx for the value.
value - The value to add to the statement.
Throws:
SQLException - Thrown if there is an error adding the value to the statement.

set

protected void set(PreparedStatement stmt,
                   int ndx,
                   int value)
            throws SQLException
Sets the statement up for an integer type. If the integer type is less than zero, then it is set to null!

Parameters:
stmt - The statement to add the value to.
ndx - The ndx for the value.
value - The value to add to the statement.
Throws:
SQLException - Thrown if there is an error adding the value to the statement.

set

protected void set(PreparedStatement stmt,
                   int ndx,
                   Timestamp value)
            throws SQLException
Sets the statement up for a timestamp type.

Parameters:
stmt - The statement to add the value to.
ndx - The ndx for the value.
value - The value to add to the statement.
Throws:
SQLException - Thrown if there is an error adding the value to the statement.

set

protected void set(PreparedStatement stmt,
                   int ndx,
                   char value)
            throws SQLException
Sets the statement up for a character value.

Parameters:
stmt - The statement to add the value to.
ndx - The ndx for the value.
value - The value to add to the statement.
Throws:
SQLException - Thrown if there is an error adding the value to the statement.

getServiceID

protected int getServiceID(String name)
                    throws SQLException
This method is used to convert the service name into a service id. It first looks up the information from a service map of Eventd and if no match is found, by performing a lookup in the database. If the conversion is successful then the corresponding integer identifier will be returned to the caller.

Parameters:
name - The name of the service
Returns:
The integer identifier for the service name.
Throws:
SQLException - Thrown if there is an error accessing the stored data or the SQL text is malformed. This will also be thrown if the result cannot be obtained.
See Also:
EventdConstants.SQL_DB_SVCNAME_TO_SVCID

getEventTime

protected Timestamp getEventTime(Event event)
Parameters:
event -
log -
Returns:

getNextId

protected int getNextId()
                 throws SQLException
Throws:
SQLException

log

protected Category log()

afterPropertiesSet

public void afterPropertiesSet()
                        throws SQLException
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
SQLException

getEventdServiceManager

public EventdServiceManager getEventdServiceManager()

setEventdServiceManager

public void setEventdServiceManager(EventdServiceManager eventdServiceManager)

getDataSource

public DataSource getDataSource()

setDataSource

public void setDataSource(DataSource dataSource)

getGetNextIdString

public String getGetNextIdString()

setGetNextIdString

public void setGetNextIdString(String getNextIdString)

checkEventSanityAndDoWeProcess

protected boolean checkEventSanityAndDoWeProcess(Event event,
                                                 String logPrefix)


Copyright © 2009. All Rights Reserved.