org.apache.catalina.cluster.tcp
Class DataSender

java.lang.Object
  extended byorg.apache.catalina.cluster.tcp.DataSender
All Implemented Interfaces:
IDataSender
Direct Known Subclasses:
AsyncSocketSender, FastAsyncSocketSender, PooledSocketSender, SocketSender

public class DataSender
extends java.lang.Object
implements IDataSender

Send cluster messages with only one socket. Ack and keep Alive Handling is supported

Version:
$Revision: 1.4 $ $Date: 2005/03/25 22:06:10 $
Author:
Peter Rossbach, Filip Hanik

Field Summary
protected  long connectCounter
           
protected  long dataResendCounter
           
protected  long disconnectCounter
           
protected  boolean doProcessingStats
          doProcessingStats
protected  long maxProcessingTime
          max proessingTime
protected  long minProcessingTime
          min proessingTime
protected  long missingAckCounter
           
protected  long nrOfRequests
           
protected  long processingTime
          proessingTime
protected static StringManager sm
          The string manager for this package.
protected  long totalBytes
           
 
Constructor Summary
DataSender(java.net.InetAddress host, int port)
           
 
Method Summary
protected  void addProcessingStats(long startTime)
           
protected  void addStats(int length)
          Add statistic for this socket instance
 boolean checkIfCloseSocket()
          Check, if time to close socket!
protected  void closeSocket()
          close socket
 void connect()
           
 void disconnect()
          close socket
 long getAckTimeout()
           
 java.net.InetAddress getAddress()
           
 long getAvgProcessingTime()
           
 long getConnectCounter()
           
 long getDataResendCounter()
           
 long getDisconnectCounter()
           
 java.lang.String getInfo()
          Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.
 long getKeepAliveConnectTime()
           
 int getKeepAliveCount()
           
 int getKeepAliveMaxRequestCount()
           
 long getKeepAliveTimeout()
           
 long getMaxProcessingTime()
           
 long getMinProcessingTime()
           
 long getMissingAckCounter()
           
 long getNrOfRequests()
           
 int getPort()
           
 long getProcessingTime()
           
 int getSocketCloseCounter()
           
 int getSocketOpenCounter()
           
 boolean getSuspect()
           
 long getTotalBytes()
           
 boolean isConnected()
           
 boolean isDoProcessingStats()
           
 boolean isSuspect()
           
 boolean isWaitForAck()
           
protected  void openSocket()
           
protected  void pushMessage(java.lang.String messageid, byte[] data)
          push messages with only one socket at a time
 void resetStatistics()
           
 void sendMessage(java.lang.String messageid, byte[] data)
           
 void setAckTimeout(long ackTimeout)
           
 void setDoProcessingStats(boolean doProcessingStats)
           
 void setKeepAliveMaxRequestCount(int keepAliveMaxRequestCount)
           
 void setKeepAliveTimeout(long keepAliveTimeout)
           
protected  void setSocketConnected(boolean isSocketConnected)
           
 void setSuspect(boolean suspect)
           
 void setWaitForAck(boolean waitForAck)
           
 java.lang.String toString()
          Name of this SockerSender
protected  void waitForAck(long timeout)
          Wait for Acknowledgement from other server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sm

protected static StringManager sm
The string manager for this package.


nrOfRequests

protected long nrOfRequests

totalBytes

protected long totalBytes

connectCounter

protected long connectCounter

disconnectCounter

protected long disconnectCounter

missingAckCounter

protected long missingAckCounter

dataResendCounter

protected long dataResendCounter

doProcessingStats

protected boolean doProcessingStats
doProcessingStats


processingTime

protected long processingTime
proessingTime


minProcessingTime

protected long minProcessingTime
min proessingTime


maxProcessingTime

protected long maxProcessingTime
max proessingTime

Constructor Detail

DataSender

