org.apache.thrift.server
Class THsHaServer

java.lang.Object
  extended by org.apache.thrift.server.TServer
      extended by org.apache.thrift.server.TNonblockingServer
          extended by org.apache.thrift.server.THsHaServer

public class THsHaServer
extends TNonblockingServer

An extension of the TNonblockingServer to a Half-Sync/Half-Async server. Like TNonblockingServer, it relies on the use of TFramedTransport.


Nested Class Summary
static class THsHaServer.Options
           
 
Nested classes/interfaces inherited from class org.apache.thrift.server.TNonblockingServer
TNonblockingServer.FrameBuffer, TNonblockingServer.SelectThread
 
Field Summary
protected  int MAX_WORKER_THREADS
           
protected  int MIN_WORKER_THREADS
           
protected  java.util.concurrent.TimeUnit STOP_TIMEOUT_UNIT
           
protected  int STOP_TIMEOUT_VAL
           
 
Fields inherited from class org.apache.thrift.server.TNonblockingServer
options_
 
Fields inherited from class org.apache.thrift.server.TServer
inputProtocolFactory_, inputTransportFactory_, outputProtocolFactory_, outputTransportFactory_, processorFactory_, serverTransport_
 
Constructor Summary
THsHaServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport)
          Create server with specified processor factory and server transport.
THsHaServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport, TFramedTransport.Factory inputTransportFactory, TFramedTransport.Factory outputTransportFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory)
          Create server with everything specified, except use default server options.
THsHaServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport, TFramedTransport.Factory inputTransportFactory, TFramedTransport.Factory outputTransportFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, THsHaServer.Options options)
          Create server with every option fully specified.
THsHaServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport, TFramedTransport.Factory transportFactory, TProtocolFactory protocolFactory)
          Create server with specified processor factory, server transport, in/out transport factory, in/out protocol factory, and default server options.
THsHaServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport, TFramedTransport.Factory transportFactory, TProtocolFactory protocolFactory, THsHaServer.Options options)
          Create server with specified processor factory, server transport, in/out transport factory, in/out protocol factory, and server options.
THsHaServer(TProcessorFactory processorFactory, TNonblockingServerTransport serverTransport, THsHaServer.Options options)
          Create server with specified processor factory, server transport, and server options.
THsHaServer(TProcessor processor, TNonblockingServerTransport serverTransport)
          Create server with given processor, and server transport.
THsHaServer(TProcessor processor, TNonblockingServerTransport serverTransport, TFramedTransport.Factory inputTransportFactory, TFramedTransport.Factory outputTransportFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory)
          Create server with everything specified, except use default server options.
THsHaServer(TProcessor processor, TNonblockingServerTransport serverTransport, TFramedTransport.Factory transportFactory, TProtocolFactory protocolFactory)
          Create server with specified processor, server transport, in/out transport factory, in/out protocol factory, and default server options.
THsHaServer(TProcessor processor, TNonblockingServerTransport serverTransport, THsHaServer.Options options)
          Create server with given processor, server transport, and server options using TBinaryProtocol for the protocol, and TFramedTransport.Factory on both input and output transports.
THsHaServer(TProcessor processor, TNonblockingServerTransport serverTransport, TProtocolFactory protocolFactory)
          Server with specified processor, server transport, and in/out protocol factory.
THsHaServer(TProcessor processor, TNonblockingServerTransport serverTransport, TProtocolFactory protocolFactory, THsHaServer.Options options)
          Server with specified processor, server transport, and in/out protocol factory.
 
Method Summary
protected  void gracefullyShutdownInvokerPool()
           
protected  void requestInvoke(TNonblockingServer.FrameBuffer frameBuffer)
          We override the standard invoke method here to queue the invocation for invoker service instead of immediately invoking.
 void serve()
          Begin accepting connections and processing invocations.
protected  boolean startInvokerPool()
           
 
Methods inherited from class org.apache.thrift.server.TNonblockingServer
joinSelector, requestSelectInterestChange, startListening, startSelectorThread, stop, stopListening
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_WORKER_THREADS

protected final int MIN_WORKER_THREADS

MAX_WORKER_THREADS

protected final int MAX_WORKER_THREADS

STOP_TIMEOUT_VAL

protected final int STOP_TIMEOUT_VAL

STOP_TIMEOUT_UNIT

protected final java.util.concurrent.TimeUnit STOP_TIMEOUT_UNIT
Constructor Detail

THsHaServer

