Search in sources :

Example 6 with THsHaServer

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;
}
Also used : THsHaServer(org.apache.thrift.server.THsHaServer) TServer(org.apache.thrift.server.TServer) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket)

Example 7 with THsHaServer

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();
}
Also used : THsHaServer(org.apache.thrift.server.THsHaServer) HonuCollector(org.honu.thrift.HonuCollector) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket)

Example 8 with THsHaServer

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);
}
Also used : THsHaServer(org.apache.thrift.server.THsHaServer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 9 with THsHaServer

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;
}
Also used : THsHaServer(org.apache.thrift.server.THsHaServer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) DistributedRPCInvocations(backtype.storm.generated.DistributedRPCInvocations)

Aggregations

THsHaServer (org.apache.thrift.server.THsHaServer)9 TNonblockingServerSocket (org.apache.thrift.transport.TNonblockingServerSocket)9 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)6 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)3 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3 ExecutorService (java.util.concurrent.ExecutorService)2 TNonblockingServerTransport (org.apache.thrift.transport.TNonblockingServerTransport)2 DistributedRPC (backtype.storm.generated.DistributedRPC)1 DistributedRPCInvocations (backtype.storm.generated.DistributedRPCInvocations)1 Nimbus (backtype.storm.generated.Nimbus)1 Iface (backtype.storm.generated.Nimbus.Iface)1 INimbus (backtype.storm.scheduler.INimbus)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 Callback (javax.security.auth.callback.Callback)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1