public class IoProcessor extends java.lang.Object implements IoProcessorMBean
EventDispatcher.
IoProcessorconsists of two controller threads and other worker
threads:
SessionListener.sessionIdle(Session)eventSession.write(Message)requestEventDispatcher.
IoProcessorhas properties such as:
threadPoolSize: the number of worker
threadscontrollerThreadPriority: the thread
priority of the controller threads. Default is Thread.NORM_PRIORITY.
threadPriority: the thread priority of
the worker threads. Default is Thread.NORM_PRIORITY.readTries: the max number of read
tries per OP_READ event; Some NIO implementations does not read all data at
once. Default is 2.
To activate, call start()method.
| Constructor and Description |
|---|
IoProcessor()
Constructs a new instance with default properties.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getControllerThreadPriority()
Returns the priority of controller threads.
|
ExceptionMonitor |
getExceptionMonitor()
Returns the
ExceptionMonitor. |
int |
getReadTries()
Deprecated.
Netty2 now automatically retries a read operation until it
returns 0.
|
java.lang.String |
getThreadNamePrefix()
Returns the prefix of the I/O thread name.
|
int |
getThreadPoolSize()
Returns the number of worker threads.
|
int |
getThreadPriority()
Returns the priority of worker threads.
|
boolean |
isStarted()
Returns
true only if this I/O processor is started. |
void |
setControllerThreadPriority(int newPriority)
Sets the priority of controller threads.
|
void |
setExceptionMonitor(ExceptionMonitor monitor)
Sets the
ExceptionMonitor. |
void |
setReadTries(int readTries)
Deprecated.
Netty2 now automatically retries a read operation until it
returns 0.
|
void |
setThreadNamePrefix(java.lang.String threadNamePrefix)
Sets the prefix of the I/O thread name.
|
void |
setThreadPoolSize(int newSize)
Sets the number of worker threads.
|
void |
setThreadPriority(int newPriority)
Sets the priority of worker threads.
|
void |
start()
Starts all controllers and worker threads.
|
void |
stop()
Stops all controllers and worker threads.
|
public IoProcessor()
public void start()
throws java.io.IOException
start in interface IoProcessorMBeanjava.io.IOException - if failed to open a Selector.public void stop()
stop in interface IoProcessorMBeanpublic boolean isStarted()
true only if this I/O processor is started.isStarted in interface IoProcessorMBeanpublic int getThreadPoolSize()
getThreadPoolSize in interface IoProcessorMBeanpublic void setThreadPoolSize(int newSize)
setThreadPoolSize in interface IoProcessorMBeanpublic int getControllerThreadPriority()
getControllerThreadPriority in interface IoProcessorMBeanpublic void setControllerThreadPriority(int newPriority)
Thread.NORM_PRIORITY.setControllerThreadPriority in interface IoProcessorMBeanjava.lang.IllegalArgumentException - if the specified priority is not between
Thread.MIN_PRIORITYand Thread.MAX_PRIORITY.public int getThreadPriority()
getThreadPriority in interface IoProcessorMBeanpublic void setThreadPriority(int newPriority)
Thread.NORM_PRIORITY.setThreadPriority in interface IoProcessorMBeanjava.lang.IllegalArgumentException - if the specified priority is not between
Thread.MIN_PRIORITYand Thread.MAX_PRIORITY.public int getReadTries()
SelectionKey.OP_READ
event.getReadTries in interface IoProcessorMBeanpublic void setReadTries(int readTries)
SelectionKey.OP_READ
event. This property is adjustable in runtime.setReadTries in interface IoProcessorMBeanjava.lang.IllegalArgumentException - if the specified value is not greater than 0.public java.lang.String getThreadNamePrefix()
getThreadNamePrefix in interface IoProcessorMBeanpublic void setThreadNamePrefix(java.lang.String threadNamePrefix)
threadNamePrefix + '-' + threadId.setThreadNamePrefix in interface IoProcessorMBeanpublic ExceptionMonitor getExceptionMonitor()
ExceptionMonitor.public void setExceptionMonitor(ExceptionMonitor monitor)
ExceptionMonitor. Any uncaught exceptions will be
forwarded to the specified ExceptionMonitorjava.lang.NullPointerException - if monitor is null.Copyright © 2004-2012 Trustin Lee. All Rights Reserved.