org.opennms.bb.dp.eventd
Class EventListener

java.lang.Object
  |
  +--org.opennms.bb.dp.eventd.EventListener

class EventListener
extends Object

Listener extends the PollerThread for the pause/resume/shutdown functionality

Its threads listen for events sent as XML over a TCP, UDP or JSDT connection. These threads add the received data as 'EventsReader'( conatining the input stream) to the 'readerQ'

It also maintains a pool of RunnableConsumerThreads that read and run the EventsReader objects added to the readerQ to actually parse the input streams to events('EventBlocks') - the 'EventsReader's are then added to the 'expanderQ' from where the 'EventsExpander's pick them up, and add data from the 'event.conf' to the events

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

Inner Class Summary
private  class EventListener.CheckQueue
          This class is designed to specifically override the add behaviour of the base class.
 
Field Summary
private static int EVENTD_TCP_PORT
          Port on which Listener accepts TCP connections
private static int EVENTD_UDP_PORT
          Port on which Listener accepts UDP connections
private static int INIT_NUM_READERS
          The initial number of threads
private  PCQueue m_destQ
          The queue to were completed reader objects are sent.
private  JSDTHandler m_jsdtHandler
          The handler for events coming in through JSDT
private static Map m_parserMap
          A hash table for the parser pool to be used by the 'RunnableConsumerThread' pool - a parser is added to the pool for each thread in the pool so that when the threads can then look up their parser by using the current thread ID
private  ThreadGroup m_readerGroup
          The thread group that all the reader threads belong two.
private  PCQueue m_readerQ
          The queue to which the incoming events are added
private  List m_readers
          The RunnableConsumerThread thread pool that takes a event input source, parses it to the event datablocks and adds that to the expanderQ
private  TCPHandler m_tcpHandler
          The handler for events coming in through TCP
private  UDPHandler m_udpHandler
          The handler for events coming in through UDP
private  int max_readers
          The max number of RunnableConsumerThreads that should be started by the manager.
 
Constructor Summary
EventListener(PCQueue destQ)
          Creates the Listener thread of eventd that listens for events sent via TCP, UDP or JSDT
 
Method Summary
(package private) static void ()
           
static org.apache.xerces.parsers.SAXParser getEventsParser(Object key)
          Returns the SAX based parser that can be used to decompose the event.
 void pauseOperation()
           
 void resumeOperation()
           
 void shutdown()
          Initiates the shutdown sequence and waits for this thread to exit.
 void start()
          Start all the threads to handle the various communication paths
(package private)  void threadsVsQueueSizeCheck(int entries)
          After each read from the readerQ, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

EVENTD_TCP_PORT

private static final int EVENTD_TCP_PORT
Port on which Listener accepts TCP connections

EVENTD_UDP_PORT

private static final int EVENTD_UDP_PORT
Port on which Listener accepts UDP connections

INIT_NUM_READERS

private static final int INIT_NUM_READERS
The initial number of threads

m_readerQ

private PCQueue m_readerQ
The queue to which the incoming events are added

m_destQ

private PCQueue m_destQ
The queue to were completed reader objects are sent.

m_tcpHandler

private TCPHandler m_tcpHandler
The handler for events coming in through TCP

m_udpHandler

private UDPHandler m_udpHandler
The handler for events coming in through UDP

m_jsdtHandler

private JSDTHandler m_jsdtHandler
The handler for events coming in through JSDT

max_readers

private int max_readers

The max number of RunnableConsumerThreads that should be started by the manager.


m_readers

private List m_readers
The RunnableConsumerThread thread pool that takes a event input source, parses it to the event datablocks and adds that to the expanderQ

m_readerGroup

private ThreadGroup m_readerGroup

The thread group that all the reader threads belong two. This group can then be used to control/access the entire group. (If all the good methods were not depreciated).

It's mainly for separating the threads in the debugger now.


m_parserMap

private static Map m_parserMap
A hash table for the parser pool to be used by the 'RunnableConsumerThread' pool - a parser is added to the pool for each thread in the pool so that when the threads can then look up their parser by using the current thread ID
Constructor Detail

EventListener

public EventListener(PCQueue destQ)
              throws EventListenerException

Creates the Listener thread of eventd that listens for events sent via TCP, UDP or JSDT

The Listener also has a pool of 'RunnableConsumerThread' threads that reads the input streams added by the individual listeners and parses the streams (this is done by running the EventsReader objects in the readerQ)

Throws:
EventListenerException - if any of the handlers fail to get created
Method Detail

static void ()

threadsVsQueueSizeCheck

void threadsVsQueueSizeCheck(int entries)
After each read from the readerQ, 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

start

public void start()
Start all the threads to handle the various communication paths

pauseOperation

public void pauseOperation()
                    throws InterruptedException

resumeOperation

public void resumeOperation()
                     throws InterruptedException

shutdown

public void shutdown()

Initiates the shutdown sequence and waits for this thread to exit.


getEventsParser

public static org.apache.xerces.parsers.SAXParser getEventsParser(Object key)
Returns the SAX based parser that can be used to decompose the event. Use the getContentHandler method of the parser to get the event parser!
Parameters:
key - the currently running thread
Returns:
The SAX parser that can be used to decompose the event object.
See Also:
org.apache.xerces.parser.SAXParser#getContentHandler, org.apache.soap.sax.SAXParser#getContentHandler