Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    java.lang.Object
      org.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

Since:
  5.5.7
Version:
  $Revision: 571204 $ $Date: 2007-08-30 09:25:46 -0600 (Thu, 30 Aug 2007) $
Author:
  Peter Rossbach, Filip Hanik

Field Summary
`protected long` | `connectCounter` number of connects
`protected long` | `createTime` createTime
`protected long` | `dataFailureCounter` number of data failure sends
`protected long` | `dataResendCounter` number of data resends (second trys after socket failure)
`protected long` | `disconnectCounter` number of explizit disconnects
`protected boolean` | `doProcessingStats` doProcessingStats
`protected boolean` | `doWaitAckStats` doWaitAckStats
`protected long` | `keepAliveConnectTime` Last connect timestamp
`protected int` | `keepAliveCount` keepalive counter
`protected long` | `maxProcessingTime` max proessingTime
`protected long` | `maxWaitAckTime` max waitAckTime
`protected long` | `minProcessingTime` min proessingTime
`protected long` | `minWaitAckTime` min waitAckTime
`protected long` | `missingAckCounter` number of failing acks
`protected long` | `nrOfRequests` number of requests
`protected long` | `processingTime` proessingTime
`protected static StringManager` | `sm` The string manager for this package.
`protected long` | `totalBytes` total bytes to transfer
`protected long` | `waitAckTime` waitAckTime

Constructor Summary
`DataSender(java.lang.String domain, java.net.InetAddress host, int port)`
`DataSender(java.lang.String domain, java.net.InetAddress host, int port, SenderState state)`

Method Summary
`protected void` | `addProcessingStats(long startTime)` Add processing stats times
`protected void` | `addStats(int length)` Add statistic for this socket instance
`protected void` | `addWaitAckStats(long startTime)` Add waitAck stats times
`boolean` | `checkKeepAlive()` Check, if time to close socket!
`protected void` | `closeSocket()` close socket
`void` | `connect()` Connect other cluster member receiver
`protected void` | `createSocket()` Create new Socket and use actTimeout (>0) as connect timeout
`void` | `disconnect()` disconnect and close socket
`long` | `getAckTimeout()` Deprecated. since 5.5.25 use timeout instead
`java.net.InetAddress` | `getAddress()`
`long` | `getAvgMessageSize()`
`double` | `getAvgProcessingTime()`
`double` | `getAvgWaitAckTime()`
`long` | `getConnectCounter()`
`long` | `getCreateTime()`
`long` | `getDataFailureCounter()`
`long` | `getDataResendCounter()`
`long` | `getDisconnectCounter()`
`java.lang.String` | `getDomain()`
`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` | `getMaxWaitAckTime()`
`long` | `getMinProcessingTime()`
`long` | `getMinWaitAckTime()`
`long` | `getMissingAckCounter()`
`long` | `getNrOfRequests()`
`int` | `getPort()`
`long` | `getProcessingTime()`
`int` | `getRxBufSize()`
`SenderState` | `getSenderState()`
`java.net.Socket` | `getSocket()`
`int` | `getSocketCloseCounter()`
`int` | `getSocketOpenCounter()`
`int` | `getSocketOpenFailureCounter()`
`int` | `getSoLingerTime()`
`int` | `getSoTrafficClass()`
`boolean` | `getSuspect()`
`int` | `getTimeout()`
`long` | `getTotalBytes()`
`int` | `getTxBufSize()`
`long` | `getWaitAckTime()`
`boolean` | `isConnected()`
`boolean` | `isDoProcessingStats()`
`boolean` | `isDoWaitAckStats()`
`boolean` | `isMessageTransferStarted()`
`boolean` | `isOoBInline()`
`boolean` | `isResend()`
`boolean` | `isSoKeepAlive()`
`boolean` | `isSoLingerOn()`
`boolean` | `isSoReuseAddress()`
`boolean` | `isSuspect()`
`boolean` | `isTcpNoDelay()`
`boolean` | `isWaitForAck()`
`protected void` | `openSocket()` open real socket and set time out when waitForAck is enabled is socket open return directly
`protected void` | `pushMessage(ClusterData data)` Push messages with only one socket at a time Wait for ack is needed and make auto retry when write message is failed.
`void` | `resetStatistics()` Reset sender statistics
`void` | `sendMessage(ClusterData data)` Send message
`void` | `setAckTimeout(long ackTimeout)` Deprecated. since 5.5.25 use timeout instead
`void` | `setAddress(java.net.InetAddress address)`
`void` | `setDomain(java.lang.String domain)`
`void` | `setDoProcessingStats(boolean doProcessingStats)`
`void` | `setDoWaitAckStats(boolean doWaitAckStats)`
`void` | `setKeepAliveMaxRequestCount(int keepAliveMaxRequestCount)`
`void` | `setKeepAliveTimeout(long keepAliveTimeout)`
`void` | `setOoBInline(boolean ooBInline)`
`void` | `setPort(int port)`
`void` | `setResend(boolean resend)`
`void` | `setRxBufSize(int rxBufSize)`
`void` | `setSocket(java.net.Socket socket)`
`protected void` | `setSocketConnected(boolean isSocketConnected)`
`void` | `setSoKeepAlive(boolean soKeepAlive)`
`void` | `setSoLingerOn(boolean soLingerOn)`
`void` | `setSoLingerTime(int soLingerTime)`
`void` | `setSoReuseAddress(boolean soReuseAddress)`
`void` | `setSoTrafficClass(int soTrafficClass)`
`void` | `setSuspect(boolean suspect)`
`void` | `setTcpNoDelay(boolean tcpNoDelay)`
`void` | `setTimeout(int timeout)`
`void` | `setTxBufSize(int txBufSize)`
`void` | `setWaitForAck(boolean waitForAck)`
`java.lang.String` | `toString()` Name of this SockerSender
`protected void` | `waitForAck(long timeout)` Wait for Acknowledgement from other server FIXME Please, not wait only for three charcters, better control that the wait ack message is correct.
`protected void` | `writeData(ClusterData data)` Sent real cluster Message to socket stream FIXME send compress

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.

