Search in sources :

Example 41 with TServerSocket

use of org.apache.thrift.transport.TServerSocket in project tutorials by eugenp.

the class CrossPlatformServiceServer method start.

public void start() throws TTransportException {
    TServerTransport serverTransport = new TServerSocket(9090);
    server = new TSimpleServer(new TServer.Args(serverTransport).processor(new CrossPlatformService.Processor<>(new CrossPlatformServiceImpl())));
    System.out.print("Starting the server... ");
    server.serve();
    System.out.println("done.");
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) TServer(org.apache.thrift.server.TServer) CrossPlatformService(com.baeldung.thrift.impl.CrossPlatformService) TSimpleServer(org.apache.thrift.server.TSimpleServer) TServerTransport(org.apache.thrift.transport.TServerTransport)

Example 42 with TServerSocket

use of org.apache.thrift.transport.TServerSocket in project jstorm by alibaba.

the class SaslTransportPlugin method getServer.

@Override
public TServer getServer(TProcessor processor) throws IOException, TTransportException {
    int port = type.getPort(storm_conf);
    TTransportFactory serverTransportFactory = getServerTransportFactory();
    TServerSocket serverTransport = new TServerSocket(port);
    int numWorkerThreads = type.getNumThreads(storm_conf);
    Integer queueSize = type.getQueueSize(storm_conf);
    TThreadPoolServer.Args server_args = new TThreadPoolServer.Args(serverTransport).processor(new TUGIWrapProcessor(processor)).minWorkerThreads(numWorkerThreads).maxWorkerThreads(numWorkerThreads).protocolFactory(new TBinaryProtocol.Factory(false, true));
    if (serverTransportFactory != null) {
        server_args.transportFactory(serverTransportFactory);
    }
    BlockingQueue workQueue = new SynchronousQueue();
    if (queueSize != null) {
        workQueue = new ArrayBlockingQueue(queueSize);
    }
    ThreadPoolExecutor executorService = new ExtendedThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, workQueue);
    server_args.executorService(executorService);
    return new TThreadPoolServer(server_args);
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) TTransportFactory(org.apache.thrift.transport.TTransportFactory) ExtendedThreadPoolExecutor(backtype.storm.utils.ExtendedThreadPoolExecutor) TServerSocket(org.apache.thrift.transport.TServerSocket) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) SynchronousQueue(java.util.concurrent.SynchronousQueue) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ExtendedThreadPoolExecutor(backtype.storm.utils.ExtendedThreadPoolExecutor) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer)

Example 43 with TServerSocket

use of org.apache.thrift.transport.TServerSocket in project commons by twitter.

the class PingPongServer method run.

@Override
public void run() {
    PingPongHandler handler = new PingPongHandler();
    PingPong.Processor processor = new PingPong.Processor(handler);
    TServer server;
    try {
        TServerTransport transport = new TServerSocket(THRIFT_PORT.get());
        server = new TSimpleServer(processor, transport);
    } catch (TTransportException e) {
        throw new RuntimeException(e);
    }
    LOG.info("Starting thrift server.");
    server.serve();
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) TServer(org.apache.thrift.server.TServer) PingPong(com.twitter.common.examples.pingpong.PingPong) TTransportException(org.apache.thrift.transport.TTransportException) TSimpleServer(org.apache.thrift.server.TSimpleServer) TServerTransport(org.apache.thrift.transport.TServerTransport)

Example 44 with TServerSocket

use of org.apache.thrift.transport.TServerSocket in project providence by morimekta.

the class SocketClientHandlerTest method setUpServer.

@BeforeClass
public static void setUpServer() throws Exception {
    Awaitility.setDefaultPollDelay(2, TimeUnit.MILLISECONDS);
    impl = Mockito.mock(Iface.class);
    TServerSocket transport = new TServerSocket(0);
    server = new TSimpleServer(new TServer.Args(transport).protocolFactory(new TBinaryProtocol.Factory()).processor(new Processor<>(impl)));
    executor = Executors.newSingleThreadExecutor();
    executor.submit(server::serve);
    serializer = new BinarySerializer();
    port = transport.getServerSocket().getLocalPort();
    address = new InetSocketAddress("localhost", port);
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) Iface(net.morimekta.test.thrift.thrift.service.MyService.Iface) InetSocketAddress(java.net.InetSocketAddress) TSimpleServer(org.apache.thrift.server.TSimpleServer) BinarySerializer(net.morimekta.providence.serializer.BinarySerializer) BeforeClass(org.junit.BeforeClass)

Example 45 with TServerSocket

use of org.apache.thrift.transport.TServerSocket in project zeppelin by apache.

the class RemoteInterpreterServer method run.

@Override
public void run() {
    RemoteInterpreterService.Processor<RemoteInterpreterServer> processor = new RemoteInterpreterService.Processor<>(this);
    try (TServerSocket tSocket = new TServerSocket(port)) {
        server = new TThreadPoolServer(new TThreadPoolServer.Args(tSocket).stopTimeoutVal(DEFAULT_SHUTDOWN_TIMEOUT).stopTimeoutUnit(TimeUnit.MILLISECONDS).processor(processor));
        if (null != intpEventServerHost && !isTest) {
            Thread registerThread = new Thread(new RegisterRunnable());
            registerThread.setName("RegisterThread");
            registerThread.start();
        }
        LOGGER.info("Launching ThriftServer at {}:{}", this.host, this.port);
        server.serve();
    } catch (TTransportException e) {
        LOGGER.error("Failure in TTransport", e);
    }
    LOGGER.info("RemoteInterpreterServer-Thread finished");
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) RemoteInterpreterService(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService) TTransportException(org.apache.thrift.transport.TTransportException) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer)

Aggregations

TServerSocket (org.apache.thrift.transport.TServerSocket)49 TThreadPoolServer (org.apache.thrift.server.TThreadPoolServer)30 TServerTransport (org.apache.thrift.transport.TServerTransport)20 TServer (org.apache.thrift.server.TServer)15 InetSocketAddress (java.net.InetSocketAddress)14 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)14 TTransportException (org.apache.thrift.transport.TTransportException)13 TTransportFactory (org.apache.thrift.transport.TTransportFactory)11 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)9 ArrayList (java.util.ArrayList)7 TProtocol (org.apache.thrift.protocol.TProtocol)7 TSimpleServer (org.apache.thrift.server.TSimpleServer)7 TTransport (org.apache.thrift.transport.TTransport)7 TProcessor (org.apache.thrift.TProcessor)6 TProtocolFactory (org.apache.thrift.protocol.TProtocolFactory)6 TServerEventHandler (org.apache.thrift.server.TServerEventHandler)6 IOException (java.io.IOException)5 ExecutorService (java.util.concurrent.ExecutorService)5 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)5 ServerContext (org.apache.thrift.server.ServerContext)5