public DataSender(java.net.InetAddress host,
                  int 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>.


getNrOfRequests

public long getNrOfRequests()
Returns:
Returns the nrOfRequests.

getTotalBytes

public long getTotalBytes()
Returns:
Returns the totalBytes.

getAvgProcessingTime

public long getAvgProcessingTime()
Returns:
Returns the avg processingTime/nrOfRequests.

getMaxProcessingTime

public long getMaxProcessingTime()
Returns:
Returns the maxProcessingTime.

getMinProcessingTime

public long getMinProcessingTime()
Returns:
Returns the minProcessingTime.

getProcessingTime

public long getProcessingTime()
Returns:
Returns the processingTime.

isDoProcessingStats

public boolean isDoProcessingStats()
Returns:
Returns the doProcessingStats.

setDoProcessingStats

public void setDoProcessingStats(boolean doProcessingStats)
Parameters:
doProcessingStats - The doProcessingStats to set.

getConnectCounter

public long getConnectCounter()
Returns:
Returns the connectCounter.

getDisconnectCounter

public long getDisconnectCounter()
Returns:
Returns the disconnectCounter.

getMissingAckCounter

public long getMissingAckCounter()
Returns:
Returns the missingAckCounter.

getSocketOpenCounter

public int getSocketOpenCounter()
Returns:
Returns the socketOpenCounter.

getSocketCloseCounter

public int getSocketCloseCounter()
Returns:
Returns the socketCloseCounter.

getDataResendCounter

public long getDataResendCounter()
Returns:
Returns the dataResendCounter.

getAddress

public java.net.InetAddress getAddress()
Specified by:
getAddress in interface IDataSender

getPort

public int getPort()
Specified by:
getPort in interface IDataSender

isConnected

public boolean isConnected()
Specified by:
isConnected in interface IDataSender

setSocketConnected

protected void setSocketConnected(boolean isSocketConnected)
Parameters:
isSocketConnected - The isSocketConnected to set.

isSuspect

public boolean isSuspect()

getSuspect

public boolean getSuspect()
Specified by:
getSuspect in interface IDataSender

setSuspect

public void setSuspect(boolean suspect)
Specified by:
setSuspect in interface IDataSender

getAckTimeout

public long getAckTimeout()
Specified by:
getAckTimeout in interface IDataSender

setAckTimeout

public void setAckTimeout(long ackTimeout)
Specified by:
setAckTimeout in interface IDataSender

getKeepAliveTimeout

public long getKeepAliveTimeout()

setKeepAliveTimeout

public void setKeepAliveTimeout(long keepAliveTimeout)

getKeepAliveMaxRequestCount

public int getKeepAliveMaxRequestCount()

setKeepAliveMaxRequestCount

public void setKeepAliveMaxRequestCount(int keepAliveMaxRequestCount)

getKeepAliveConnectTime

public long getKeepAliveConnectTime()
Returns:
Returns the keepAliveConnectTime.

getKeepAliveCount

public int getKeepAliveCount()
Returns:
Returns the keepAliveCount.

isWaitForAck

public boolean isWaitForAck()
Specified by:
isWaitForAck in interface IDataSender
Returns:
Returns the waitForAck.

setWaitForAck

public void setWaitForAck(boolean waitForAck)
Specified by:
setWaitForAck in interface IDataSender
Parameters:
waitForAck - The waitForAck to set.

connect

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

disconnect

public void disconnect()
close socket

Specified by:
disconnect in interface IDataSender
See Also:
IDataSender.disconnect(), closeSocket()

checkIfCloseSocket

public boolean checkIfCloseSocket()
Check, if time to close socket! Important for AsyncSocketSender that replication thread is not fork again! Only work when keepAliveTimeout or keepAliveMaxRequestCount greater -1

Returns:
true, is socket close
See Also:
closeSocket()

sendMessage

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

resetStatistics

public void resetStatistics()

toString

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


openSocket

protected void openSocket()
                   throws java.io.IOException,
                          java.net.SocketException
Throws:
java.io.IOException
java.net.SocketException

closeSocket

protected void closeSocket()
close socket

See Also:
disconnect(), checkIfCloseSocket()

addStats

protected void addStats(int length)
Add statistic for this socket instance

Parameters:
length -

addProcessingStats

protected void addProcessingStats(long startTime)

pushMessage

protected void pushMessage(java.lang.String messageid,
                           byte[] data)
                    throws java.io.IOException
push messages with only one socket at a time

Parameters:
messageid - unique message id
data - data to send
Throws:
java.io.IOException

waitForAck

protected void waitForAck(long timeout)
                   throws java.io.IOException
Wait for Acknowledgement from other server

Parameters:
timeout -
Throws:
java.io.IOException


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