net.gleamynode.netty2
Class IoProcessor

java.lang.Object
  extended bynet.gleamynode.netty2.IoProcessor
All Implemented Interfaces:
IoProcessorMBean

public class IoProcessor
extends Object
implements IoProcessorMBean

Performs I/O operations, interprets them into session events, and passes them to EventDispatcher.

IoProcessorconsists of two controller threads and other worker threads:

IoProcessorhas properties such as:

To activate, call start()method.

Version:
$Rev: 4 $, $Date: 2005-04-18 12:04:09 +0900 $
Author:
Trustin Lee (http://gleamynode.net/dev/)

Constructor Summary
IoProcessor()
          Constructs a new instance with default properties.
 
Method Summary
 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.
 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(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IoProcessor

public IoProcessor()
Constructs a new instance with default properties.

Method Detail

start

public void start()
           throws IOException
Starts all controllers and worker threads. Invoking this method has no effect when this I/O processor is already started.

Specified by:
start in interface IoProcessorMBean
Throws:
IOException - if failed to open a Selector.

stop

public void stop()
Stops all controllers and worker threads. Invoking this method has no effect when this I/O processor is already stopped.

Specified by:
stop in interface IoProcessorMBean

isStarted

public boolean isStarted()
Returns true only if this I/O processor is started.

Specified by:
isStarted in interface IoProcessorMBean

getThreadPoolSize

public int getThreadPoolSize()
Returns the number of worker threads.

Specified by:
getThreadPoolSize in interface IoProcessorMBean

setThreadPoolSize

public void setThreadPoolSize(int newSize)
Sets the number of worker threads. The number of worker threads is also adjustable in runtime.

Specified by:
setThreadPoolSize in interface IoProcessorMBean

getControllerThreadPriority

public int getControllerThreadPriority()
Returns the priority of controller threads.

Specified by:
getControllerThreadPriority in interface IoProcessorMBean

setControllerThreadPriority

public void setControllerThreadPriority(int newPriority)
Sets the priority of controller threads. The default value is Thread.NORM_PRIORITY.

Specified by:
setControllerThreadPriority in interface IoProcessorMBean
Throws:
IllegalArgumentException - if the specified priority is not between Thread.MIN_PRIORITYand Thread.MAX_PRIORITY.

getThreadPriority

public int getThreadPriority()
Returns the priority of worker threads.

Specified by:
getThreadPriority in interface IoProcessorMBean

setThreadPriority

public void setThreadPriority(int newPriority)
Sets the priority of worker threads. The default value is Thread.NORM_PRIORITY.

Specified by:
setThreadPriority in interface IoProcessorMBean
Throws:
IllegalArgumentException - if the specified priority is not between Thread.MIN_PRIORITYand Thread.MAX_PRIORITY.

getReadTries

public int getReadTries()
Deprecated. Netty2 now automatically retries a read operation until it returns 0.

Returns the maximum number of read tries per SelectionKey.OP_READ event.

Specified by:
getReadTries in interface IoProcessorMBean

setReadTries

public void setReadTries(int readTries)
Deprecated. Netty2 now automatically retries a read operation until it returns 0.

Sets the maximum number of read tries per SelectionKey.OP_READ event. This property is adjustable in runtime.

Specified by:
setReadTries in interface IoProcessorMBean
Throws:
IllegalArgumentException - if the specified value is not greater than 0.

getThreadNamePrefix

public String getThreadNamePrefix()
Returns the prefix of the I/O thread name.

Specified by:
getThreadNamePrefix in interface IoProcessorMBean

setThreadNamePrefix

public void setThreadNamePrefix(String threadNamePrefix)
Sets the prefix of the I/O thread name. The actual thread name will be threadNamePrefix + '-' + threadId.

Specified by:
setThreadNamePrefix in interface IoProcessorMBean

getExceptionMonitor

public ExceptionMonitor getExceptionMonitor()
Returns the ExceptionMonitor.


setExceptionMonitor

public void setExceptionMonitor(ExceptionMonitor monitor)
Sets the ExceptionMonitor. Any uncaught exceptions will be forwarded to the specified ExceptionMonitor

Throws:
NullPointerException - if monitor is null.


Copyright © 2004-2007 Trustin Lee. All Rights Reserved.