## org.apache.catalina.cluster.tcp
Class TcpReplicationThread

    java.lang.Object
      java.lang.Thread
          org.apache.catalina.cluster.tcp.WorkerThread
              org.apache.catalina.cluster.tcp.TcpReplicationThread

All Implemented Interfaces:
  java.lang.Runnable

public class TcpReplicationThread
extends WorkerThread

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.

Version:
  $Id: TcpReplicationThread.java 939539 2010-04-30 01:31:33Z kkolinko $
Author:
  Filip Hanik

Field Summary
`static byte[]` `ACK_COMMAND`

Fields inherited from class org.apache.catalina.cluster.tcp.WorkerThread
`doRun, pool`

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Method Summary
`protected void` `drainChannel(java.nio.channels.SelectionKey key)` The actual code which drains the channel associated with the given key.
`void` `run()`
`protected void` `sendAck(java.nio.channels.SelectionKey key, java.nio.channels.SocketChannel channel)` send a reply-acknowledgement (6,2,3)

Methods inherited from class org.apache.catalina.cluster.tcp.WorkerThread
`close, getPool, setPool`

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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

### ACK_COMMAND

    public static final byte[] ACK_COMMAND

Method Detail

### run

    public void run()

### drainChannel

    protected void drainChannel(java.nio.channels.SelectionKey key)
                         throws java.lang.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.

  Throws:
    `java.lang.Exception`

### sendAck

    protected void sendAck(java.nio.channels.SelectionKey key,
                           java.nio.channels.SocketChannel channel)

  send a reply-acknowledgement (6,2,3)

  Parameters:
    `key` -
    `channel` -

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.