### createTime

    protected long createTime

  createTime

### nrOfRequests

    protected long nrOfRequests

  number of requests

### totalBytes

    protected long totalBytes

  total bytes to transfer

### connectCounter

    protected long connectCounter

  number of connects

### disconnectCounter

    protected long disconnectCounter

  number of explizit disconnects

### missingAckCounter

    protected long missingAckCounter

  number of failing acks

### dataResendCounter

    protected long dataResendCounter

  number of data resends (second trys after socket failure)

### dataFailureCounter

    protected long dataFailureCounter

  number of data failure sends

### doProcessingStats

    protected boolean doProcessingStats

  doProcessingStats

### processingTime

    protected long processingTime

  proessingTime

### minProcessingTime

    protected long minProcessingTime

  min proessingTime

### maxProcessingTime

    protected long maxProcessingTime

  max proessingTime

### doWaitAckStats

    protected boolean doWaitAckStats

  doWaitAckStats

### waitAckTime

    protected long waitAckTime

  waitAckTime

### minWaitAckTime

    protected long minWaitAckTime

  min waitAckTime

### maxWaitAckTime

    protected long maxWaitAckTime

  max waitAckTime

### keepAliveConnectTime

    protected long keepAliveConnectTime

  Last connect timestamp

### keepAliveCount

    protected int keepAliveCount

  keepalive counter

Constructor Detail

### DataSender

    public DataSender(java.lang.String domain,
                      java.net.InetAddress host,
                      int port)

### DataSender

    public DataSender(java.lang.String domain,
                      java.net.InetAddress host,
                      int port,
                      SenderState state)

Method Detail

### getInfo

    public java.lang.String getInfo()

  Return descriptive information about this implementation and the corresponding version number, in the format `<description>/<version>`.

### getCreateTime

    public long getCreateTime()

  Returns:
    the createTime

### getNrOfRequests

    public long getNrOfRequests()

  Returns:
    Returns the nrOfRequests.

### getTotalBytes

    public long getTotalBytes()

  Returns:
    Returns the totalBytes.

### getAvgMessageSize

    public long getAvgMessageSize()

  Returns:
    Returns the avg totalBytes/nrOfRequests.

### getAvgProcessingTime

    public double 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.

### isDoWaitAckStats

    public boolean isDoWaitAckStats()

  Returns:
    Returns the doWaitAckStats.

### setDoWaitAckStats

    public void setDoWaitAckStats(boolean doWaitAckStats)

  Parameters:
    `doWaitAckStats` - The doWaitAckStats to set.

### getAvgWaitAckTime

    public double getAvgWaitAckTime()

  Returns:
    Returns the avg waitAckTime/nrOfRequests.

