Class TNonblockingServer

  extended by org.apache.thrift.server.TServer
      extended by org.apache.thrift.server.TNonblockingServer
Direct Known Subclasses:

public class TNonblockingServer
extends TServer

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.AbstractNonblockingServerArgs<T extends TNonblockingServer.AbstractNonblockingServerArgs<T>>
static class TNonblockingServer.Args
protected  class TNonblockingServer.FrameBuffer
          Class that implements a sort of state machine around the interaction with a client and an invoker.
protected  class TNonblockingServer.SelectThread
          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.TServer
TServer.AbstractServerArgs<T extends TServer.AbstractServerArgs<T>>
Field Summary
Fields inherited from class org.apache.thrift.server.TServer
inputProtocolFactory_, inputTransportFactory_, outputProtocolFactory_, outputTransportFactory_, processorFactory_, serverTransport_
Constructor Summary
TNonblockingServer(TNonblockingServer.AbstractNonblockingServerArgs args)
Method Summary
 boolean isStopped()
protected  void joinSelector()
          Block until the selector exits.
protected  boolean requestInvoke(TNonblockingServer.FrameBuffer frameBuffer)
          Perform an invocation.
protected  void requestSelectInterestChange(TNonblockingServer.FrameBuffer frameBuffer)
          A FrameBuffer wants to change its selection preferences, but might not be in the select thread.
 void serve()
          Begin accepting connections and processing invocations.
protected  boolean startListening()
          Have the server transport start accepting connections.
protected  boolean startSelectorThread()
          Start the selector thread running to deal with clients.
 void stop()
          Stop serving and shut everything down.
protected  void stopListening()
          Stop listening for conections.
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 TNonblockingServer(TNonblockingServer.AbstractNonblockingServerArgs args)
Method Detail


public void serve()
Begin accepting connections and processing invocations.

Specified by:
serve in class TServer


protected boolean startListening()
Have the server transport start accepting connections.

true if we started listening successfully, false if something went wrong.


protected void stopListening()
Stop listening for conections.


protected boolean startSelectorThread()
Start the selector thread running to deal with clients.

true if everything went ok, false if we couldn't start for some reason.


protected void joinSelector()
Block until the selector exits.


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

stop in class TServer


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


protected void requestSelectInterestChange(TNonblockingServer.FrameBuffer frameBuffer)
A FrameBuffer wants to change its selection preferences, but might not be in the select thread.


public boolean isStopped()