org.opennms.bb.dp.eventd
Class EventPersistd

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.opennms.bb.dp.common.components.PollerThread
              |
              +--org.opennms.bb.dp.eventd.EventPersistd
All Implemented Interfaces:
Runnable

public class EventPersistd
extends PollerThread

Version:
$Revision: 1.1 $
Author:
Sowmya Kumaraswamy, Brian Weaver, OpenNMS.org

Inner Class Summary
private  class EventPersistd.CheckQueue
          This class is designed to specifically override the add behaviour of the base class.
 
Field Summary
private static int INIT_NUM_WRITERS
          the number of initial threads to create in the thread pool
private  com.sun.media.jsdt.Channel m_channel
          The channel on which events are sent out
private  String m_driver
          database driver loaded from the properties file
private  PCQueue m_eventWriterQ
          Queue to which this adds EventWriter objects which then run and add all the data collected to the database
private  PCQueue m_eventWriterReplyQ
          The queue to which EventWriters add events that have been added to the database - these are then grouped 10 at a time and sent out
private  PollerThread m_jsdtSender
          the jsdt sender
private  String m_passwd
          database password loaded from the properties file
private  PCQueue m_readersQ
          The queue from which EventReaders are received from
private  String m_url
          database url loaded from the properties file
private  String m_user
          database user loaded from the properties file
private  ThreadGroup m_writerGroup
          The pool of db consumers
private  List m_writers
          the pool of threads
private  int max_writers
          the max number of threads to create in the thread pool
 
Fields inherited from class org.opennms.bb.dp.common.components.PollerThread
m_curOpStatus, STATUS_MASK, STATUS_NORMAL, STATUS_PAUSED, STATUS_PAUSING, STATUS_RESUMING, STATUS_SHUTDOWN, STATUS_STARTING, STATUS_TERMINATING
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ
 
Constructor Summary
EventPersistd(PCQueue readersQ)
          Constructs the EventPeristd thread of the Eventd
 
Method Summary
private  void connect()
          Creates the poller JSDT client and channel to be used by the EventWriter threads to send events out once events are added to the database
 void run()
          Starts the thread pool.
 void shutdown()
          Start the shutdown and notify run() to shutdown
(package private)  void threadsVsQueueSizeCheck(int entries)
          After each read from the listenerQ, the threads in the thread pool call this method to adjust the number of threads in the pool if necessary If the number of entries in the queue is more than double the number of threads, the number of threads is increased by one until the configurable maximum number of threads is reached If the number of threads in thepool is more than double the number of entries in the queue, the number of threads is decreased by one until the predefined initial number of threads is reached
 
Methods inherited from class org.opennms.bb.dp.common.components.PollerThread
getCtrlStatus, getOpStatus, pauseOperation, pauseThread, resumeOperation, resumeThread, setCtrlStatus, setOpStatus, setUserStatus, shutdownThread
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INIT_NUM_WRITERS

private static final int INIT_NUM_WRITERS
the number of initial threads to create in the thread pool

m_readersQ

private PCQueue m_readersQ
The queue from which EventReaders are received from

m_eventWriterQ

private PCQueue m_eventWriterQ
Queue to which this adds EventWriter objects which then run and add all the data collected to the database

m_eventWriterReplyQ

private PCQueue m_eventWriterReplyQ
The queue to which EventWriters add events that have been added to the database - these are then grouped 10 at a time and sent out

m_driver

private String m_driver
database driver loaded from the properties file

m_url

private String m_url
database url loaded from the properties file

m_user

private String m_user
database user loaded from the properties file

m_passwd

private String m_passwd
database password loaded from the properties file

max_writers

private int max_writers
the max number of threads to create in the thread pool

m_writerGroup

private ThreadGroup m_writerGroup
The pool of db consumers

m_writers

private List m_writers
the pool of threads

m_jsdtSender

private PollerThread m_jsdtSender
the jsdt sender

m_channel

private com.sun.media.jsdt.Channel m_channel
The channel on which events are sent out
Constructor Detail

EventPersistd

public EventPersistd(PCQueue readersQ)
              throws com.sun.media.jsdt.JSDTException,
                     SQLException
Constructs the EventPeristd thread of the Eventd
Parameters:
readersQ - the queue from which the events to be written into the database are read
Throws:
java.lang.NullPointerException - Thrown if the database related properties are not found
com.sun.media.jsdt.JSDTException - Thrown if the the JSDT communication channel cannot be established
Method Detail

threadsVsQueueSizeCheck

void threadsVsQueueSizeCheck(int entries)
After each read from the listenerQ, the threads in the thread pool call this method to adjust the number of threads in the pool if necessary If the number of entries in the queue is more than double the number of threads, the number of threads is increased by one until the configurable maximum number of threads is reached If the number of threads in thepool is more than double the number of entries in the queue, the number of threads is decreased by one until the predefined initial number of threads is reached

connect

private void connect()
              throws com.sun.media.jsdt.JSDTException
Creates the poller JSDT client and channel to be used by the EventWriter threads to send events out once events are added to the database
Throws:
throws - JSDTException if connection is not successful

run

public void run()
Starts the thread pool. Checks for status changes. If status is normal, reads EventBlock objects off of the m_readersQ, constructs EventWriter objects and adds them to the m_eventWriterQ which is the input Q to the DBRunnableConsumerThreads Also reads the 'persisted' events from the m_eventWriterReplyQ and sends them out NUM_EVENTS_PER_SEND at a time
Overrides:
run in class Thread

shutdown

public void shutdown()
Start the shutdown and notify run() to shutdown
Overrides:
shutdown in class PollerThread
Following copied from class: org.opennms.bb.dp.common.components.PollerThread
See Also:
PollerThread.STATUS_TERMINATING, Object.notifyAll()