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
Nested ClassesModifier and TypeClassDescriptionstatic classprotected classThe 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.FrameBufferNested 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
LOGGERFields inherited from class org.apache.thrift.server.TServer
eventHandler_, inputProtocolFactory_, inputTransportFactory_, outputProtocolFactory_, outputTransportFactory_, processorFactory_, serverTransport_, stopped_ -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected voidBlock until the selector thread exits.protected booleanrequestInvoke(AbstractNonblockingServer.FrameBuffer frameBuffer) Perform an invocation.protected booleanStart the selector thread to deal with accepts and client messages.voidstop()Stop serving and shut everything down.protected voidA 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, stopListeningMethods 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:
startThreadsin classAbstractNonblockingServer- Returns:
- true if everything went ok, false if we couldn't start for some reason.
-
waitForShutdown
protected void waitForShutdown()Description copied from class:AbstractNonblockingServerA method that will block until when threads handling the serving have been shut down.- Specified by:
waitForShutdownin 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:
requestInvokein 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()
-