Class NioReceiver
- java.lang.Object
- 
- org.apache.catalina.tribes.transport.ReceiverBase
- 
- org.apache.catalina.tribes.transport.nio.NioReceiver
 
 
- 
- All Implemented Interfaces:
- java.lang.Runnable,- ChannelReceiver,- Heartbeat,- ListenCallback,- NioReceiverMBean,- RxTaskPool.TaskCreator
 
 public class NioReceiver extends ReceiverBase implements java.lang.Runnable, NioReceiverMBean 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.Deque<java.lang.Runnable>eventsprotected longlastCheckprotected static StringManagersmThe string manager for this package.- 
Fields inherited from class org.apache.catalina.tribes.transport.ReceiverBaseOPTION_DIRECT_BUFFER
 - 
Fields inherited from interface org.apache.catalina.tribes.ChannelReceiverMAX_UDP_SIZE
 
- 
 - 
Constructor SummaryConstructors Constructor Description NioReceiver()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEvent(java.lang.Runnable event)protected voidbind()static voidcancelledKey(java.nio.channels.SelectionKey key)AbstractRxTaskcreateRxTask()voidevents()protected voidlisten()Get data from channel and store in byte array send it to clusterprotected voidreadDataFromSocket(java.nio.channels.SelectionKey key)Sample data handler method for a channel with data ready to read.protected voidregisterChannel(java.nio.channels.Selector selector, java.nio.channels.SelectableChannel channel, int ops, java.lang.Object attach)Register the given channel with the given selector for the given operations of interestvoidrun()Start thread and listenprotected voidsocketTimeouts()voidstart()Start cluster receiver.voidstop()Stop listening for messagesprotected voidstopListening()Close Selector.- 
Methods inherited from class org.apache.catalina.tribes.transport.ReceiverBasebind, bindUdp, doListen, getActiveCount, getAddress, getAutoBind, getBind, getChannel, getCompletedTaskCount, getDirect, getExecutor, getHost, getListener, getMaxIdleTime, getMaxTasks, getMaxThreads, getMessageListener, getMinTasks, getMinThreads, getOoBInline, getPoolSize, getPort, getRxBufSize, getSecurePort, getSelectorTimeout, getSoKeepAlive, getSoLingerOn, getSoLingerTime, getSoReuseAddress, getSoTrafficClass, getTaskCount, getTaskPool, getTcpNoDelay, getTimeout, getTxBufSize, getUdpPort, getUdpRxBufSize, getUdpTxBufSize, getUseBufferPool, getWorkerThreadOptions, heartbeat, isDaemon, isListening, messageDataReceived, setAddress, setAutoBind, setBind, setChannel, setDaemon, setDirect, setExecutor, setHost, setListen, setListener, setMaxIdleTime, setMaxTasks, setMaxThreads, setMessageListener, setMinTasks, setMinThreads, setOoBInline, setPool, setPort, setRxBufSize, setSecurePort, setSelectorTimeout, setSoKeepAlive, setSoLingerOn, setSoLingerTime, setSoReuseAddress, setSoTrafficClass, setTcpNoDelay, setTimeout, setTxBufSize, setUdpPort, setUdpRxBufSize, setUdpTxBufSize, setUseBufferPool
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.catalina.tribes.transport.nio.NioReceiverMBeangetActiveCount, getAddress, getAutoBind, getCompletedTaskCount, getDirect, getMaxIdleTime, getMaxThreads, getMinThreads, getOoBInline, getPoolSize, getPort, getRxBufSize, getSecurePort, getSelectorTimeout, getSoKeepAlive, getSoLingerOn, getSoLingerTime, getSoReuseAddress, getTaskCount, getTcpNoDelay, getTimeout, getTxBufSize, getUdpPort, getUdpRxBufSize, getUdpTxBufSize, getUseBufferPool, isListening
 
- 
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm The string manager for this package.
 - 
eventsprotected final java.util.Deque<java.lang.Runnable> events 
 - 
lastCheckprotected long lastCheck 
 
- 
 - 
Method Detail- 
stoppublic void stop() Description copied from interface:ChannelReceiverStop listening for messages- Specified by:
- stopin interface- ChannelReceiver
- Overrides:
- stopin class- ReceiverBase
 
 - 
startpublic void start() throws java.io.IOExceptionStart cluster receiver.- Specified by:
- startin interface- ChannelReceiver
- Overrides:
- startin class- ReceiverBase
- Throws:
- java.io.IOException- If the receiver fails to start
- See Also:
- ChannelReceiver.start()
 
 - 
createRxTaskpublic AbstractRxTask createRxTask() - Specified by:
- createRxTaskin interface- RxTaskPool.TaskCreator
 
 - 
bindprotected void bind() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
addEventpublic void addEvent(java.lang.Runnable event) 
 - 
eventspublic void events() 
 - 
cancelledKeypublic static void cancelledKey(java.nio.channels.SelectionKey key) 
 - 
socketTimeoutsprotected void socketTimeouts() 
 - 
listenprotected void listen() throws java.lang.ExceptionGet data from channel and store in byte array send it to cluster- Throws:
- java.io.IOException- IO error
- java.lang.Exception
 
 - 
stopListeningprotected void stopListening() Close Selector.- See Also:
- ReceiverBase.stop()
 
 - 
registerChannelprotected void registerChannel(java.nio.channels.Selector selector, java.nio.channels.SelectableChannel channel, int ops, java.lang.Object attach) throws java.lang.ExceptionRegister the given channel with the given selector for the given operations of interest- Parameters:
- selector- The selector to use
- channel- The channel
- ops- The operations to register
- attach- Attachment object
- Throws:
- java.lang.Exception- IO error with channel
 
 - 
runpublic void run() Start thread and listen- Specified by:
- runin interface- java.lang.Runnable
 
 - 
readDataFromSocketprotected void readDataFromSocket(java.nio.channels.SelectionKey key) throws java.lang.ExceptionSample data handler method for a channel with data ready to read.- Parameters:
- key- A SelectionKey object associated with a channel determined by the selector to be ready for reading. If the channel returns an EOF condition, it is closed here, which automatically invalidates the associated key. The selector will then de-register the channel on the next select call.
- Throws:
- java.lang.Exception- IO error with channel
 
 
- 
 
-