org.apache.thrift.server
Class TNonblockingServer

java.lang.Object
  extended by org.apache.thrift.server.TServer
      extended by org.apache.thrift.server.AbstractNonblockingServer
          extended by org.apache.thrift.server.TNonblockingServer
Direct Known Subclasses:
THsHaServer

public class TNonblockingServer
extends AbstractNonblockingServer

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
static class TNonblockingServer.Args
           
protected  class TNonblockingServer.SelectAcceptThread
          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_
 
Constructor Summary
TNonblockingServer(AbstractNonblockingServer.AbstractNonblockingServerArgs args)
           
 
Method Summary
 boolean isStopped()
           
protected  void joinSelector()
          Block until the selector thread exits.
protected  boolean requestInvoke(AbstractNonblockingServer.FrameBuffer frameBuffer)
          Perform an invocation.
protected  boolean startThreads()
          Start the selector thread to deal with accepts and client messages.
 void stop()
          Stop serving and shut everything down.
protected  void waitForShutdown()
          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, isServing, setServerEventHandler, setServing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TNonblockingServer

public TNonblockingServer(AbstractNonblockingServer.AbstractNonblockingServerArgs args)
Method Detail

startThreads

protected boolean startThreads()
Start the selector thread to deal with accepts and client messages.

Specified by:
startThreads in class AbstractNonblockingServer
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 class AbstractNonblockingServer

joinSelector

protected void joinSelector()
Block until the selector thread exits.


stop

public void stop()
Stop serving and shut everything down.

Overrides:
stop in class TServer

requestInvoke

protected boolean requestInvoke(AbstractNonblockingServer.FrameBuffer frameBuffer)
Perform an invocation. This method could behave several different ways - invoke immediately inline, queue for separate execution, etc.

Specified by:
requestInvoke in class AbstractNonblockingServer
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()