public THsHaServer(TProcessor processor,
                   TNonblockingServerTransport serverTransport)
Create server with given processor, and server transport. Default server options, TBinaryProtocol for the protocol, and TFramedTransport.Factory on both input and output transports. A TProcessorFactory will be created that always returns the specified processor.


THsHaServer

public THsHaServer(TProcessor processor,
                   TNonblockingServerTransport serverTransport,
                   THsHaServer.Options options)
Create server with given processor, server transport, and server options using TBinaryProtocol for the protocol, and TFramedTransport.Factory on both input and output transports. A TProcessorFactory will be created that always returns the specified processor.


THsHaServer

public THsHaServer(TProcessorFactory processorFactory,
                   TNonblockingServerTransport serverTransport)
Create server with specified processor factory and server transport. Uses default options. TBinaryProtocol is assumed. TFramedTransport.Factory is used on both input and output transports.


THsHaServer

public THsHaServer(TProcessorFactory processorFactory,
                   TNonblockingServerTransport serverTransport,
                   THsHaServer.Options options)
Create server with specified processor factory, server transport, and server options. TBinaryProtocol is assumed. TFramedTransport.Factory is used on both input and output transports.


THsHaServer

public THsHaServer(TProcessor processor,
                   TNonblockingServerTransport serverTransport,
                   TProtocolFactory protocolFactory)
Server with specified processor, server transport, and in/out protocol factory. Defaults will be used for in/out transport factory and server options.


THsHaServer

public THsHaServer(TProcessor processor,
                   TNonblockingServerTransport serverTransport,
                   TProtocolFactory protocolFactory,
                   THsHaServer.Options options)
Server with specified processor, server transport, and in/out protocol factory. Defaults will be used for in/out transport factory and server options.


THsHaServer

public THsHaServer(TProcessor processor,
                   TNonblockingServerTransport serverTransport,
                   TFramedTransport.Factory transportFactory,
                   TProtocolFactory protocolFactory)
Create server with specified processor, server transport, in/out transport factory, in/out protocol factory, and default server options. A processor factory will be created that always returns the specified processor.


THsHaServer

public THsHaServer(TProcessorFactory processorFactory,
                   TNonblockingServerTransport serverTransport,
                   TFramedTransport.Factory transportFactory,
                   TProtocolFactory protocolFactory)
Create server with specified processor factory, server transport, in/out transport factory, in/out protocol factory, and default server options.


THsHaServer

public THsHaServer(TProcessorFactory processorFactory,
                   TNonblockingServerTransport serverTransport,
                   TFramedTransport.Factory transportFactory,
                   TProtocolFactory protocolFactory,
                   THsHaServer.Options options)
Create server with specified processor factory, server transport, in/out transport factory, in/out protocol factory, and server options.


THsHaServer

public THsHaServer(TProcessor processor,
                   TNonblockingServerTransport serverTransport,
                   TFramedTransport.Factory inputTransportFactory,
                   TFramedTransport.Factory outputTransportFactory,
                   TProtocolFactory inputProtocolFactory,
                   TProtocolFactory outputProtocolFactory)
Create server with everything specified, except use default server options.


THsHaServer

public THsHaServer(TProcessorFactory processorFactory,
                   TNonblockingServerTransport serverTransport,
                   TFramedTransport.Factory inputTransportFactory,
                   TFramedTransport.Factory outputTransportFactory,
                   TProtocolFactory inputProtocolFactory,
                   TProtocolFactory outputProtocolFactory)
Create server with everything specified, except use default server options.


THsHaServer

public THsHaServer(TProcessorFactory processorFactory,
                   TNonblockingServerTransport serverTransport,
                   TFramedTransport.Factory inputTransportFactory,
                   TFramedTransport.Factory outputTransportFactory,
                   TProtocolFactory inputProtocolFactory,
                   TProtocolFactory outputProtocolFactory,
                   THsHaServer.Options options)
Create server with every option fully specified.

Method Detail

serve

public void serve()
Description copied from class: TNonblockingServer
Begin accepting connections and processing invocations.

Overrides:
serve in class TNonblockingServer

startInvokerPool

protected boolean startInvokerPool()

gracefullyShutdownInvokerPool

protected void gracefullyShutdownInvokerPool()

requestInvoke

protected void requestInvoke(TNonblockingServer.FrameBuffer frameBuffer)
We override the standard invoke method here to queue the invocation for invoker service instead of immediately invoking. The thread pool takes care of the rest.

Overrides:
requestInvoke in class TNonblockingServer