ReceiverBase (Apache Tomcat 11.0.8 API Documentation)
Description: declaration: package: org.apache.catalina.tribes.transport, class: ReceiverBase

# Class ReceiverBase

java.lang.Object
org.apache.catalina.tribes.transport.ReceiverBase

All Implemented Interfaces:
  `ChannelReceiver`, `Heartbeat`, `ListenCallback`, `RxTaskPool.TaskCreator`

Direct Known Subclasses:
  `NioReceiver`

public abstract class ReceiverBase extends Object implements ChannelReceiver, ListenCallback, RxTaskPool.TaskCreator

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `OPTION_DIRECT_BUFFER`
  `protected static final StringManager`
  `sm`

  ### Fields inherited from interface org.apache.catalina.tribes.ChannelReceiver

  `MAX_UDP_SIZE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReceiverBase()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `bind(ServerSocket socket, int portstart, int retries)`
  Attempts to bind using the provided port and if that fails attempts to bind to each of the ports from portstart to (portstart + retries -1) until either there are no more ports or the bind is successful.
  `protected int`
  `bindUdp(DatagramSocket socket, int portstart, int retries)`
  Same as bind() except it does it for the UDP port
  `boolean`
  `doListen()`
  `int`
  `getActiveCount()`
  Return the current number of threads that are in use.
  `String`
  `getAddress()`
  `int`
  `getAutoBind()`
  `InetAddress`
  `getBind()`
  `Channel`
  `getChannel()`
  Return the channel that is related to this ChannelReceiver
  `long`
  `getCompletedTaskCount()`
  Return the total number of tasks that have completed execution by the pool.
  `boolean`
  `getDirect()`
  `ExecutorService`
  `getExecutor()`
  `String`
  `getHost()`
  String representation of the IPv4 or IPv6 address that this host is listening to.
  `MessageListener`
  `getListener()`
  `long`
  `getMaxIdleTime()`
  `int`
  `getMaxTasks()`
  `int`
  `getMaxThreads()`
  `MessageListener`
  `getMessageListener()`
  Returns the message listener that is associated with this receiver
  `int`
  `getMinTasks()`
  `int`
  `getMinThreads()`
  `boolean`
  `getOoBInline()`
  `int`
  `getPoolSize()`
  Return the current number of threads that are managed by the pool.
  `int`
  `getPort()`
  Returns the listening port
  `int`
  `getRxBufSize()`
  `int`
  `getSecurePort()`
  Returns the secure listening port
  `long`
  `getSelectorTimeout()`
  `boolean`
  `getSoKeepAlive()`
  `boolean`
  `getSoLingerOn()`
  `int`
  `getSoLingerTime()`
  `boolean`
  `getSoReuseAddress()`
  `int`
  `getSoTrafficClass()`
  `long`
  `getTaskCount()`
  Return the total number of tasks that have ever been scheduled for execution by the pool.
  `RxTaskPool`
  `getTaskPool()`
  `boolean`
  `getTcpNoDelay()`
  `int`
  `getTimeout()`
  `int`
  `getTxBufSize()`
  `int`
  `getUdpPort()`
  Returns the UDP port
  `int`
  `getUdpRxBufSize()`
  `int`
  `getUdpTxBufSize()`
  `boolean`
  `getUseBufferPool()`
  `int`
  `getWorkerThreadOptions()`
  `void`
  `heartbeat()`
  Heartbeat invocation for resources cleanup etc
  `boolean`
  `isDaemon()`
  `boolean`
  `isListening()`
  `void`
  `messageDataReceived(ChannelMessage data)`
  This method is invoked on the callback object to notify it that new data has been received from one of the cluster nodes.
  `void`
  `setAddress(String host)`
  `void`
  `setAutoBind(int autoBind)`
  `void`
  `setBind(InetAddress bind)`
  `void`
  `setChannel(Channel channel)`
  Set the channel that is related to this ChannelReceiver
  `void`
  `setDaemon(boolean daemon)`
  `void`
  `setDirect(boolean direct)`
  `void`
  `setExecutor(ExecutorService executor)`
  `void`
  `setHost(String host)`
  `void`
  `setListen(boolean doListen)`
  `void`
  `setListener(MessageListener listener)`
  `void`
  `setMaxIdleTime(long maxIdleTime)`
  `void`
  `setMaxTasks(int maxTasks)`
  `void`
  `setMaxThreads(int maxThreads)`
  `void`
  `setMessageListener(MessageListener listener)`
  Sets the message listener to receive notification of incoming
  `void`
  `setMinTasks(int minTasks)`
  `void`
  `setMinThreads(int minThreads)`
  `void`
  `setOoBInline(boolean ooBInline)`
  `void`
  `setPool(RxTaskPool pool)`
  `void`
  `setPort(int port)`
  `void`
  `setRxBufSize(int rxBufSize)`
  `void`
  `setSecurePort(int securePort)`
  `void`
  `setSelectorTimeout(long selTimeout)`
  `void`
  `setSoKeepAlive(boolean soKeepAlive)`
  `void`
  `setSoLingerOn(boolean soLingerOn)`
  `void`
  `setSoLingerTime(int soLingerTime)`
  `void`
  `setSoReuseAddress(boolean soReuseAddress)`
  `void`
  `setSoTrafficClass(int soTrafficClass)`
  `void`
  `setTcpNoDelay(boolean tcpNoDelay)`
  `void`
  `setTimeout(int timeout)`
  `void`
  `setTxBufSize(int txBufSize)`
  `void`
  `setUdpPort(int udpPort)`
  `void`
  `setUdpRxBufSize(int udpRxBufSize)`
  `void`
  `setUdpTxBufSize(int udpTxBufSize)`
  `void`
  `setUseBufferPool(boolean useBufferPool)`
  `void`
  `start()`
  Start listening for incoming messages on the host/port
  `void`
  `stop()`
  Stop listening for messages

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.catalina.tribes.transport.RxTaskPool.TaskCreator

  `createRxTask`

- ## Field Details

  - ### OPTION_DIRECT_BUFFER

    public static final int OPTION_DIRECT_BUFFER
    See Also:
      - Constant Field Values

  - ### sm

    protected static final StringManager sm

- ## Constructor Details

  - ### ReceiverBase

    public ReceiverBase()

- ## Method Details

  - ### start

    public void start() throws IOException
    Description copied from interface: `ChannelReceiver`
    Start listening for incoming messages on the host/port
    Specified by:
      `start` in interface `ChannelReceiver`
    Throws:
      `IOException` - Listen failed

  - ### stop

    public void stop()
    Description copied from interface: `ChannelReceiver`
    Stop listening for messages
    Specified by:
      `stop` in interface `ChannelReceiver`

  - ### getMessageListener

    public MessageListener getMessageListener()
    Description copied from interface: `ChannelReceiver`
    Returns the message listener that is associated with this receiver
    Specified by:
      `getMessageListener` in interface `ChannelReceiver`
    Returns:
      MessageListener
    See Also:
      - `MessageListener`

  - ### getPort

    public int getPort()
    Description copied from interface: `ChannelReceiver`
    Returns the listening port
    Specified by:
      `getPort` in interface `ChannelReceiver`
    Returns:
      port

  - ### getRxBufSize

    public int getRxBufSize()

  - ### getTxBufSize

    public int getTxBufSize()

  - ### setMessageListener

    public void setMessageListener(MessageListener listener)
    Description copied from interface: `ChannelReceiver`
    Sets the message listener to receive notification of incoming
    Specified by:
      `setMessageListener` in interface `ChannelReceiver`
    Parameters:
      `listener` - MessageListener
    See Also:
      - `MessageListener`

  - ### setRxBufSize

    public void setRxBufSize(int rxBufSize)

  - ### setTxBufSize

    public void setTxBufSize(int txBufSize)

  - ### getBind

    public InetAddress getBind()
    Returns:
      Returns the bind.

  - ### bind

    protected void bind(ServerSocket socket, int portstart, int retries) throws IOException
    Attempts to bind using the provided port and if that fails attempts to bind to each of the ports from portstart to (portstart + retries -1) until either there are no more ports or the bind is successful. The address to bind to is obtained via a call to `getBind()`.
    Parameters:
      `socket` - The socket to bind
      `portstart` - Starting port for bind attempts
      `retries` - Number of times to attempt to bind (port incremented between attempts)
    Throws:
      `IOException` - Socket bind error

  - ### bindUdp

    protected int bindUdp(DatagramSocket socket, int portstart, int retries) throws IOException
    Same as bind() except it does it for the UDP port
    Parameters:
      `socket` - The socket to bind
      `portstart` - Starting port for bind attempts
      `retries` - Number of times to attempt to bind (port incremented between attempts)
    Returns:
      int The retry count
    Throws:
      `IOException` - Socket bind error

  - ### messageDataReceived

    public void messageDataReceived(ChannelMessage data)
    Description copied from interface: `ListenCallback`
    This method is invoked on the callback object to notify it that new data has been received from one of the cluster nodes.
    Specified by:
      `messageDataReceived` in interface `ListenCallback`
    Parameters:
      `data` - - the message bytes received from the cluster/replication system

  - ### getWorkerThreadOptions

    public int getWorkerThreadOptions()

  - ### setBind

    public void setBind(InetAddress bind)
    Parameters:
      `bind` - The bind to set.

  - ### getDirect

    public boolean getDirect()

  - ### setDirect

    public void setDirect(boolean direct)

  - ### getAddress

    public String getAddress()

  - ### getHost

    public String getHost()
    Description copied from interface: `ChannelReceiver`
    String representation of the IPv4 or IPv6 address that this host is listening to.
    Specified by:
      `getHost` in interface `ChannelReceiver`
    Returns:
      the host that this receiver is listening to

  - ### getSelectorTimeout

    public long getSelectorTimeout()

  - ### doListen

    public boolean doListen()

  - ### getListener

    public MessageListener getListener()

  - ### getTaskPool

    public RxTaskPool getTaskPool()

  - ### getAutoBind

    public int getAutoBind()

  - ### getMaxThreads

    public int getMaxThreads()

  - ### getMinThreads

    public int getMinThreads()

  - ### getTcpNoDelay

    public boolean getTcpNoDelay()

  - ### getSoKeepAlive

    public boolean getSoKeepAlive()

  - ### getOoBInline

    public boolean getOoBInline()

  - ### getSoLingerOn

    public boolean getSoLingerOn()

  - ### getSoLingerTime

    public int getSoLingerTime()

  - ### getSoReuseAddress

    public boolean getSoReuseAddress()

  - ### getSoTrafficClass

    public int getSoTrafficClass()

  - ### getTimeout

    public int getTimeout()

  - ### getUseBufferPool

    public boolean getUseBufferPool()

  - ### getSecurePort

    public int getSecurePort()
    Description copied from interface: `ChannelReceiver`
    Returns the secure listening port
    Specified by:
      `getSecurePort` in interface `ChannelReceiver`
    Returns:
      port, -1 if a secure port is not activated

  - ### getMinTasks

    public int getMinTasks()

  - ### getMaxTasks

    public int getMaxTasks()

  - ### getExecutor

    public ExecutorService getExecutor()

  - ### isListening

    public boolean isListening()

  - ### setSelectorTimeout

    public void setSelectorTimeout(long selTimeout)

  - ### setListen

    public void setListen(boolean doListen)

  - ### setAddress

    public void setAddress(String host)

  - ### setHost

    public void setHost(String host)

  - ### setListener

    public void setListener(MessageListener listener)

  - ### setPool

    public void setPool(RxTaskPool pool)

  - ### setPort

    public void setPort(int port)

  - ### setAutoBind

    public void setAutoBind(int autoBind)

  - ### setMaxThreads

    public void setMaxThreads(int maxThreads)

  - ### setMinThreads

    public void setMinThreads(int minThreads)

  - ### setTcpNoDelay

    public void setTcpNoDelay(boolean tcpNoDelay)

  - ### setSoKeepAlive

    public void setSoKeepAlive(boolean soKeepAlive)

  - ### setOoBInline

    public void setOoBInline(boolean ooBInline)

  - ### setSoLingerOn

    public void setSoLingerOn(boolean soLingerOn)

  - ### setSoLingerTime

    public void setSoLingerTime(int soLingerTime)

  - ### setSoReuseAddress

    public void setSoReuseAddress(boolean soReuseAddress)

  - ### setSoTrafficClass

    public void setSoTrafficClass(int soTrafficClass)

  - ### setTimeout

    public void setTimeout(int timeout)

  - ### setUseBufferPool

    public void setUseBufferPool(boolean useBufferPool)

  - ### setSecurePort

    public void setSecurePort(int securePort)

  - ### setMinTasks

    public void setMinTasks(int minTasks)

  - ### setMaxTasks

    public void setMaxTasks(int maxTasks)

  - ### setExecutor

    public void setExecutor(ExecutorService executor)

  - ### heartbeat

    public void heartbeat()
    Description copied from interface: `Heartbeat`
    Heartbeat invocation for resources cleanup etc
    Specified by:
      `heartbeat` in interface `Heartbeat`

  - ### getUdpPort

    public int getUdpPort()
    Description copied from interface: `ChannelReceiver`
    Returns the UDP port
    Specified by:
      `getUdpPort` in interface `ChannelReceiver`
    Returns:
      port, -1 if the UDP port is not activated.

  - ### setUdpPort

    public void setUdpPort(int udpPort)

  - ### getUdpRxBufSize

    public int getUdpRxBufSize()

  - ### setUdpRxBufSize

    public void setUdpRxBufSize(int udpRxBufSize)

  - ### getUdpTxBufSize

    public int getUdpTxBufSize()

  - ### setUdpTxBufSize

    public void setUdpTxBufSize(int udpTxBufSize)

  - ### getChannel

    public Channel getChannel()
    Description copied from interface: `ChannelReceiver`
    Return the channel that is related to this ChannelReceiver
    Specified by:
      `getChannel` in interface `ChannelReceiver`
    Returns:
      Channel

  - ### setChannel

    public void setChannel(Channel channel)
    Description copied from interface: `ChannelReceiver`
    Set the channel that is related to this ChannelReceiver
    Specified by:
      `setChannel` in interface `ChannelReceiver`
    Parameters:
      `channel` - The channel

  - ### getPoolSize

    public int getPoolSize()
    Return the current number of threads that are managed by the pool.
    Returns:
      the current number of threads that are managed by the pool

  - ### getActiveCount

    public int getActiveCount()
    Return the current number of threads that are in use.
    Returns:
      the current number of threads that are in use

  - ### getTaskCount

    public long getTaskCount()
    Return the total number of tasks that have ever been scheduled for execution by the pool.
    Returns:
      the total number of tasks that have ever been scheduled for execution by the pool

  - ### getCompletedTaskCount

    public long getCompletedTaskCount()
    Return the total number of tasks that have completed execution by the pool.
    Returns:
      the total number of tasks that have completed execution by the pool

  - ### isDaemon

    public boolean isDaemon()

  - ### getMaxIdleTime

    public long getMaxIdleTime()

  - ### setDaemon

    public void setDaemon(boolean daemon)

  - ### setMaxIdleTime

    public void setMaxIdleTime(long maxIdleTime)