org.opennms.bb.dp.eventd
Class EventWriter

java.lang.Object
  |
  +--org.opennms.bb.dp.eventd.EventWriter
All Implemented Interfaces:
DBRunnable, Runnable

public class EventWriter
extends Object
implements DBRunnable, Runnable

EventWriter loads the information in each 'EventBlock' into the database Once the events are added to the database, they are sent out via JSDT for other processes (such as actiond) to read

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:
$Revision: 1.1 $
Author:
Sowmya Kumaraswamy, OpenNMS.org
See Also:
#MULTIPLE_VAL_DELIM, #DB_ATTRIB_DELIM, #escapeDelimiter(), #NAME_VAL_DELIM

Field Summary
private  com.sun.media.jsdt.Channel m_channel
          The JSDT channel
private  com.sun.media.jsdt.Client m_client
          The JSDT client
private  Event m_event
          The current event that is to be written
private  EventHeader m_header
          The event header
 
Constructor Summary
EventWriter(EventHeader header, Event event, com.sun.media.jsdt.Client client, com.sun.media.jsdt.Channel channel)
          Constructs an EventWriter thread
 
Method Summary
private  void add(Connection db)
          Insert values into the EVENTS table
 void dbRun(Connection connection)
          The method that starts the processing for this object
 Event getEvent()
          Return the event serialzed to the database.
 EventHeader getHeader()
          Return the event header used during serialzation to the database.
 void run()
          The run method is invoked to send the new serialized event to other listening applications using JSDT.
private  void set(PreparedStatement stmt, int ndx, int value)
          Sets the statement up for an interger type.
private  void set(PreparedStatement stmt, int ndx, String value)
          Sets the statement up for an interger type.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_event

private Event m_event
The current event that is to be written

m_header

private EventHeader m_header
The event header

m_client

private com.sun.media.jsdt.Client m_client
The JSDT client

m_channel

private com.sun.media.jsdt.Channel m_channel
The JSDT channel
Constructor Detail

EventWriter

public EventWriter(EventHeader header,
                   Event event,
                   com.sun.media.jsdt.Client client,
                   com.sun.media.jsdt.Channel channel)
Constructs an EventWriter thread
Parameters:
eventBlock - the event to be 'persisted'
channel - JSDT channel to be used to send events out once they are added to the database
client - JSDT client ID for this thread
Method Detail

set

private void set(PreparedStatement stmt,
                 int ndx,
                 String value)
          throws SQLException
Sets the statement up for an interger type. If the interger 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

private void set(PreparedStatement stmt,
                 int ndx,
                 int value)
          throws SQLException
Sets the statement up for an interger type. If the interger 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.

add

private void add(Connection db)
          throws SQLException
Insert values into the EVENTS table
Returns:
true if the add is successful, false if not
Throws:
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.
See Also:
org.opennms.bb.events.eventd.databalocks.EventBlock, org.opennms.bb.events.eventd.utils.EventsParser#ATTRIB_DELIM, #ATTRIB_DELIM, #DB_ATTRIB_DELIM, #VALUE_TRUNCATE_INDICATOR

dbRun

public void dbRun(Connection connection)
The method that starts the processing for this object
Specified by:
dbRun in interface DBRunnable
Parameters:
connection - the database connection to be used by this object to add data to the DB

run

public void run()
The run method is invoked to send the new serialized event to other listening applications using JSDT.
Specified by:
run in interface Runnable

getHeader

public EventHeader getHeader()
Return the event header used during serialzation to the database.

getEvent

public Event getEvent()
Return the event serialzed to the database.