use of org.apache.thrift.server.THsHaServer in project yyl_example by Relucent.
the class HelloServer method getHsHaServer.
/** 半同步半异步的服务端模型,需要指定为: TFramedTransport 数据传输的方式 */
public static TServer getHsHaServer(int port, HelloService.Processor<HelloServiceHandler> processor) throws TTransportException {
TNonblockingServerSocket transport = new TNonblockingServerSocket(port);
THsHaServer.Args args = new THsHaServer.Args(transport).processor(processor);
TServer server = new THsHaServer(args);
return server;
}
use of org.apache.thrift.server.THsHaServer in project Honu by jboulon.
the class ThriftTHsHaCollector method start.
public void start(int port) throws Exception {
transport = new TNonblockingServerSocket(port);
processor = new HonuCollector.Processor(new ThriftCollectorLockFreeImpl());
THsHaServer.Options serverOpt = new THsHaServer.Options();
serverOpt.maxWorkerThreads = 5;
serverOpt.minWorkerThreads = 5;
server = new THsHaServer(processor, transport, serverOpt);
System.out.println("Server started on port:" + port);
server.serve();
}
use of org.apache.thrift.server.THsHaServer in project jstorm by alibaba.
the class SimpleTransportPlugin method getServer.
@Override
public TServer getServer(TProcessor processor) throws IOException, TTransportException {
int port = type.getPort(storm_conf);
TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port);
int numWorkerThreads = type.getNumThreads(storm_conf);
int maxBufferSize = type.getMaxBufferSize(storm_conf);
Integer queueSize = type.getQueueSize(storm_conf);
THsHaServer.Args server_args = new THsHaServer.Args(serverTransport).processor(new SimpleWrapProcessor(processor)).workerThreads(numWorkerThreads).protocolFactory(new TBinaryProtocol.Factory(false, true, maxBufferSize, -1));
if (queueSize != null) {
server_args.executorService(new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(queueSize)));
}
// construct THsHaServer
return new THsHaServer(server_args);
}
use of org.apache.thrift.server.THsHaServer in project jstorm by alibaba.
the class Drpc method initInvokeServer.
private THsHaServer initInvokeServer(Map conf, final Drpc service) throws Exception {
int port = JStormUtils.parseInt(conf.get(Config.DRPC_INVOCATIONS_PORT));
LOG.info("Begin to init Invoke Server " + port);
TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
THsHaServer.Args targsInvoke = new THsHaServer.Args(socket);
targsInvoke.workerThreads(64);
targsInvoke.protocolFactory(new TBinaryProtocol.Factory());
targsInvoke.processor(new DistributedRPCInvocations.Processor<DistributedRPCInvocations.Iface>(service));
THsHaServer invokeServer = new THsHaServer(targsInvoke);
LOG.info("Successfully init Invoke Server " + port);
return invokeServer;
}
Aggregations