OpenNMS API 1.2.3

org.opennms.netmgt.eventd
Class EventWriter

java.lang.Object
  extended byorg.opennms.netmgt.eventd.EventWriter

final class EventWriter
extends java.lang.Object

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:
Sowmya Nataraj , OpenNMS.org
See Also:
Constants.MULTIPLE_VAL_DELIM, Constants.DB_ATTRIB_DELIM, Constants.NAME_VAL_DELIM

Field Summary
private static int EVENT_ACKUSER_FIELD_SIZE
           
private static int EVENT_AUTOACTION_FIELD_SIZE
           
private static int EVENT_CORRELATION_FIELD_SIZE
           
private static int EVENT_DESCR_FIELD_SIZE
           
private static int EVENT_DPNAME_FIELD_SIZE
           
private static int EVENT_FORWARD_FIELD_SIZE
           
private static int EVENT_HOST_FIELD_SIZE
           
private static int EVENT_INTERFACE_FIELD_SIZE
           
private static int EVENT_LOGGRP_FIELD_SIZE
           
private static int EVENT_LOGMSG_FIELD_SIZE
           
private static int EVENT_MOUSEOVERTEXT_FIELD_SIZE
           
private static int EVENT_NOTIFICATION_FIELD_SIZE
           
private static int EVENT_OPERACTION_FIELD_SIZE
           
private static int EVENT_OPERACTION_MENU_FIELD_SIZE
           
private static int EVENT_OPERINSTRUCT_FIELD_SIZE
           
private static int EVENT_PATHOUTAGE_FIELD_SIZE
           
private static int EVENT_SNMP_FIELD_SIZE
           
private static int EVENT_SNMPHOST_FIELD_SIZE
           
private static int EVENT_SOURCE_FIELD_SIZE
           
private static int EVENT_TTICKET_FIELD_SIZE
           
private static int EVENT_UEI_FIELD_SIZE
           
private  java.sql.Connection m_dbConn
          The database connection
private  java.sql.PreparedStatement m_eventInsStmt
          SQL statement to get insert an event into the db
private  java.sql.PreparedStatement m_getHostNameStmt
          SQL statement to get hostname for an ip from the ipinterface table
private  java.sql.PreparedStatement m_getNextEventIdStmt
          SQL statement to get next event id from sequence
private  java.sql.PreparedStatement m_getSvcIdStmt
          SQL statement to get service id for a service name
private static char MSG_NO
          The character to put in if the log or display is to be set to no
private static char MSG_YES
          The character to put in if the log or display is to be set to yes
 
Constructor Summary
EventWriter(java.lang.String getNextEventIdStr)
          Constructor
 
Method Summary
private  void add(Header eventHeader, Event event)
          Insert values into the EVENTS table
 void close()
          Close all the prepared statements
private  java.lang.String getHostName(java.lang.String hostip)
          This method is used to convert the event host into a hostname id by performing a lookup in the database.
private  int getServiceID(java.lang.String name)
          This method is used to convert the service name into a service id.
 void persistEvent(Header eventHeader, Event event)
          The method that inserts the event into the database
private  void set(java.sql.PreparedStatement stmt, int ndx, char value)
          Sets the statement up for a character value.
private  void set(java.sql.PreparedStatement stmt, int ndx, int value)
          Sets the statement up for an integer type.
private  void set(java.sql.PreparedStatement stmt, int ndx, java.lang.String value)
          Sets the statement up for a String value.
private  void set(java.sql.PreparedStatement stmt, int ndx, java.sql.Timestamp value)
          Sets the statement up for a timestamp type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_UEI_FIELD_SIZE

private static final int EVENT_UEI_FIELD_SIZE
See Also:
Constant Field Values

EVENT_HOST_FIELD_SIZE

private static final int EVENT_HOST_FIELD_SIZE
See Also:
Constant Field Values

EVENT_INTERFACE_FIELD_SIZE

private static final int EVENT_INTERFACE_FIELD_SIZE
See Also:
Constant Field Values

EVENT_DPNAME_FIELD_SIZE

private static final int EVENT_DPNAME_FIELD_SIZE
See Also:
Constant Field Values

EVENT_SNMPHOST_FIELD_SIZE

private static final int EVENT_SNMPHOST_FIELD_SIZE
See Also:
Constant Field Values

EVENT_SNMP_FIELD_SIZE

private static final int EVENT_SNMP_FIELD_SIZE
See Also:
Constant Field Values

EVENT_DESCR_FIELD_SIZE

private static final int EVENT_DESCR_FIELD_SIZE
See Also:
Constant Field Values

EVENT_LOGGRP_FIELD_SIZE

private static final int EVENT_LOGGRP_FIELD_SIZE
See Also:
Constant Field Values

