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 SummaryFieldsFields inherited from interface org.apache.catalina.tribes.ChannelReceiverMAX_UDP_SIZE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidbind(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 intbindUdp(DatagramSocket socket, int portstart, int retries) Same as bind() except it does it for the UDP portbooleandoListen()intReturn the current number of threads that are in use.intgetBind()Return the channel that is related to this ChannelReceiverlongReturn the total number of tasks that have completed execution by the pool.booleangetHost()String representation of the IPv4 or IPv6 address that this host is listening to.longintintgetMessageListenerintintbooleanintReturn the current number of threads that are managed by the pool.intgetPort()Returns the listening portintintReturns the secure listening portlongbooleanbooleanintbooleanintlongReturn the total number of tasks that have ever been scheduled for execution by the pool.booleanintintintReturns the UDP portintintbooleanintvoidHeartbeat invocation for resources cleanup etcbooleanisDaemon()booleanvoidThis method is invoked on the callback object to notify it that new data has been received from one of the cluster nodes.voidsetAddress(String host) voidsetAutoBind(int autoBind) voidsetBind(InetAddress bind) voidsetChannel(Channel channel) Set the channel that is related to this ChannelReceivervoidsetDaemon(boolean daemon) voidsetDirect(boolean direct) voidsetExecutor(ExecutorService executor) voidvoidsetListen(boolean doListen) voidsetListener(MessageListener listener) voidsetMaxIdleTime(long maxIdleTime) voidsetMaxTasks(int maxTasks) voidsetMaxThreads(int maxThreads) voidsetMessageListener(MessageListener listener) setMessageListenervoidsetMinTasks(int minTasks) voidsetMinThreads(int minThreads) voidsetOoBInline(boolean ooBInline) voidsetPool(RxTaskPool pool) voidsetPort(int port) voidsetRxBufSize(int rxBufSize) voidsetSecurePort(int securePort) voidsetSelectorTimeout(long selTimeout) voidsetSoKeepAlive(boolean soKeepAlive) voidsetSoLingerOn(boolean soLingerOn) voidsetSoLingerTime(int soLingerTime) voidsetSoReuseAddress(boolean soReuseAddress) voidsetSoTrafficClass(int soTrafficClass) voidsetTcpNoDelay(boolean tcpNoDelay) voidsetTimeout(int timeout) voidsetTxBufSize(int txBufSize) voidsetUdpPort(int udpPort) voidsetUdpRxBufSize(int udpRxBufSize) voidsetUdpTxBufSize(int udpTxBufSize) voidsetUseBufferPool(boolean useBufferPool) voidstart()Start listening for incoming messages on the host/portvoidstop()Stop listening for messagesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.catalina.tribes.transport.RxTaskPool.TaskCreatorcreateRxTask
- 
Field Details- 
OPTION_DIRECT_BUFFERpublic static final int OPTION_DIRECT_BUFFER- See Also:
 
- 
sm
 
- 
- 
Constructor Details- 
ReceiverBasepublic ReceiverBase()
 
- 
- 
Method Details- 
startDescription copied from interface:ChannelReceiverStart listening for incoming messages on the host/port- Specified by:
- startin interface- ChannelReceiver
- Throws:
- IOException- Listen failed
 
- 
stoppublic void stop()Description copied from interface:ChannelReceiverStop listening for messages- Specified by:
- stopin interface- ChannelReceiver
 
- 
getMessageListenergetMessageListener- Specified by:
- getMessageListenerin interface- ChannelReceiver
- Returns:
- MessageListener
- See Also:
 
- 
getPortpublic int getPort()Description copied from interface:ChannelReceiverReturns the listening port- Specified by:
- getPortin interface- ChannelReceiver
- Returns:
- The port
 
- 
getRxBufSizepublic int getRxBufSize()
- 
getTxBufSizepublic int getTxBufSize()
- 
setMessageListenersetMessageListener- Specified by:
- setMessageListenerin interface- ChannelReceiver
- Parameters:
- listener- MessageListener
- See Also:
 
- 
setRxBufSizepublic void setRxBufSize(int rxBufSize) 
- 
setTxBufSizepublic void setTxBufSize(int txBufSize) 
- 
getBind- Returns:
- Returns the bind.
 
- 
bindAttempts 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 {linkgetBind().- 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
 
- 
bindUdpSame 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
 
- 
messageDataReceivedDescription copied from interface:ListenCallbackThis method is invoked on the callback object to notify it that new data has been received from one of the cluster nodes.- Specified by:
- messageDataReceivedin interface- ListenCallback
- Parameters:
- data- - the message bytes received from the cluster/replication system
 
- 
getWorkerThreadOptionspublic int getWorkerThreadOptions()
- 
setBind- Parameters:
- bind- The bind to set.
 
- 
getDirectpublic boolean getDirect()
- 
setDirectpublic void setDirect(boolean direct) 
- 
getAddress
- 
getHostDescription copied from interface:ChannelReceiverString representation of the IPv4 or IPv6 address that this host is listening to.- Specified by:
- getHostin interface- ChannelReceiver
- Returns:
- the host that this receiver is listening to
 
- 
getSelectorTimeoutpublic long getSelectorTimeout()
- 
doListenpublic boolean doListen()
- 
getListener
- 
getTaskPool
- 
getAutoBindpublic int getAutoBind()
- 
getMaxThreadspublic int getMaxThreads()
- 
getMinThreadspublic int getMinThreads()
- 
getTcpNoDelaypublic boolean getTcpNoDelay()
- 
getSoKeepAlivepublic boolean getSoKeepAlive()
- 
getOoBInlinepublic boolean getOoBInline()
- 
getSoLingerOnpublic boolean getSoLingerOn()
- 
getSoLingerTimepublic int getSoLingerTime()
- 
getSoReuseAddresspublic boolean getSoReuseAddress()
- 
getSoTrafficClasspublic int getSoTrafficClass()
- 
getTimeoutpublic int getTimeout()
- 
getUseBufferPoolpublic boolean getUseBufferPool()
- 
getSecurePortpublic int getSecurePort()Description copied from interface:ChannelReceiverReturns the secure listening port- Specified by:
- getSecurePortin interface- ChannelReceiver
- Returns:
- port, -1 if a secure port is not activated
 
- 
getMinTaskspublic int getMinTasks()
- 
getMaxTaskspublic int getMaxTasks()
- 
getExecutor
- 
isListeningpublic boolean isListening()
- 
setSelectorTimeoutpublic void setSelectorTimeout(long selTimeout) 
- 
setListenpublic void setListen(boolean doListen) 
- 
setAddress
- 
setHost
- 
setListener
- 
setPool
- 
setPortpublic void setPort(int port) 
- 
setAutoBindpublic void setAutoBind(int autoBind) 
- 
setMaxThreadspublic void setMaxThreads(int maxThreads) 
- 
setMinThreadspublic void setMinThreads(int minThreads) 
- 
setTcpNoDelaypublic void setTcpNoDelay(boolean tcpNoDelay) 
- 
setSoKeepAlivepublic void setSoKeepAlive(boolean soKeepAlive) 
- 
setOoBInlinepublic void setOoBInline(boolean ooBInline) 
- 
setSoLingerOnpublic void setSoLingerOn(boolean soLingerOn) 
- 
setSoLingerTimepublic void setSoLingerTime(int soLingerTime) 
- 
setSoReuseAddresspublic void setSoReuseAddress(boolean soReuseAddress) 
- 
setSoTrafficClasspublic void setSoTrafficClass(int soTrafficClass) 
- 
setTimeoutpublic void setTimeout(int timeout) 
- 
setUseBufferPoolpublic void setUseBufferPool(boolean useBufferPool) 
- 
setSecurePortpublic void setSecurePort(int securePort) 
- 
setMinTaskspublic void setMinTasks(int minTasks) 
- 
setMaxTaskspublic void setMaxTasks(int maxTasks) 
- 
setExecutor
- 
heartbeatpublic void heartbeat()Description copied from interface:HeartbeatHeartbeat invocation for resources cleanup etc
- 
getUdpPortpublic int getUdpPort()Description copied from interface:ChannelReceiverReturns the UDP port- Specified by:
- getUdpPortin interface- ChannelReceiver
- Returns:
- port, -1 if the UDP port is not activated.
 
- 
setUdpPortpublic void setUdpPort(int udpPort) 
- 
getUdpRxBufSizepublic int getUdpRxBufSize()
- 
setUdpRxBufSizepublic void setUdpRxBufSize(int udpRxBufSize) 
- 
getUdpTxBufSizepublic int getUdpTxBufSize()
- 
setUdpTxBufSizepublic void setUdpTxBufSize(int udpTxBufSize) 
- 
getChannelDescription copied from interface:ChannelReceiverReturn the channel that is related to this ChannelReceiver- Specified by:
- getChannelin interface- ChannelReceiver
- Returns:
- Channel
 
- 
setChannelDescription copied from interface:ChannelReceiverSet the channel that is related to this ChannelReceiver- Specified by:
- setChannelin interface- ChannelReceiver
- Parameters:
- channel- The channel
 
- 
getPoolSizepublic 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
 
- 
getActiveCountpublic int getActiveCount()Return the current number of threads that are in use.- Returns:
- the current number of threads that are in use
 
- 
getTaskCountpublic 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
 
- 
getCompletedTaskCountpublic 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
 
- 
isDaemonpublic boolean isDaemon()
- 
getMaxIdleTimepublic long getMaxIdleTime()
- 
setDaemonpublic void setDaemon(boolean daemon) 
- 
setMaxIdleTimepublic void setMaxIdleTime(long maxIdleTime) 
 
-