|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.thrift.server.TServer
org.apache.thrift.server.AbstractNonblockingServer
org.apache.thrift.server.TThreadedSelectorServer
public class TThreadedSelectorServer
A Half-Sync/Half-Async server with a separate pool of threads to handle non-blocking I/O. Accepts are handled on a single thread, and a configurable number of nonblocking selector threads manage reading and writing of client connections. A synchronous worker thread pool handles processing of requests. Performs better than TNonblockingServer/THsHaServer in multi-core environments when the the bottleneck is CPU on the single selector thread handling I/O. In addition, because the accept handling is decoupled from reads/writes and invocation, the server has better ability to handle back- pressure from new connections (e.g. stop accepting when busy). Like TNonblockingServer, it relies on the use of TFramedTransport.
| Nested Class Summary | |
|---|---|
protected class |
TThreadedSelectorServer.AcceptThread
The thread that selects on the server transport (listen socket) and accepts new connections to hand off to the IO selector threads |
static class |
TThreadedSelectorServer.Args
|
protected class |
TThreadedSelectorServer.SelectorThread
The SelectorThread(s) will be doing all the selecting on accepted active connections. |
protected class |
TThreadedSelectorServer.SelectorThreadLoadBalancer
A round robin load balancer for choosing selector threads for new connections. |
| Nested classes/interfaces inherited from class org.apache.thrift.server.AbstractNonblockingServer |
|---|
AbstractNonblockingServer.AbstractNonblockingServerArgs<T extends AbstractNonblockingServer.AbstractNonblockingServerArgs<T>>, AbstractNonblockingServer.AbstractSelectThread, AbstractNonblockingServer.FrameBuffer |
| Nested classes/interfaces inherited from class org.apache.thrift.server.TServer |
|---|
TServer.AbstractServerArgs<T extends TServer.AbstractServerArgs<T>> |
| Field Summary |
|---|
| Fields inherited from class org.apache.thrift.server.TServer |
|---|
eventHandler_, inputProtocolFactory_, inputTransportFactory_, outputProtocolFactory_, outputTransportFactory_, processorFactory_, serverTransport_ |
| Constructor Summary | |
|---|---|
TThreadedSelectorServer(TThreadedSelectorServer.Args args)
Create the server with the specified Args configuration |
|
| Method Summary | |
|---|---|
protected static java.util.concurrent.ExecutorService |
createDefaultExecutor(TThreadedSelectorServer.Args options)
Helper to create the invoker if one is not specified |
protected TThreadedSelectorServer.SelectorThreadLoadBalancer |
createSelectorThreadLoadBalancer(java.util.Collection<? extends TThreadedSelectorServer.SelectorThread> threads)
Creates a SelectorThreadLoadBalancer to be used by the accept thread for assigning newly accepted connections across the threads. |
protected java.lang.Runnable |
getRunnable(AbstractNonblockingServer.FrameBuffer frameBuffer)
|
protected void |
gracefullyShutdownInvokerPool()
|
protected void |
joinThreads()
|
protected boolean |
requestInvoke(AbstractNonblockingServer.FrameBuffer frameBuffer)
We override the standard invoke method here to queue the invocation for invoker service instead of immediately invoking. |
protected boolean |
startThreads()
Start the accept and selector threads running to deal with clients. |
void |
stop()
Stop serving and shut everything down. |
protected void |
waitForShutdown()
Joins the accept and selector threads and shuts down the executor service. |
| Methods inherited from class org.apache.thrift.server.AbstractNonblockingServer |
|---|
getEventHandler, serve, setServerEventHandler, startListening, stopListening |
| Methods inherited from class org.apache.thrift.server.TServer |
|---|
isServing, setServing |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TThreadedSelectorServer(TThreadedSelectorServer.Args args)
| Method Detail |
|---|
protected boolean startThreads()
startThreads in class AbstractNonblockingServerprotected void waitForShutdown()
waitForShutdown in class AbstractNonblockingServer
protected void joinThreads()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void stop()
stop in class TServerprotected void gracefullyShutdownInvokerPool()
protected boolean requestInvoke(AbstractNonblockingServer.FrameBuffer frameBuffer)
requestInvoke in class AbstractNonblockingServerprotected java.lang.Runnable getRunnable(AbstractNonblockingServer.FrameBuffer frameBuffer)
protected static java.util.concurrent.ExecutorService createDefaultExecutor(TThreadedSelectorServer.Args options)
protected TThreadedSelectorServer.SelectorThreadLoadBalancer createSelectorThreadLoadBalancer(java.util.Collection<? extends TThreadedSelectorServer.SelectorThread> threads)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||