com.sun.slamd.example
Class TCPReplayReadThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.slamd.example.TCPReplayReadThread
All Implemented Interfaces:
java.lang.Runnable

public class TCPReplayReadThread
extends java.lang.Thread

This class defines a thread that works in conjunction with the TCPReplay job to read any data returned on any of the connections associated with the job threads.

Author:
Neil A. Wilson

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TCPReplayReadThread(TCPReplayJobClass tcpReplayJob)
          Creates a new instance of this TCPReplay read thread that will be used to read data from connections associated with the provided TCPReplay job.
 
Method Summary
 void registerJobThread()
          Registers a provided job thread with this read thread to indicate that it will be sending connections to this thread for reading.
 void registerSocketChannel(java.nio.channels.SocketChannel socketChannel)
          Registers the provided socket channel with this read thread so that any incoming data available on that connection will be read.
 void run()
          Loops, waiting for data to be available on any of the registered connections, reading it as it becomes available.
 void threadDone()
          Deregisters a job thread from this read thread to indicate that it will no longer be sending connections to this thread for reading.
 
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
 

Constructor Detail

TCPReplayReadThread

public TCPReplayReadThread(TCPReplayJobClass tcpReplayJob)
                    throws java.io.IOException
Creates a new instance of this TCPReplay read thread that will be used to read data from connections associated with the provided TCPReplay job.

Parameters:
tcpReplayJob - The TCPReplay job instance for which this thread should read all data from the server.
Throws:
java.io.IOException - If a problem occurs while creating the associated selector.
Method Detail

registerJobThread

public void registerJobThread()
Registers a provided job thread with this read thread to indicate that it will be sending connections to this thread for reading.


threadDone

public void threadDone()
Deregisters a job thread from this read thread to indicate that it will no longer be sending connections to this thread for reading.


registerSocketChannel

public void registerSocketChannel(java.nio.channels.SocketChannel socketChannel)
Registers the provided socket channel with this read thread so that any incoming data available on that connection will be read.

Parameters:
socketChannel - The socket channel to be registered. It must already be configured in non-blocking mode.

run

public void run()
Loops, waiting for data to be available on any of the registered connections, reading it as it becomes available.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread