Package org.apache.thrift.server
Class TNonblockingServer
java.lang.Object
org.apache.thrift.server.TServer
org.apache.thrift.server.AbstractNonblockingServer
org.apache.thrift.server.TNonblockingServer
- Direct Known Subclasses:
THsHaServer
A nonblocking TServer implementation. This allows for fairness amongst all connected clients in
terms of invocations.
This server is inherently single-threaded. If you want a limited thread pool coupled with invocation-fairness, see THsHaServer.
To use this server, you MUST use a TFramedTransport at the outermost transport, otherwise this server will be unable to determine when a whole method call has been read off the wire. Clients must also use TFramedTransport.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
protected class
The thread that will be doing all the selecting, managing new connections and those that still need to be read.Nested classes/interfaces inherited from class org.apache.thrift.server.AbstractNonblockingServer
AbstractNonblockingServer.AbstractNonblockingServerArgs<T extends AbstractNonblockingServer.AbstractNonblockingServerArgs<T>>, AbstractNonblockingServer.AbstractSelectThread, AbstractNonblockingServer.AsyncFrameBuffer, 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.AbstractNonblockingServer
LOGGER
Fields inherited from class org.apache.thrift.server.TServer
eventHandler_, inputProtocolFactory_, inputTransportFactory_, outputProtocolFactory_, outputTransportFactory_, processorFactory_, serverTransport_, stopped_
-
Constructor Summary
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected void
Block until the selector thread exits.protected boolean
requestInvoke
(AbstractNonblockingServer.FrameBuffer frameBuffer) Perform an invocation.protected boolean
Start the selector thread to deal with accepts and client messages.void
stop()
Stop serving and shut everything down.protected void
A method that will block until when threads handling the serving have been shut down.Methods inherited from class org.apache.thrift.server.AbstractNonblockingServer
serve, startListening, stopListening
Methods inherited from class org.apache.thrift.server.TServer
getEventHandler, getShouldStop, isServing, setServerEventHandler, setServing, setShouldStop
-
Constructor Details
-
TNonblockingServer
-
-
Method Details
-
startThreads
protected boolean startThreads()Start the selector thread to deal with accepts and client messages.- Specified by:
startThreads
in classAbstractNonblockingServer
- Returns:
- true if everything went ok, false if we couldn't start for some reason.
-
waitForShutdown
protected void waitForShutdown()Description copied from class:AbstractNonblockingServer
A method that will block until when threads handling the serving have been shut down.- Specified by:
waitForShutdown
in classAbstractNonblockingServer
-
joinSelector
protected void joinSelector()Block until the selector thread exits. -
stop
public void stop()Stop serving and shut everything down. -
requestInvoke
Perform an invocation. This method could behave several different ways - invoke immediately inline, queue for separate execution, etc.- Specified by:
requestInvoke
in classAbstractNonblockingServer
- Returns:
- true if invocation was successfully requested, which is not a guarantee that invocation has completed. False if the request failed.
-
isStopped
public boolean isStopped()
-