Java Code Examples for org.apache.thrift.server.TThreadedSelectorServer#Args
The following examples show how to use
org.apache.thrift.server.TThreadedSelectorServer#Args .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThriftServer.java From hbase with Apache License 2.0 | 6 votes |
protected TServer getTThreadedSelectorServer(TNonblockingServerTransport serverTransport, TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) { LOG.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString()); TThreadedSelectorServer.Args serverArgs = new HThreadedSelectorServerArgs(serverTransport, conf); int queueSize = conf.getInt(TBoundedThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY, TBoundedThreadPoolServer.DEFAULT_MAX_QUEUED_REQUESTS); CallQueue callQueue = new CallQueue(new LinkedBlockingQueue<>(queueSize), metrics); int workerThreads = conf.getInt(TBoundedThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY, serverArgs.getWorkerThreads()); int selectorThreads = conf.getInt(THRIFT_SELECTOR_NUM, serverArgs.getSelectorThreads()); serverArgs.selectorThreads(selectorThreads); ExecutorService executorService = createExecutor( callQueue, workerThreads, workerThreads); serverArgs.executorService(executorService).processor(processor) .transportFactory(transportFactory).protocolFactory(protocolFactory); return new TThreadedSelectorServer(serverArgs); }
Example 2
Source File: Server.java From rpc-benchmark with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws TTransportException { InetSocketAddress serverAddress = new InetSocketAddress("benchmark-server", 8080); TNonblockingServerTransport serverSocket = new TNonblockingServerSocket(serverAddress); TThreadedSelectorServer.Args serverParams = new TThreadedSelectorServer.Args(serverSocket); serverParams.protocolFactory(new TBinaryProtocol.Factory()); serverParams.processor(new UserService.Processor<Iface>(new UserServiceThriftServerImpl())); TServer server = new TThreadedSelectorServer(serverParams); server.serve(); }
Example 3
Source File: NonblockingThriftServerImpl.java From ikasoa with MIT License | 5 votes |
/** * 初始化Thrift服务 * * @param serverTransport * 服务传输类型 */ @Override protected void initServer(TServerTransport serverTransport) { ThriftServerConfiguration configuration = getServerConfiguration(); // 使用多线程半同步半异步方式 TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args((TNonblockingServerSocket) serverTransport) .transportFactory(configuration.getTransportFactory()) .protocolFactory(configuration.getProtocolFactory()); if (ObjectUtil.isNotNull(configuration.getExecutorService())) args.executorService(configuration.getExecutorService()); server = new TThreadedSelectorServer( configuration.getServerArgsAspect().tThreadedSelectorServerArgsAspect(args).processor(getProcessor())); if (ObjectUtil.isNotNull(configuration.getServerEventHandler())) server.setServerEventHandler(configuration.getServerEventHandler()); }
Example 4
Source File: ServerArgsAspect.java From ikasoa with MIT License | 4 votes |
public TThreadedSelectorServer.Args tThreadedSelectorServerArgsAspect(TThreadedSelectorServer.Args args) { return args; }