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 hbase by apache.
the class ThriftServer method getTThreadPoolServer.
protected TServer getTThreadPoolServer(TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws Exception {
LOG.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
// Thrift's implementation uses '0' as a placeholder for 'use the default.'
int backlog = conf.getInt(BACKLOG_CONF_KEY, BACKLOG_CONF_DEAFULT);
int readTimeout = conf.getInt(THRIFT_SERVER_SOCKET_READ_TIMEOUT_KEY, THRIFT_SERVER_SOCKET_READ_TIMEOUT_DEFAULT);
TServerTransport serverTransport = new TServerSocket(new TServerSocket.ServerSocketTransportArgs().bindAddr(inetSocketAddress).backlog(backlog).clientTimeout(readTimeout));
TBoundedThreadPoolServer.Args serverArgs = new TBoundedThreadPoolServer.Args(serverTransport, conf);
serverArgs.processor(processor).transportFactory(transportFactory).protocolFactory(protocolFactory);
return new TBoundedThreadPoolServer(serverArgs, metrics);
}
use of org.apache.thrift.transport.TServerTransport in project jstorm by alibaba.
the class AMServer method simple.
public void simple(JstormAM.Processor processor) {
try {
TServerTransport serverTransport = new TServerSocket(port);
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
LOG.info("Starting the simple server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.thrift.transport.TServerTransport in project vcell by virtualcell.
the class VCellProxyServer method startSimpleVCellProxyServer.
private static void startSimpleVCellProxyServer(VCellProxy.Processor<VCellProxyHandler> processor) {
try {
InetSocketAddress inetSocketAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 9090);
TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
TServer vcellProxyServer = new TSimpleServer(new org.apache.thrift.server.TServer.Args(serverTransport).processor(processor));
System.out.println("Starting the VCell-VisIt Data Server thread...");
vcellProxyServer.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
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);
RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService);
final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000;
final TServerTransport serverTransport = new TServerSocket(portNumber, timeout);
startServing(executorService, serverTransport);
}
Aggregations