Package org.apache.thrift.server
Class TThreadedSelectorServer.SelectorThread
java.lang.Object
java.lang.Thread
org.apache.thrift.server.AbstractNonblockingServer.AbstractSelectThread
org.apache.thrift.server.TThreadedSelectorServer.SelectorThread
- All Implemented Interfaces:
Runnable
- Enclosing class:
- TThreadedSelectorServer
protected class TThreadedSelectorServer.SelectorThread
extends AbstractNonblockingServer.AbstractSelectThread
The SelectorThread(s) will be doing all the selecting on accepted active connections.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class org.apache.thrift.server.AbstractNonblockingServer.AbstractSelectThread
selectInterestChanges, selector
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionSet up the SelectorThread with an unbounded queue for incoming accepts.SelectorThread
(int maxPendingAccepts) Set up the SelectorThread with an bounded queue for incoming accepts.SelectorThread
(BlockingQueue<TNonblockingTransport> acceptedQueue) Set up the SelectorThread with a specified queue for connections. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addAcceptedConnection
(TNonblockingTransport accepted) Hands off an accepted connection to be handled by this thread.protected AbstractNonblockingServer.FrameBuffer
createFrameBuffer
(TNonblockingTransport trans, SelectionKey selectionKey, AbstractNonblockingServer.AbstractSelectThread selectThread) void
run()
The work loop.Methods inherited from class org.apache.thrift.server.AbstractNonblockingServer.AbstractSelectThread
cleanupSelectionKey, handleRead, handleWrite, processInterestChanges, requestSelectInterestChange, wakeupSelector
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
SelectorThread
Set up the SelectorThread with an unbounded queue for incoming accepts.- Throws:
IOException
- if a selector cannot be created
-
SelectorThread
Set up the SelectorThread with an bounded queue for incoming accepts.- Throws:
IOException
- if a selector cannot be created
-
SelectorThread
Set up the SelectorThread with a specified queue for connections.- Parameters:
acceptedQueue
- The BlockingQueue implementation for holding incoming accepted connections.- Throws:
IOException
- if a selector cannot be created.
-
-
Method Details
-
addAcceptedConnection
Hands off an accepted connection to be handled by this thread. This method will block if the queue for new connections is at capacity.- Parameters:
accepted
- The connection that has been accepted.- Returns:
- true if the connection has been successfully added.
-
run
public void run()The work loop. Handles selecting (read/write IO), dispatching, and managing the selection preferences of all existing connections. -
createFrameBuffer
protected AbstractNonblockingServer.FrameBuffer createFrameBuffer(TNonblockingTransport trans, SelectionKey selectionKey, AbstractNonblockingServer.AbstractSelectThread selectThread) throws TTransportException - Throws:
TTransportException
-