### getMaxWaitAckTime

    public long getMaxWaitAckTime()

  Returns:
    Returns the maxWaitAckTime.

### getMinWaitAckTime

    public long getMinWaitAckTime()

  Returns:
    Returns the minWaitAckTime.

### getWaitAckTime

    public long getWaitAckTime()

  Returns:
    Returns the waitAckTime.

### 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.

### getSocketOpenFailureCounter

    public int getSocketOpenFailureCounter()

  Returns:
    Returns the socketOpenFailureCounter.

### getSocketCloseCounter

    public int getSocketCloseCounter()

  Returns:
    Returns the socketCloseCounter.

### getDataResendCounter

    public long getDataResendCounter()

  Returns:
    Returns the dataResendCounter.

### getDataFailureCounter

    public long getDataFailureCounter()

  Returns:
    Returns the dataFailureCounter.

### setAddress

    public void setAddress(java.net.InetAddress address)

  Specified by:
    `setAddress` in interface `IDataSender`
  Parameters:
    `address` - The address to set.

### getAddress

    public java.net.InetAddress getAddress()

  Specified by:
    `getAddress` in interface `IDataSender`

### setPort

    public void setPort(int port)

  Specified by:
    `setPort` in interface `IDataSender`
  Parameters:
    `port` - The port to set.

### getPort

    public int getPort()

  Specified by:
    `getPort` in interface `IDataSender`

### getDomain

    public java.lang.String getDomain()

  Specified by:
    `getDomain` in interface `IDataSender`
  Returns:
    Returns the domain.

### setDomain

    public void setDomain(java.lang.String domain)

  Specified by:
    `setDomain` in interface `IDataSender`
  Parameters:
    `domain` - The domain to set.

### isConnected

    public boolean isConnected()

  Specified by:
    `isConnected` in interface `IDataSender`

### isMessageTransferStarted

    public boolean isMessageTransferStarted()

  Returns:
    Is DataSender send a message

### 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`

### isOoBInline

    public boolean isOoBInline()

  Returns:
    the ooBInline
  Since:
    5.5.25

### setOoBInline

    public void setOoBInline(boolean ooBInline)

  Parameters:
    `ooBInline` - the ooBInline to set
  Since:
    5.5.25

### getRxBufSize

    public int getRxBufSize()

  Returns:
    the rxBufSize
  Since:
    5.5.25

### setRxBufSize

    public void setRxBufSize(int rxBufSize)

  Parameters:
    `rxBufSize` - the rxBufSize to set
  Since:
    5.5.25

### isSoKeepAlive

    public boolean isSoKeepAlive()

  Returns:
    the soKeepAlive
  Since:
    5.5.25

### setSoKeepAlive

    public void setSoKeepAlive(boolean soKeepAlive)

  Parameters:
    `soKeepAlive` - the soKeepAlive to set
  Since:
    5.5.25

### isSoLingerOn

    public boolean isSoLingerOn()

  Returns:
    the soLingerOn
  Since:
    5.5.25

### setSoLingerOn

    public void setSoLingerOn(boolean soLingerOn)

  Parameters:
    `soLingerOn` - the soLingerOn to set
  Since:
    5.5.25

### getSoLingerTime

    public int getSoLingerTime()

  Returns:
    the soLingerTime
  Since:
    5.5.25

### setSoLingerTime

    public void setSoLingerTime(int soLingerTime)

  Parameters:
    `soLingerTime` - the soLingerTime to set
  Since:
    5.5.25

### isSoReuseAddress

    public boolean isSoReuseAddress()

  Returns:
    the soReuseAddress
  Since:
    5.5.25

### setSoReuseAddress

    public void setSoReuseAddress(boolean soReuseAddress)

  Parameters:
    `soReuseAddress` - the soReuseAddress to set
  Since:
    5.5.25

### getSoTrafficClass

    public int getSoTrafficClass()

  Returns:
    the soTrafficClass
  Since:
    5.5.25

### setSoTrafficClass

    public void setSoTrafficClass(int soTrafficClass)

  Parameters:
    `soTrafficClass` - the soTrafficClass to set
  Since:
    5.5.25

### isTcpNoDelay

    public boolean isTcpNoDelay()

  Returns:
    the tcpNoDelay
  Since:
    5.5.25

### setTcpNoDelay

    public void setTcpNoDelay(boolean tcpNoDelay)

  Parameters:
    `tcpNoDelay` - the tcpNoDelay to set
  Since:
    5.5.25

