org.apache.thrift.server

## Class TNonblockingServer

- java.lang.Object
- - org.apache.thrift.server.TServer
  - - org.apache.thrift.server.TNonblockingServer

- Direct Known Subclasses:
    THsHaServer

      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

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `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

    Constructors
    Constructor and Description
    `TNonblockingServer(TNonblockingServer.AbstractNonblockingServerArgs args)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 connections.

    - ### 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

    - #### TNonblockingServer

          public TNonblockingServer(TNonblockingServer.AbstractNonblockingServerArgs args)

  - ### Method Detail

    - #### serve

          public void serve()

      Begin accepting connections and processing invocations.
      Specified by:
        `serve` in class `TServer`

    - #### startListening

          protected boolean startListening()

      Have the server transport start accepting connections.
      Returns:
        true if we started listening successfully, false if something went wrong.

    - #### stopListening

          protected void stopListening()

      Stop listening for connections.

    - #### startSelectorThread

          protected boolean startSelectorThread()

      Start the selector thread running to deal with clients.
      Returns:
        true if everything went ok, false if we couldn't start for some reason.

    - #### joinSelector

          protected void joinSelector()

      Block until the selector exits.

    - #### stop

          public void stop()

      Stop serving and shut everything down.
      Overrides:
        `stop` in class `TServer`

    - #### requestInvoke

          protected boolean requestInvoke(TNonblockingServer.FrameBuffer frameBuffer)

      Perform an invocation. This method could behave several different ways - invoke immediately inline, queue for separate execution, etc.

    - #### requestSelectInterestChange

          protected void requestSelectInterestChange(TNonblockingServer.FrameBuffer frameBuffer)

      A FrameBuffer wants to change its selection preferences, but might not be in the select thread.

    - #### isStopped

          public boolean isStopped()