EVENT_LOGMSG_FIELD_SIZE

private static final int EVENT_LOGMSG_FIELD_SIZE
See Also:
Constant Field Values

EVENT_PATHOUTAGE_FIELD_SIZE

private static final int EVENT_PATHOUTAGE_FIELD_SIZE
See Also:
Constant Field Values

EVENT_CORRELATION_FIELD_SIZE

private static final int EVENT_CORRELATION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_OPERINSTRUCT_FIELD_SIZE

private static final int EVENT_OPERINSTRUCT_FIELD_SIZE
See Also:
Constant Field Values

EVENT_AUTOACTION_FIELD_SIZE

private static final int EVENT_AUTOACTION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_OPERACTION_FIELD_SIZE

private static final int EVENT_OPERACTION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_OPERACTION_MENU_FIELD_SIZE

private static final int EVENT_OPERACTION_MENU_FIELD_SIZE
See Also:
Constant Field Values

EVENT_NOTIFICATION_FIELD_SIZE

private static final int EVENT_NOTIFICATION_FIELD_SIZE
See Also:
Constant Field Values

EVENT_TTICKET_FIELD_SIZE

private static final int EVENT_TTICKET_FIELD_SIZE
See Also:
Constant Field Values

EVENT_FORWARD_FIELD_SIZE

private static final int EVENT_FORWARD_FIELD_SIZE
See Also:
Constant Field Values

EVENT_MOUSEOVERTEXT_FIELD_SIZE

private static final int EVENT_MOUSEOVERTEXT_FIELD_SIZE
See Also:
Constant Field Values

EVENT_ACKUSER_FIELD_SIZE

private static final int EVENT_ACKUSER_FIELD_SIZE
See Also:
Constant Field Values

EVENT_SOURCE_FIELD_SIZE

private static final int EVENT_SOURCE_FIELD_SIZE
See Also:
Constant Field Values

MSG_YES

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


MSG_NO

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


m_dbConn

private java.sql.Connection m_dbConn
The database connection


m_getSvcIdStmt

private java.sql.PreparedStatement m_getSvcIdStmt
SQL statement to get service id for a service name


m_getHostNameStmt

private java.sql.PreparedStatement m_getHostNameStmt
SQL statement to get hostname for an ip from the ipinterface table


m_getNextEventIdStmt

private java.sql.PreparedStatement m_getNextEventIdStmt
SQL statement to get next event id from sequence


m_eventInsStmt

private java.sql.PreparedStatement m_eventInsStmt
SQL statement to get insert an event into the db

Constructor Detail

EventWriter

public EventWriter(java.lang.String getNextEventIdStr)
            throws java.sql.SQLException
Constructor

Method Detail

set

private void set(java.sql.PreparedStatement stmt,
                 int ndx,
                 java.lang.String value)
          throws java.sql.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:
java.sql.SQLException - Thrown if there is an error adding the value to the statement.

set

private void set(java.sql.PreparedStatement stmt,
                 int ndx,
                 int value)
          throws java.sql.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:
java.sql.SQLException - Thrown if there is an error adding the value to the statement.

set

private void set(java.sql.PreparedStatement stmt,
                 int ndx,
                 java.sql.Timestamp value)
          throws java.sql.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:
java.sql.SQLException - Thrown if there is an error adding the value to the statement.

set

private void set(java.sql.PreparedStatement stmt,
                 int ndx,
                 char value)
          throws java.sql.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:
java.sql.SQLException - Thrown if there is an error adding the value to the statement.

getServiceID

private int getServiceID(java.lang.String name)
                  throws java.sql.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:
java.sql.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

getHostName

private java.lang.String getHostName(java.lang.String hostip)
                              throws java.sql.SQLException
This method is used to convert the event host into a hostname id by performing a lookup in the database. If the conversion is successful then the corresponding hosname will be returned to the caller.

Parameters:
hostip - The event host
Returns:
The hostname
Throws:
java.sql.SQLException - Thrown if there is an error accessing the stored data or the SQL text is malformed.
See Also:
EventdConstants.SQL_DB_HOSTIP_TO_HOSTNAME

add

private void add(Header eventHeader,
                 Event event)
          throws java.sql.SQLException
Insert values into the EVENTS table

Throws:
java.sql.SQLException - Thrown if there is an error adding the event to the database.
java.lang.NullPointerException - Thrown if a required resource cannot be found in the properties file.

close

public void close()
Close all the prepared statements


persistEvent

public void persistEvent(Header eventHeader,
                         Event event)
                  throws java.sql.SQLException
The method that inserts the event into the database

Parameters:
eventHeader - the event header
event - the actual event to be inserted
Throws:
java.sql.SQLException

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.