Search in sources :

Example 6 with TSimpleServer

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

use of org.apache.thrift.server.TSimpleServer 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)

Aggregations

TSimpleServer (org.apache.thrift.server.TSimpleServer)7 TServerSocket (org.apache.thrift.transport.TServerSocket)7 TServer (org.apache.thrift.server.TServer)5 TServerTransport (org.apache.thrift.transport.TServerTransport)4 InetSocketAddress (java.net.InetSocketAddress)2 CrossPlatformService (com.baeldung.thrift.impl.CrossPlatformService)1 PingPong (com.twitter.common.examples.pingpong.PingPong)1 ServerSocket (java.net.ServerSocket)1 ExecutorService (java.util.concurrent.ExecutorService)1 BinarySerializer (net.morimekta.providence.serializer.BinarySerializer)1 NoLogging (net.morimekta.providence.tools.rpc.internal.NoLogging)1 MyService (net.morimekta.test.thrift.MyService)1 Iface (net.morimekta.test.thrift.thrift.service.MyService.Iface)1 Args (org.apache.thrift.server.TServer.Args)1 TTransportException (org.apache.thrift.transport.TTransportException)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1