CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.net
Class LoadBalancer.SocketHandler

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.Daemon
          extended by com.tangosol.net.LoadBalancer.SocketHandler
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
LoadBalancer.RequestHandler, LoadBalancer.ResponseHandler
Enclosing class:
LoadBalancer

public abstract static class LoadBalancer.SocketHandler
extends Daemon

A SocketHandler is an abstract daemon thread.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.tangosol.util.Daemon
Daemon.DaemonWorker
 
Field Summary
protected  byte[] m_abBuf
          The buffer to use for reading from a stream.
 
Constructor Summary
LoadBalancer.SocketHandler(String sName)
          Construct a SocketHandler with a given daemon thread name.
 
Method Summary
protected  void copy(InputStream streamIn, OutputStream streamOut, byte[] abBuf)
          Process the transfer of data from one stream to another.
protected  byte[] ensureBuffer(Socket socket)
          Return the existing buffer, if there is one, or create one to use for reading from the passed socket.
protected  void process(Socket socketIn, Socket socketOut)
          Process the transfer of data from one socket to another.
abstract  void run()
          Processing loop for the SocketHandler.
 
Methods inherited from class com.tangosol.util.Daemon
changeState, configureWorker, getConfiguredName, getConfiguredPriority, getDescription, getState, getThread, getThreadContextClassLoader, getWorker, instantiateWorker, isOnWorkerThread, isRunning, isStopping, setConfiguredName, setConfiguredPriority, setThreadContextClassLoader, start, stop, toStateString, toString
 

Field Detail

m_abBuf

protected byte[] m_abBuf
The buffer to use for reading from a stream.

Constructor Detail

LoadBalancer.SocketHandler

public LoadBalancer.SocketHandler(String sName)
Construct a SocketHandler with a given daemon thread name.

Method Detail

run

public abstract void run()
Processing loop for the SocketHandler.

Specified by:
run in interface Runnable
Specified by:
run in class Daemon

process

protected void process(Socket socketIn,
                       Socket socketOut)
                throws IOException
Process the transfer of data from one socket to another.

Parameters:
socketIn - the socket to read from
socketOut - the socket to write to
Throws:
IOException

copy

protected void copy(InputStream streamIn,
                    OutputStream streamOut,
                    byte[] abBuf)
             throws IOException
Process the transfer of data from one stream to another.

Parameters:
streamIn - the stream to read from
streamOut - the stream to write to
abBuf - the byte array to use as a buffer to read into and write from
Throws:
IOException

ensureBuffer

protected byte[] ensureBuffer(Socket socket)
Return the existing buffer, if there is one, or create one to use for reading from the passed socket.

Parameters:
socket - the socket that the buffer will be used to read from
Returns:
a byte array to use as a read buffer

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation