Search in sources :

Example 11 with TNonblockingServerSocket

use of org.apache.thrift.transport.TNonblockingServerSocket 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 12 with TNonblockingServerSocket

use of org.apache.thrift.transport.TNonblockingServerSocket in project hbase by apache.

the class ThriftServer method getTThreadedSelectorServer.

private static TServer getTThreadedSelectorServer(TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, int workerThreads, int selectorThreads, int maxCallQueueSize, InetSocketAddress inetSocketAddress, ThriftMetrics metrics) throws TTransportException {
    TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
    log.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString());
    TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport);
    if (workerThreads > 0) {
        serverArgs.workerThreads(workerThreads);
    }
    if (selectorThreads > 0) {
        serverArgs.selectorThreads(selectorThreads);
    }
    ExecutorService executorService = createExecutor(workerThreads, maxCallQueueSize, metrics);
    serverArgs.executorService(executorService);
    serverArgs.processor(processor);
    serverArgs.transportFactory(transportFactory);
    serverArgs.protocolFactory(protocolFactory);
    return new TThreadedSelectorServer(serverArgs);
}
Also used : TNonblockingServerTransport(org.apache.thrift.transport.TNonblockingServerTransport) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) TThreadedSelectorServer(org.apache.thrift.server.TThreadedSelectorServer) ExecutorService(java.util.concurrent.ExecutorService)

Example 13 with TNonblockingServerSocket

use of org.apache.thrift.transport.TNonblockingServerSocket in project lucida by claritylab.

the class CalendarDaemon method main.

public static void main(String[] args) throws TTransportException, IOException, InterruptedException {
    TProcessor proc = new LucidaService.AsyncProcessor(new CAServiceHandler.AsyncCAServiceHandler());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(8084);
    TThreadedSelectorServer.Args arguments = new TThreadedSelectorServer.Args(transport).processor(proc).protocolFactory(new TBinaryProtocol.Factory()).transportFactory(new TFramedTransport.Factory());
    final TThreadedSelectorServer server = new TThreadedSelectorServer(arguments);
    System.out.println("CA at port 8084");
    server.serve();
}
Also used : TNonblockingServerTransport(org.apache.thrift.transport.TNonblockingServerTransport) TProcessor(org.apache.thrift.TProcessor) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) TThreadedSelectorServer(org.apache.thrift.server.TThreadedSelectorServer)

Example 14 with TNonblockingServerSocket

use of org.apache.thrift.transport.TNonblockingServerSocket 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 15 with TNonblockingServerSocket

use of org.apache.thrift.transport.TNonblockingServerSocket 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

TNonblockingServerSocket (org.apache.thrift.transport.TNonblockingServerSocket)19 THsHaServer (org.apache.thrift.server.THsHaServer)9 TNonblockingServerTransport (org.apache.thrift.transport.TNonblockingServerTransport)9 TThreadedSelectorServer (org.apache.thrift.server.TThreadedSelectorServer)8 TProcessor (org.apache.thrift.TProcessor)6 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)6 ExecutorService (java.util.concurrent.ExecutorService)4 TServer (org.apache.thrift.server.TServer)4 TFramedTransport (org.apache.thrift.transport.TFramedTransport)4 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)3 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3 TProtocolFactory (org.apache.thrift.protocol.TProtocolFactory)3 TNonblockingServer (org.apache.thrift.server.TNonblockingServer)3 TTransportFactory (org.apache.thrift.transport.TTransportFactory)3 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)2 Args (org.apache.thrift.server.TThreadedSelectorServer.Args)2 TServerSocket (org.apache.thrift.transport.TServerSocket)2 TTransportException (org.apache.thrift.transport.TTransportException)2 HelloImpl (org.tech.model.impl.HelloImpl)2 DistributedRPC (backtype.storm.generated.DistributedRPC)1