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:
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.

Version:
$Id: $
Author:
David Hustace , OpenNMS.org Changes: - Alarm persisting added (many moons ago) - Alarm persisting now removes oldest events by default. Use "auto-clean" attribute in eventconf files., Sowmya Nataraj , David Hustace , 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, Constants.MULTIPLE_VAL_DELIM, Constants.DB_ATTRIB_DELIM, Constants.NAME_VAL_DELIM, Constants.MULTIPLE_VAL_DELIM, Constants.DB_ATTRIB_DELIM, Constants.NAME_VAL_DELIM

Field Summary
protected static int EVENT_ACKUSER_FIELD_SIZE
          Constant EVENT_ACKUSER_FIELD_SIZE=256
protected static int EVENT_AUTOACTION_FIELD_SIZE
          Constant EVENT_AUTOACTION_FIELD_SIZE=256
protected static int EVENT_CORRELATION_FIELD_SIZE
          Constant EVENT_CORRELATION_FIELD_SIZE=1024
protected static int EVENT_DPNAME_FIELD_SIZE
          Constant EVENT_DPNAME_FIELD_SIZE=12
protected static int EVENT_FORWARD_FIELD_SIZE
          Constant EVENT_FORWARD_FIELD_SIZE=256
protected static int EVENT_HOST_FIELD_SIZE
          Constant EVENT_HOST_FIELD_SIZE=256
protected static int EVENT_INTERFACE_FIELD_SIZE
          Constant EVENT_INTERFACE_FIELD_SIZE=16
protected static int EVENT_LOGGRP_FIELD_SIZE
          Constant EVENT_LOGGRP_FIELD_SIZE=32
protected static int EVENT_MOUSEOVERTEXT_FIELD_SIZE
          Constant EVENT_MOUSEOVERTEXT_FIELD_SIZE=64
protected static int EVENT_OPERACTION_FIELD_SIZE
          Constant EVENT_OPERACTION_FIELD_SIZE=256
protected static int EVENT_OPERACTION_MENU_FIELD_SIZE
          Constant EVENT_OPERACTION_MENU_FIELD_SIZE=64
protected static int EVENT_OPERINSTRUCT_FIELD_SIZE
          Constant EVENT_OPERINSTRUCT_FIELD_SIZE=1024
protected static int EVENT_PATHOUTAGE_FIELD_SIZE
          Constant EVENT_PATHOUTAGE_FIELD_SIZE=1024
protected static int EVENT_SNMP_FIELD_SIZE
          Constant EVENT_SNMP_FIELD_SIZE=256
protected static int EVENT_SNMPHOST_FIELD_SIZE
          Constant EVENT_SNMPHOST_FIELD_SIZE=256
protected static int EVENT_SOURCE_FIELD_SIZE
          Constant EVENT_SOURCE_FIELD_SIZE=128
protected static int EVENT_TTICKET_FIELD_SIZE
          Constant EVENT_TTICKET_FIELD_SIZE=128
protected static int EVENT_UEI_FIELD_SIZE
          Constant EVENT_UEI_FIELD_SIZE=256
protected static int EVENT_X733_ALARMTYPE_SIZE
          Constant EVENT_X733_ALARMTYPE_SIZE=31
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()
          Constructor for AbstractJdbcPersister.
 
Method Summary
 void afterPropertiesSet()
          afterPropertiesSet
protected  boolean checkEventSanityAndDoWeProcess(Event event, String logPrefix)
          checkEventSanityAndDoWeProcess
 DataSource getDataSource()
          getDataSource
 EventdServiceManager getEventdServiceManager()
          getEventdServiceManager
protected  Timestamp getEventTime(Event event)
          getEventTime
 String getGetNextIdString()
          getGetNextIdString
protected  int getNextId()
          getNextId
protected  int getServiceID(String name)
          This method is used to convert the service name into a service id.
protected  ThreadCategory log()
          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)
          setDataSource
 void setEventdServiceManager(EventdServiceManager eventdServiceManager)
          setEventdServiceManager
 void setGetNextIdString(String getNextIdString)
          setGetNextIdString
 
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
Constant EVENT_UEI_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_HOST_FIELD_SIZE

protected static final int EVENT_HOST_FIELD_SIZE
Constant EVENT_HOST_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_INTERFACE_FIELD_SIZE

protected static final int EVENT_INTERFACE_FIELD_SIZE
Constant EVENT_INTERFACE_FIELD_SIZE=16

See Also:
Constant Field Values

EVENT_DPNAME_FIELD_SIZE

protected static final int EVENT_DPNAME_FIELD_SIZE
Constant EVENT_DPNAME_FIELD_SIZE=12

See Also:
Constant Field Values

EVENT_SNMPHOST_FIELD_SIZE

