org.apache.catalina.cluster.tcp
Class FastAsyncSocketSender

java.lang.Object
  extended byorg.apache.catalina.cluster.tcp.DataSender
      extended byorg.apache.catalina.cluster.tcp.FastAsyncSocketSender
All Implemented Interfaces:
IDataSender

public class FastAsyncSocketSender
extends DataSender

Send cluster messages from a Message queue with only one socket. Ack and keep Alive Handling is supported. Fast Queue can limit queue size and consume all messages at queue at one block.
Limit the queue lock contention under high load!

FIXME: refactor code duplications with AsyncSocketSender => configurable or extract super class

Since:
5.5.9
Version:
$Revision: 1.2 $ $Date: 2005/03/25 22:07:20 $
Author:
Peter Rossbach ( idea comes form Rainer Jung)

Field Summary
 
Fields inherited from class org.apache.catalina.cluster.tcp.DataSender
connectCounter, dataResendCounter, disconnectCounter, doProcessingStats, maxProcessingTime, minProcessingTime, missingAckCounter, nrOfRequests, processingTime, sm, totalBytes
 
Constructor Summary
FastAsyncSocketSender(java.net.InetAddress host, int port)
          start background thread to push incomming cluster messages to replication node
 
Method Summary
protected  void checkThread()
          Start Queue thread as daemon
 void connect()
           
 void disconnect()
          Disconnect socket ad stop queue thread
 java.lang.String getInfo()
          Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.
 long getInQueueCounter()
           
 int getMaxQueueLength()
           
 long getOutQueueCounter()
           
 long getQueueAddWaitTime()
           
 long getQueueAddWaitTimeout()
          get current add wait timeout
 long getQueuedNrOfBytes()
           
 long getQueueRemoveWaitTime()
           
 long getQueueRemoveWaitTimeout()
          get current remove wait timeout
 int getQueueSize()
           
 boolean isQueueCheckLock()
           
 boolean isQueueDoStats()
           
 boolean isQueueTimeWait()
           
protected  void reduceQueuedCounter(int size)
           
 void resetStatistics()
           
 void sendMessage(java.lang.String messageid, byte[] data)
           
 void setMaxQueueLength(int length)
           
 void setQueueAddWaitTimeout(long timeout)
          Set add wait timeout (default 10000 msec)
 void setQueueCheckLock(boolean checkLock)
           
 void setQueueDoStats(boolean doStats)
           
 void setQueueTimeWait(boolean timeWait)
           
 void setRemoveWaitTimeout(long timeout)
          set remove wait timeout ( default 30000 msec)
protected  void stopThread()
          stop queue worker thread
 java.lang.String toString()
          Name of this SockerSender
 
Methods inherited from class org.apache.catalina.cluster.tcp.DataSender
addProcessingStats, addStats, checkIfCloseSocket, closeSocket, getAckTimeout, getAddress, getAvgProcessingTime, getConnectCounter, getDataResendCounter, getDisconnectCounter, getKeepAliveConnectTime, getKeepAliveCount, getKeepAliveMaxRequestCount, getKeepAliveTimeout, getMaxProcessingTime, getMinProcessingTime, getMissingAckCounter, getNrOfRequests, getPort, getProcessingTime, getSocketCloseCounter, getSocketOpenCounter, getSuspect, getTotalBytes, isConnected, isDoProcessingStats, isSuspect, isWaitForAck, openSocket, pushMessage, setAckTimeout, setDoProcessingStats, setKeepAliveMaxRequestCount, setKeepAliveTimeout, setSocketConnected, setSuspect, setWaitForAck, waitForAck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FastAsyncSocketSender

public FastAsyncSocketSender(java.net.InetAddress host,
                             int port)
start background thread to push incomming cluster messages to replication node

Parameters:
host - replication node tcp address
port - replication node tcp port
Method Detail

getInfo

public java.lang.String getInfo()
Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.

Overrides:
getInfo in class DataSender

getQueueAddWaitTimeout

public long getQueueAddWaitTimeout()
get current add wait timeout

Returns:
current wait timeout

setQueueAddWaitTimeout

public void setQueueAddWaitTimeout(long timeout)
Set add wait timeout (default 10000 msec)

Parameters:
timeout -

getQueueRemoveWaitTimeout

public long getQueueRemoveWaitTimeout()
get current remove wait timeout

Returns:

setRemoveWaitTimeout

public void setRemoveWaitTimeout(long timeout)
set remove wait timeout ( default 30000 msec)

Parameters:
timeout -

isQueueCheckLock

public boolean isQueueCheckLock()
Returns:
Returns the checkLock.

setQueueCheckLock

public void setQueueCheckLock(boolean checkLock)
Parameters:
checkLock - The checkLock to set.

isQueueDoStats

public boolean isQueueDoStats()
Returns:
Returns the doStats.

setQueueDoStats

public void setQueueDoStats(boolean doStats)
Parameters:
doStats - The doStats to set.

isQueueTimeWait

public boolean isQueueTimeWait()
Returns:
Returns the timeWait.

setQueueTimeWait

public void setQueueTimeWait(boolean timeWait)
Parameters:
timeWait - The timeWait to set.

getMaxQueueLength

public int getMaxQueueLength()
Returns:
Returns the inQueueCounter.

setMaxQueueLength

public void setMaxQueueLength(int length)

getQueueAddWaitTime

public long getQueueAddWaitTime()
Returns:
Returns the add wait times.

getQueueRemoveWaitTime

public long getQueueRemoveWaitTime()
Returns:
Returns the add wait times.

getInQueueCounter

public long getInQueueCounter()
Returns:
Returns the inQueueCounter.

getOutQueueCounter

public long getOutQueueCounter()
Returns:
Returns the outQueueCounter.

getQueueSize

public int getQueueSize()
Returns:
Returns the queueSize.

getQueuedNrOfBytes

public long getQueuedNrOfBytes()
Returns:
Returns the queuedNrOfBytes.

connect

public void connect()
             throws java.io.IOException
Specified by:
connect in interface IDataSender
Overrides:
connect in class DataSender
Throws:
java.io.IOException

disconnect

public void disconnect()
Disconnect socket ad stop queue thread

Specified by:
disconnect in interface IDataSender
Overrides:
disconnect in class DataSender
See Also:
IDataSender.disconnect()

sendMessage

public void sendMessage(java.lang.String messageid,
                        byte[] data)
                 throws java.io.IOException
Specified by:
sendMessage in interface IDataSender
Overrides:
sendMessage in class DataSender
Throws:
java.io.IOException

resetStatistics

public void resetStatistics()
Overrides:
resetStatistics in class DataSender

toString

public java.lang.String toString()
Name of this SockerSender

Overrides:
toString in class DataSender

checkThread

protected void checkThread()
Start Queue thread as daemon


stopThread

protected void stopThread()
stop queue worker thread


reduceQueuedCounter

protected void reduceQueuedCounter(int size)


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