Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » catalina » cluster » tcp » [javadoc | source]
org.apache.catalina.cluster.tcp
public class: TcpReplicationThread [javadoc | source]
java.lang.Object
   java.lang.Thread
      org.apache.catalina.cluster.tcp.WorkerThread
         org.apache.catalina.cluster.tcp.TcpReplicationThread

All Implemented Interfaces:
    Runnable

A worker thread class which can drain channels and echo-back the input. Each instance is constructed with a reference to the owning thread pool object. When started, the thread loops forever waiting to be awakened to service the channel associated with a SelectionKey object. The worker is tasked by calling its serviceChannel() method with a SelectionKey object. The serviceChannel() method stores the key reference in the thread object then calls notify() to wake it up. When the channel has been drained, the worker thread returns itself to its parent pool.
Field Summary
public static final  byte[] ACK_COMMAND     
Fields inherited from org.apache.catalina.cluster.tcp.WorkerThread:
pool,  doRun
Fields inherited from java.lang.Thread:
MIN_PRIORITY,  NORM_PRIORITY,  MAX_PRIORITY
Constructor:
 TcpReplicationThread() 
Method from org.apache.catalina.cluster.tcp.TcpReplicationThread Summary:
drainChannel,   run,   sendAck,   serviceChannel
Methods from org.apache.catalina.cluster.tcp.WorkerThread:
close,   getPool,   setPool
Methods from 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,   run,   setContextClassLoader,   setDaemon,   setDefaultUncaughtExceptionHandler,   setName,   setPriority,   setUncaughtExceptionHandler,   sleep,   sleep,   start,   stop,   stop,   suspend,   toString,   yield
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.catalina.cluster.tcp.TcpReplicationThread Detail:
 protected  void drainChannel(SelectionKey key) throws Exception 
    The actual code which drains the channel associated with the given key. This method assumes the key has been modified prior to invocation to turn off selection interest in OP_READ. When this method completes it re-enables OP_READ and calls wakeup() on the selector so the selector will resume watching this channel.
 public synchronized  void run() 
 protected  void sendAck(SelectionKey key,
    SocketChannel channel) 
    send a reply-acknowledgement (6,2,3)
 synchronized  void serviceChannel(SelectionKey key,
    boolean sendAck) 
    Called to initiate a unit of work by this worker thread on the provided SelectionKey object. This method is synchronized, as is the run() method, so only one key can be serviced at a given time. Before waking the worker thread, and before returning to the main selection loop, this key's interest set is updated to remove OP_READ. This will cause the selector to ignore read-readiness for this channel while the worker thread is servicing it.