public class TThreadedSelectorServer extends AbstractNonblockingServer
Modifier and Type | Class and Description |
---|---|
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.
|
AbstractNonblockingServer.AbstractNonblockingServerArgs<T extends AbstractNonblockingServer.AbstractNonblockingServerArgs<T>>, AbstractNonblockingServer.AbstractSelectThread, AbstractNonblockingServer.AsyncFrameBuffer, AbstractNonblockingServer.FrameBuffer
TServer.AbstractServerArgs<T extends TServer.AbstractServerArgs<T>>
eventHandler_, inputProtocolFactory_, inputTransportFactory_, outputProtocolFactory_, outputTransportFactory_, processorFactory_, serverTransport_
Constructor and Description |
---|
TThreadedSelectorServer(TThreadedSelectorServer.Args args)
Create the server with the specified Args configuration
|
Modifier and Type | Method and Description |
---|---|
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.
|
serve, startListening, stopListening
getEventHandler, isServing, setServerEventHandler, setServing
public TThreadedSelectorServer(TThreadedSelectorServer.Args args)
protected boolean startThreads()
startThreads
in class AbstractNonblockingServer
protected void waitForShutdown()
waitForShutdown
in class AbstractNonblockingServer
protected void joinThreads() throws java.lang.InterruptedException
java.lang.InterruptedException
protected void gracefullyShutdownInvokerPool()
protected boolean requestInvoke(AbstractNonblockingServer.FrameBuffer frameBuffer)
requestInvoke
in class AbstractNonblockingServer
protected 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)