Class NioReceiver
java.lang.Object
org.apache.catalina.tribes.transport.ReceiverBase
org.apache.catalina.tribes.transport.nio.NioReceiver
- All Implemented Interfaces:
Runnable
,ChannelReceiver
,Heartbeat
,ListenCallback
,NioReceiverMBean
,RxTaskPool.TaskCreator
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected static final StringManager
The string manager for this package.Fields inherited from class org.apache.catalina.tribes.transport.ReceiverBase
OPTION_DIRECT_BUFFER
Fields inherited from interface org.apache.catalina.tribes.ChannelReceiver
MAX_UDP_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
bind()
static void
cancelledKey
(SelectionKey key) void
events()
protected void
listen()
Get data from channel and store in byte array send it to clusterprotected void
Sample data handler method for a channel with data ready to read.protected void
registerChannel
(Selector selector, SelectableChannel channel, int ops, Object attach) Register the given channel with the given selector for the given operations of interestvoid
run()
Start thread and listenprotected void
void
start()
Start listening for incoming messages on the host/portvoid
stop()
Stop listening for messagesprotected void
Close Selector.Methods inherited from class org.apache.catalina.tribes.transport.ReceiverBase
bind, 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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.catalina.tribes.transport.nio.NioReceiverMBean
getActiveCount, 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 Details
-
sm
The string manager for this package. -
events
-
lastCheck
protected long lastCheck
-
-
Constructor Details
-
NioReceiver
public NioReceiver()
-
-
Method Details
-
stop
public void stop()Description copied from interface:ChannelReceiver
Stop listening for messages- Specified by:
stop
in interfaceChannelReceiver
- Overrides:
stop
in classReceiverBase
-
start
Description copied from interface:ChannelReceiver
Start listening for incoming messages on the host/port- Specified by:
start
in interfaceChannelReceiver
- Overrides:
start
in classReceiverBase
- Throws:
IOException
- Listen failed
-
createRxTask
- Specified by:
createRxTask
in interfaceRxTaskPool.TaskCreator
-
bind
- Throws:
IOException
-
addEvent
-
events
public void events() -
cancelledKey
-
socketTimeouts
protected void socketTimeouts() -
listen
Get data from channel and store in byte array send it to cluster- Throws:
IOException
- IO errorException
-
stopListening
protected void stopListening()Close Selector.- See Also:
-
registerChannel
protected void registerChannel(Selector selector, SelectableChannel channel, int ops, Object attach) throws Exception Register the given channel with the given selector for the given operations of interest- Parameters:
selector
- The selector to usechannel
- The channelops
- The operations to registerattach
- Attachment object- Throws:
Exception
- IO error with channel
-
run
public void run()Start thread and listen -
readDataFromSocket
Sample 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:
Exception
- IO error with channel
-