org.opennms.bb.dp.capsd.components
Class CapsdWriteManager

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

public final class CapsdWriteManager
extends PollerThread

CapsdWriteManager reads CapsReader objects from the in input queue and uses a thread pool of 'DBRunnableConsumerThread's to write this data to the database. The CapsdWriteManager converts the CapsReader objects into CapsWriter objects and enqueues the new writer for execution by the DBRunnableConsumerThreads.

Version:
$Revision: 1.15 $
Author:
Sowmya, OpenNMS

Field Summary
private static String JSDT_CLIENT_NAME
          The name of the JSDT client for all instances of this object.
private  PCQueue m_capsWriterQ
          Queue to which this adds CapsWriter objects which then run and all the data collected to the database.
private  com.sun.media.jsdt.Channel m_channel
          The actual channel used to exchange messages between systems.
private  PollerClient m_client
          The client that is joined to the JSDT session.
private  PCQueue m_mgrInputQ
          Queue to which CapsReader objects that have results of the SNMP, service queries are added by the CapsdReadManager.
private  com.sun.media.jsdt.Session m_session
          The JSDT Session that is used to communicate with the discovery system.
private  List m_threads
          The list of DBRunnableConsumerThreads that are being managed by this instance.
private static int NUM_WRITERS
          The number of thread writers to start for the manager.
 
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
private CapsdWriteManager()
          The default constructor for the class is not supported.
  CapsdWriteManager(PCQueue Q)
          Constructs a new CapsdWriteManager object that maintains a DBRunnableConsumerThread thread pool to handle the serilization of data to persistant storage (the database).
 
Method Summary
 void connect()
          Creates the poller JSDT client and channel to be used by the CapsWriter object to send confirmation to discovery once a node has been added to the database.
 void run()
          Starts the thread pool, reads CapsReader objects from the m_mgrInputQ, constructs CapsWriter objects and adds them to the m_capsWriterQ.
 void shutdown()
          Initiates the shutdown sequence and then waits for the thread's run method to exit.
 
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

m_mgrInputQ

private PCQueue m_mgrInputQ

Queue to which CapsReader objects that have results of the SNMP, service queries are added by the CapsdReadManager.


m_capsWriterQ

private PCQueue m_capsWriterQ

Queue to which this adds CapsWriter objects which then run and all the data collected to the database.


NUM_WRITERS

private static final int NUM_WRITERS

The number of thread writers to start for the manager.


m_threads

private List m_threads

The list of DBRunnableConsumerThreads that are being managed by this instance.


m_client

private PollerClient m_client

The client that is joined to the JSDT session.


m_session

private com.sun.media.jsdt.Session m_session

The JSDT Session that is used to communicate with the discovery system.


m_channel

private com.sun.media.jsdt.Channel m_channel

The actual channel used to exchange messages between systems.


JSDT_CLIENT_NAME

private static final String JSDT_CLIENT_NAME

The name of the JSDT client for all instances of this object. There should only ever be one instances since clients must be unique.

Constructor Detail

CapsdWriteManager

private CapsdWriteManager()
                   throws UnsupportedOperationException

The default constructor for the class is not supported. This constructor will always throw and UnsupportedOperationException.

Throws:
UnsupportedOperationException - Always thrown from this method.

CapsdWriteManager

public CapsdWriteManager(PCQueue Q)
                  throws com.sun.media.jsdt.JSDTException,
                         SQLException

Constructs a new CapsdWriteManager object that maintains a DBRunnableConsumerThread thread pool to handle the serilization of data to persistant storage (the database).

Parameters:
Q - The input queue where CapsReader objects are received. These CapsReader objects contain results of the SNMP and services staus queries.
Throws:
java.lang.NullPointerException - Thrown when database related properites is not found.
com.sun.media.jsdt.JSDTException - Thrown when the JSDT communication channel cannot be established.
SQLException - Thrown if there is an error creating the connections to the database.
Method Detail

run

public void run()

Starts the thread pool, reads CapsReader objects from the m_mgrInputQ, constructs CapsWriter objects and adds them to the m_capsWriterQ. In short the run method is a transform thread that reads CapsReader objects from one queue and writes CapsWriter objects to another. The thread pool started and managed by the object read from the manager's queue and process the queues objects.

Overrides:
run in class Thread

shutdown

public void shutdown()

Initiates the shutdown sequence and then waits for the thread's run method to exit. If the thread that calls shutdown is the same thread being terminated, then a join() will not occur to prevent a deadlock.

Overrides:
shutdown in class PollerThread
Following copied from class: org.opennms.bb.dp.common.components.PollerThread
See Also:
PollerThread.STATUS_TERMINATING, Object.notifyAll()

connect

public void connect()
             throws com.sun.media.jsdt.JSDTException

Creates the poller JSDT client and channel to be used by the CapsWriter object to send confirmation to discovery once a node has been added to the database.

Throws:
com.sun.media.jsdt.JSDTException - thrown when the JSDT communication channel cannot be established.