org.apache.cassandra.net
Class SelectorManager

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.cassandra.net.SelectorManager
All Implemented Interfaces:
java.lang.Runnable

public class SelectorManager
extends java.lang.Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.nio.channels.Selector selector
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
protected  void doProcess()
           
static SelectorManager getSelectorManager()
          Returns the SelectorManager applications should use.
static SelectorManager getUdpSelectorManager()
           
 java.nio.channels.SelectionKey register(java.nio.channels.SelectableChannel channel, SelectionKeyHandler handler, int ops)
          Registers a new channel with the selector, and attaches the given SelectionKeyHandler as the handler for the newly created key.
 void run()
          This method starts the socket manager listening for events.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

selector

protected java.nio.channels.Selector selector
Method Detail

register

public java.nio.channels.SelectionKey register(java.nio.channels.SelectableChannel channel,
                                               SelectionKeyHandler handler,
                                               int ops)
                                        throws java.io.IOException
Registers a new channel with the selector, and attaches the given SelectionKeyHandler as the handler for the newly created key. Operations which the hanlder is interested in will be called as available.

Parameters:
channel - The channel to regster with the selector
handler - The handler to use for the callbacks
ops - The initial interest operations
Returns:
The SelectionKey which uniquely identifies this channel
Throws:
java.io.IOException - if the channel is closed

run

public void run()
This method starts the socket manager listening for events. It is designed to be started when this thread's start() method is invoked.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

doProcess

protected void doProcess()
                  throws java.io.IOException
Throws:
java.io.IOException

getSelectorManager

public static SelectorManager getSelectorManager()
Returns the SelectorManager applications should use.

Returns:
The SelectorManager which applications should use

getUdpSelectorManager

public static SelectorManager getUdpSelectorManager()


Copyright © 2009 The Apache Software Foundation