isc.sensor
Class SessionProcessor

java.lang.Object
  extended by java.lang.Thread
      extended by isc.sensor.SessionProcessor
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
TCPSessionProcessor, UDPSessionProcessor

public class SessionProcessor
extends java.lang.Thread

Session Processors (TCP/UDP) manage the full state lifecyle of each session. This processor runs and controls it's own thread

Author:
John Casey
Project: DNA_sensor - Aug 12, 2005

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  long currentPacketTime
          The current timer according to the packets
protected  java.lang.Object dbh
          The instance of the output writer
protected  boolean finish
          Flag to communicate the server exit status
protected static org.apache.log4j.Logger log
          log4j
protected  java.util.Hashtable packetDB
          The hashtable that keep track of flows for each session
protected static java.lang.String PROP_OUTPUTWRITERCLASS
          Property to specity the class of the Session record output writer
 AppProperties props
          Application properties
protected  java.util.Hashtable sessions
          Hashtable to keep track of all open sessions
protected  SessionTimer sesTimer
          The session timer object
protected  java.util.Vector sesWorkQueue
          The work queue contains packets to be associated with session
protected  java.util.Vector workItem
          The current item to be worked on
protected  java.lang.Boolean writeSession
          Flag to control the writing out of sessions
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SessionProcessor()
          Create a new instance of the Session processor
 
Method Summary
 void addCompletedSession(java.lang.String sessionKey)
          SessionTimer will add completed session to this queue when they determine a session has ended
protected  void close()
          Close the session output writer
 boolean finished()
          Is the server shutting down
 java.util.Enumeration getActiveSessions()
          Get an enumeration of all the inflight active sessions
 java.util.Vector getSessionPackets(java.lang.String key)
          Get the packet flows associated with this session
 void notifyProc()
          Notify this thread/mutex of an event
protected  void open()
          Open the session output writer
protected  void processWorkItem()
          Main work routine.
 void run()
           
 void setFinish()
          The server is going down.
 void updatePacketClock(long currentPacketTime)
          Update the running packet timer with the time of the current packet
protected  void waitProc()
          Mutex wait for a time/event
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentPacketTime

protected long currentPacketTime
The current timer according to the packets


writeSession

protected java.lang.Boolean writeSession
Flag to control the writing out of sessions


sesWorkQueue

protected volatile java.util.Vector sesWorkQueue
The work queue contains packets to be associated with session


finish

protected volatile boolean finish
Flag to communicate the server exit status


workItem

protected java.util.Vector workItem
The current item to be worked on


sessions

protected volatile java.util.Hashtable sessions
Hashtable to keep track of all open sessions


packetDB

protected java.util.Hashtable packetDB
The hashtable that keep track of flows for each session


PROP_OUTPUTWRITERCLASS

protected static java.lang.String PROP_OUTPUTWRITERCLASS
Property to specity the class of the Session record output writer


log

protected static org.apache.log4j.Logger log
log4j


dbh

protected java.lang.Object dbh
The instance of the output writer


sesTimer

protected SessionTimer sesTimer
The session timer object


props

public AppProperties props
Application properties

Constructor Detail

SessionProcessor

public SessionProcessor()
Create a new instance of the Session processor

Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

notifyProc

public void notifyProc()
Notify this thread/mutex of an event


waitProc

protected void waitProc()
Mutex wait for a time/event


processWorkItem

protected void processWorkItem()
Main work routine. Subclasses must override this. This is were Session processor take items off their workqueue and process them.


open

protected void open()
Open the session output writer


close

protected void close()
Close the session output writer


addCompletedSession

public void addCompletedSession(java.lang.String sessionKey)
SessionTimer will add completed session to this queue when they determine a session has ended

Parameters:
sessionKey - The session that ended

setFinish

public void setFinish()
The server is going down. Clean up and exit all threads


finished

public boolean finished()
Is the server shutting down

Returns:
True = the server is shutting down

getSessionPackets

public java.util.Vector getSessionPackets(java.lang.String key)
                                   throws java.lang.Exception
Get the packet flows associated with this session

Parameters:
key - The key to this session
Returns:
The vector contains the Summary flows
Throws:
java.lang.Exception - Flows not found

updatePacketClock

public void updatePacketClock(long currentPacketTime)
Update the running packet timer with the time of the current packet

Parameters:
currentPacketTime - The time of the current packet in milliseconds

getActiveSessions

public java.util.Enumeration getActiveSessions()
Get an enumeration of all the inflight active sessions

Returns:
Enumeration of active sessions