### getTimeout

    public int getTimeout()

  Returns:
    the timeout
  Since:
    5.5.25

### setTimeout

    public void setTimeout(int timeout)

  Parameters:
    `timeout` - the timeout to set
  Since:
    5.5.25

### getTxBufSize

    public int getTxBufSize()

  Returns:
    the txBufSize
  Since:
    5.5.25

### setTxBufSize

    public void setTxBufSize(int txBufSize)

  Parameters:
    `txBufSize` - the txBufSize to set
  Since:
    5.5.25

### getAckTimeout

    public long getAckTimeout()

  Deprecated. since 5.5.25 use timeout instead

  Specified by:
    `getAckTimeout` in interface `IDataSender`

### setAckTimeout

    public void setAckTimeout(long ackTimeout)

  Deprecated. since 5.5.25 use timeout instead

  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.

### isResend

    public boolean isResend()

  Returns:
    Returns the resend.

### setResend

    public void setResend(boolean resend)

  Parameters:
    `resend` - The resend to set.

### getSocket

    public java.net.Socket getSocket()

  Returns:
    Returns the socket.

### getSenderState

    public SenderState getSenderState()

### setSocket

    public void setSocket(java.net.Socket socket)

  Parameters:
    `socket` - The socket to set.

### connect

    public void connect()
                 throws java.io.IOException

  Connect other cluster member receiver

  Specified by:
    `connect` in interface `IDataSender`
  Throws:
    `java.io.IOException`
  See Also:
    `IDataSender.connect()`

### disconnect

    public void disconnect()

  disconnect and close socket

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

### checkKeepAlive

    public boolean checkKeepAlive()

  Check, if time to close socket! Important for AsyncSocketSender that replication thread is not fork again! Only work when keepAliveTimeout or keepAliveMaxRequestCount greater -1 FIXME Can we close a socket when a message wait for ack?

  Specified by:
    `checkKeepAlive` in interface `IDataSender`
  Returns:
    true, is socket close
  See Also:
    `closeSocket()`

### sendMessage

    public void sendMessage(ClusterData data)
                     throws java.io.IOException

  Send message

  Specified by:
    `sendMessage` in interface `IDataSender`
  Throws:
    `java.io.IOException`
  See Also:
    `IDataSender.sendMessage(, ClusterData)`

### resetStatistics

    public void resetStatistics()

  Reset sender statistics

### toString

    public java.lang.String toString()

  Name of this SockerSender

### openSocket

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

  open real socket and set time out when waitForAck is enabled is socket open return directly

  Throws:
    `java.io.IOException`
    `java.net.SocketException`

### createSocket

    protected void createSocket()
                         throws java.io.IOException,
                                java.net.SocketException

  Create new Socket and use actTimeout (>0) as connect timeout

  Throws:
    `java.io.IOException`
    `java.net.SocketException`

### closeSocket

    protected void closeSocket()

  close socket

  See Also:
    `disconnect()`, `closeSocket()`

### addStats

    protected void addStats(int length)

  Add statistic for this socket instance

  Parameters:
    `length` -

### addProcessingStats

    protected void addProcessingStats(long startTime)

  Add processing stats times

  Parameters:
    `startTime` -

### addWaitAckStats

    protected void addWaitAckStats(long startTime)

  Add waitAck stats times

  Parameters:
    `startTime` -

### pushMessage

    protected void pushMessage(ClusterData data)
                        throws java.io.IOException

  Push messages with only one socket at a time Wait for ack is needed and make auto retry when write message is failed. After sending error close and reopen socket again. After successfull sending update stats WARNING: Subclasses must be very carefull that only one thread call this pushMessage at once!!!

  Parameters:
    `data` - data to send
  Throws:
    `java.io.IOException`
  Since:
    5.5.10
  See Also:
    `closeSocket()`, `openSocket()`, `writeData(ClusterData)`

### writeData

    protected void writeData(ClusterData data)
                      throws java.io.IOException

  Sent real cluster Message to socket stream FIXME send compress

  Parameters:
    `data` -
  Throws:
    `java.io.IOException`
  Since:
    5.5.10

### waitForAck

    protected void waitForAck(long timeout)
                       throws java.io.IOException

  Wait for Acknowledgement from other server FIXME Please, not wait only for three charcters, better control that the wait ack message is correct.

  Parameters:
    `timeout` -
  Throws:
    `java.io.IOException`
    `java.net.SocketTimeoutException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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