use of org.apache.thrift.transport.TServerTransport in project metacat by Netflix.
the class AbstractThriftServer method start.
/**
* Server initialization.
*
* @throws Exception error
*/
public void start() throws Exception {
log.info("initializing thrift server {}", getServerName());
final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(threadPoolNameFormat).setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: " + t.getName(), e)).build();
final ExecutorService executorService = new ThreadPoolExecutor(Math.min(2, config.getThriftServerMaxWorkerThreads()), config.getThriftServerMaxWorkerThreads(), 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory);
final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000;
final TServerTransport serverTransport = new TServerSocket(portNumber, timeout);
startServing(executorService, serverTransport);
}
use of org.apache.thrift.transport.TServerTransport in project yyl_example by Relucent.
the class HelloServer method getPoolServer.
/** 线程池服务模型,使用标准的阻塞式IO,预先创建一组线程处理请求 */
public static TServer getPoolServer(int port, HelloService.Processor<HelloServiceHandler> processor) throws TTransportException {
TServerTransport transport = new TServerSocket(port);
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(transport).processor(processor));
return server;
}
use of org.apache.thrift.transport.TServerTransport in project commons by twitter.
the class PingPongServer method run.
@Override
public void run() {
PingPongHandler handler = new PingPongHandler();
PingPong.Processor processor = new PingPong.Processor(handler);
TServer server;
try {
TServerTransport transport = new TServerSocket(THRIFT_PORT.get());
server = new TSimpleServer(processor, transport);
} catch (TTransportException e) {
throw new RuntimeException(e);
}
LOG.info("Starting thrift server.");
server.serve();
}
use of org.apache.thrift.transport.TServerTransport in project yyl_example by Relucent.
the class HelloServer method getSimpleServer.
/** 简单的单线程服务模型,一般用于测试 */
public static TServer getSimpleServer(int port, HelloService.Processor<HelloServiceHandler> processor) throws TTransportException {
TServerTransport transport = new TServerSocket(port);
TServer server = new TSimpleServer(new TServer.Args(transport).processor(processor));
return server;
}
Aggregations