Search in sources :

Example 6 with TThreadedSelectorServer

use of org.apache.thrift.server.TThreadedSelectorServer in project summer by foxsugar.

the class GameRpcServer method StartServer.

public static TServer StartServer(int port, GameRPCNew.AsyncIface iface) throws TTransportException {
    TServer server = null;
    try {
        TProcessor tprocessor = new GameRPCNew.AsyncProcessor<>(iface);
        TNonblockingServerSocket serverTransport = null;
        serverTransport = new TNonblockingServerSocket(port);
        TThreadedSelectorServer.Args tArgs = new TThreadedSelectorServer.Args(serverTransport);
        tArgs.maxReadBufferBytes = 1024 * 1024L;
        tArgs.processor(tprocessor);
        tArgs.transportFactory(new TFramedTransport.Factory());
        tArgs.protocolFactory(new TBinaryProtocol.Factory());
        server = new TThreadedSelectorServer(tArgs);
        server.serve();
    } catch (Exception e) {
        System.out.println("-------------------------------------");
        e.printStackTrace();
    }
    return server;
}
Also used : TProcessor(org.apache.thrift.TProcessor) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TServer(org.apache.thrift.server.TServer) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) TThreadedSelectorServer(org.apache.thrift.server.TThreadedSelectorServer) TTransportException(org.apache.thrift.transport.TTransportException)

Example 7 with TThreadedSelectorServer

use of org.apache.thrift.server.TThreadedSelectorServer in project summer by foxsugar.

the class GameRpcServer method StartServer.

public static TServer StartServer(int port, GameRPC.AsyncIface iface) throws TTransportException {
    TServer server = null;
    try {
        TProcessor tprocessor = new GameRPC.AsyncProcessor<>(iface);
        TNonblockingServerSocket serverTransport = null;
        serverTransport = new TNonblockingServerSocket(port);
        TThreadedSelectorServer.Args tArgs = new TThreadedSelectorServer.Args(serverTransport);
        tArgs.maxReadBufferBytes = 1024 * 1024L;
        tArgs.processor(tprocessor);
        tArgs.transportFactory(new TFramedTransport.Factory());
        tArgs.protocolFactory(new TBinaryProtocol.Factory());
        server = new TThreadedSelectorServer(tArgs);
        server.serve();
    } catch (Exception e) {
        System.out.println("-------------------------------------");
        e.printStackTrace();
    }
    return server;
}
Also used : TProcessor(org.apache.thrift.TProcessor) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TServer(org.apache.thrift.server.TServer) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) TThreadedSelectorServer(org.apache.thrift.server.TThreadedSelectorServer) TTransportException(org.apache.thrift.transport.TTransportException)

Example 8 with TThreadedSelectorServer

use of org.apache.thrift.server.TThreadedSelectorServer 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 9 with TThreadedSelectorServer

use of org.apache.thrift.server.TThreadedSelectorServer 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 10 with TThreadedSelectorServer

use of org.apache.thrift.server.TThreadedSelectorServer in project lucida by claritylab.

the class QADaemon method main.

/** 
	 * Entry point for question-answer.
	 * @param args the argument list. Provide port numbers
	 * for both sirius and qa.
	 */
public static void main(String[] args) throws TTransportException, IOException, InterruptedException {
    TProcessor proc = new LucidaService.AsyncProcessor(new QAServiceHandler.AsyncQAServiceHandler());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(8083);
    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("QA at port 8083");
    server.serve();
}
Also used : AsyncQAServiceHandler(lucida.handler.QAServiceHandler.AsyncQAServiceHandler) 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) AsyncQAServiceHandler(lucida.handler.QAServiceHandler.AsyncQAServiceHandler)

Aggregations

TThreadedSelectorServer (org.apache.thrift.server.TThreadedSelectorServer)13 TNonblockingServerSocket (org.apache.thrift.transport.TNonblockingServerSocket)12 TProcessor (org.apache.thrift.TProcessor)10 TFramedTransport (org.apache.thrift.transport.TFramedTransport)8 TNonblockingServerTransport (org.apache.thrift.transport.TNonblockingServerTransport)7 TServer (org.apache.thrift.server.TServer)6 ExecutorService (java.util.concurrent.ExecutorService)4 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)4 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)3 TProtocolFactory (org.apache.thrift.protocol.TProtocolFactory)3 TTransportException (org.apache.thrift.transport.TTransportException)3 TTransportFactory (org.apache.thrift.transport.TTransportFactory)3 HelloImpl (org.tech.model.impl.HelloImpl)3 InetSocketAddress (java.net.InetSocketAddress)2 Args (org.apache.thrift.server.TThreadedSelectorServer.Args)2 ThriftException (com.facebook.buck.slb.ThriftException)1 Constructor (java.lang.reflect.Constructor)1 InetAddress (java.net.InetAddress)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1