protected static final int EVENT_SNMPHOST_FIELD_SIZE
Constant EVENT_SNMPHOST_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_SNMP_FIELD_SIZE

protected static final int EVENT_SNMP_FIELD_SIZE
Constant EVENT_SNMP_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_LOGGRP_FIELD_SIZE

protected static final int EVENT_LOGGRP_FIELD_SIZE
Constant EVENT_LOGGRP_FIELD_SIZE=32

See Also:
Constant Field Values

EVENT_PATHOUTAGE_FIELD_SIZE

protected static final int EVENT_PATHOUTAGE_FIELD_SIZE
Constant EVENT_PATHOUTAGE_FIELD_SIZE=1024

See Also:
Constant Field Values

EVENT_CORRELATION_FIELD_SIZE

protected static final int EVENT_CORRELATION_FIELD_SIZE
Constant EVENT_CORRELATION_FIELD_SIZE=1024

See Also:
Constant Field Values

EVENT_OPERINSTRUCT_FIELD_SIZE

protected static final int EVENT_OPERINSTRUCT_FIELD_SIZE
Constant EVENT_OPERINSTRUCT_FIELD_SIZE=1024

See Also:
Constant Field Values

EVENT_AUTOACTION_FIELD_SIZE

protected static final int EVENT_AUTOACTION_FIELD_SIZE
Constant EVENT_AUTOACTION_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_OPERACTION_FIELD_SIZE

protected static final int EVENT_OPERACTION_FIELD_SIZE
Constant EVENT_OPERACTION_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_OPERACTION_MENU_FIELD_SIZE

protected static final int EVENT_OPERACTION_MENU_FIELD_SIZE
Constant EVENT_OPERACTION_MENU_FIELD_SIZE=64

See Also:
Constant Field Values

EVENT_TTICKET_FIELD_SIZE

protected static final int EVENT_TTICKET_FIELD_SIZE
Constant EVENT_TTICKET_FIELD_SIZE=128

See Also:
Constant Field Values

EVENT_FORWARD_FIELD_SIZE

protected static final int EVENT_FORWARD_FIELD_SIZE
Constant EVENT_FORWARD_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_MOUSEOVERTEXT_FIELD_SIZE

protected static final int EVENT_MOUSEOVERTEXT_FIELD_SIZE
Constant EVENT_MOUSEOVERTEXT_FIELD_SIZE=64

See Also:
Constant Field Values

EVENT_ACKUSER_FIELD_SIZE

protected static final int EVENT_ACKUSER_FIELD_SIZE
Constant EVENT_ACKUSER_FIELD_SIZE=256

See Also:
Constant Field Values

EVENT_SOURCE_FIELD_SIZE

protected static final int EVENT_SOURCE_FIELD_SIZE
Constant EVENT_SOURCE_FIELD_SIZE=128

See Also:
Constant Field Values

EVENT_X733_ALARMTYPE_SIZE

protected static final int EVENT_X733_ALARMTYPE_SIZE
Constant EVENT_X733_ALARMTYPE_SIZE=31

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()

Constructor for 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.
SQLException - if any.

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.
SQLException - if any.

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.
SQLException - if any.

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.
SQLException - if any.

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.
SQLException - if any.
See Also:
EventdConstants.SQL_DB_SVCNAME_TO_SVCID

getEventTime

protected Timestamp getEventTime(Event event)

getEventTime

Parameters:
event - a Event object.
Returns:
a Timestamp object.

getNextId

protected int getNextId()
                 throws SQLException

getNextId

Returns:
a int.
Throws:
SQLException - if any.

log

protected ThreadCategory log()

log

Returns:
a ThreadCategory object.

afterPropertiesSet

public void afterPropertiesSet()
                        throws SQLException

afterPropertiesSet

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
SQLException - if any.

getEventdServiceManager

public EventdServiceManager getEventdServiceManager()

getEventdServiceManager

Returns:
a EventdServiceManager object.

setEventdServiceManager

public void setEventdServiceManager(EventdServiceManager eventdServiceManager)

setEventdServiceManager

Parameters:
eventdServiceManager - a EventdServiceManager object.

getDataSource

public DataSource getDataSource()

getDataSource

Returns:
a DataSource object.

setDataSource

public void setDataSource(DataSource dataSource)

setDataSource

Parameters:
dataSource - a DataSource object.

getGetNextIdString

public String getGetNextIdString()

getGetNextIdString

Returns:
a String object.

setGetNextIdString

public void setGetNextIdString(String getNextIdString)

setGetNextIdString

Parameters:
getNextIdString - a String object.

checkEventSanityAndDoWeProcess

protected boolean checkEventSanityAndDoWeProcess(Event event,
                                                 String logPrefix)

checkEventSanityAndDoWeProcess

Parameters:
event - a Event object.
logPrefix - a String object.
Returns:
a boolean.


Copyright © 2011. All Rights Reserved.