Package org.apache.thrift.server
Class AbstractNonblockingServer.AbstractSelectThread
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.thrift.server.AbstractNonblockingServer.AbstractSelectThread
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
TNonblockingServer.SelectAcceptThread
,TThreadedSelectorServer.SelectorThread
- Enclosing class:
- AbstractNonblockingServer
protected abstract class AbstractNonblockingServer.AbstractSelectThread extends java.lang.Thread
An abstract thread that handles selecting on a set of transports andFrameBuffers
associated with selected keys corresponding to requests.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<AbstractNonblockingServer.FrameBuffer>
selectInterestChanges
protected java.nio.channels.Selector
selector
-
Constructor Summary
Constructors Constructor Description AbstractSelectThread()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cleanupSelectionKey(java.nio.channels.SelectionKey key)
Do connection-close cleanup on a given SelectionKey.protected void
handleRead(java.nio.channels.SelectionKey key)
Do the work required to read from a readable client.protected void
handleWrite(java.nio.channels.SelectionKey key)
Let a writable client get written, if there's data to be written.protected void
processInterestChanges()
Check to see if there are any FrameBuffers that have switched their interest type from read to write or vice versa.void
requestSelectInterestChange(AbstractNonblockingServer.FrameBuffer frameBuffer)
Add FrameBuffer to the list of select interest changes and wake up the selector if it's blocked.void
wakeupSelector()
If the selector is blocked, wake it up.-
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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
selector
protected java.nio.channels.Selector selector
-
selectInterestChanges
protected final java.util.Set<AbstractNonblockingServer.FrameBuffer> selectInterestChanges
-
-
Method Detail
-
wakeupSelector
public void wakeupSelector()
If the selector is blocked, wake it up.
-
requestSelectInterestChange
public void requestSelectInterestChange(AbstractNonblockingServer.FrameBuffer frameBuffer)
Add FrameBuffer to the list of select interest changes and wake up the selector if it's blocked. When the select() call exits, it'll give the FrameBuffer a chance to change its interests.
-
processInterestChanges
protected void processInterestChanges()
Check to see if there are any FrameBuffers that have switched their interest type from read to write or vice versa.
-
handleRead
protected void handleRead(java.nio.channels.SelectionKey key)
Do the work required to read from a readable client. If the frame is fully read, then invoke the method call.
-
handleWrite
protected void handleWrite(java.nio.channels.SelectionKey key)
Let a writable client get written, if there's data to be written.
-
cleanupSelectionKey
protected void cleanupSelectionKey(java.nio.channels.SelectionKey key)
Do connection-close cleanup on a given SelectionKey.
-
-