Search in sources :

Example 1 with TSimpleServer

use of org.apache.thrift.server.TSimpleServer in project HackTutorial by linrongbin16.

the class Server method main.

public static void main(String[] args) throws Exception {
    ServerSocket socket = new ServerSocket(30003);
    TServerSocket serverTransport = new TServerSocket(socket);
    Basic.BasicService.Processor processor = new Basic.BasicService.Processor(new BasicServiceImpl());
    TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
    System.out.println("Server Starting...");
    server.serve();
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) Args(org.apache.thrift.server.TServer.Args) TServer(org.apache.thrift.server.TServer) ServerSocket(java.net.ServerSocket) TServerSocket(org.apache.thrift.transport.TServerSocket) TSimpleServer(org.apache.thrift.server.TSimpleServer)

Example 2 with TSimpleServer

use of org.apache.thrift.server.TSimpleServer in project providence by morimekta.

the class RPCThriftSocketTest method setUp.

@Before
public void setUp() throws Exception {
    Log.setLog(new NoLogging());
    rc = copyResourceTo("/pvdrc", temp.getRoot());
    copyResourceTo("/test.thrift", temp.getRoot());
    impl = Mockito.mock(MyService.Iface.class);
    TServerSocket transport = new TServerSocket(0);
    server = new TSimpleServer(new TServer.Args(transport).protocolFactory(new TBinaryProtocol.Factory()).processor(new MyService.Processor<>(impl)));
    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.submit(server::serve);
    Thread.sleep(1);
    port = transport.getServerSocket().getLocalPort();
    exitCode = 0;
    rpc = new RPC(console.tty()) {

        @Override
        protected void exit(int i) {
            exitCode = i;
        }
    };
}
Also used : NoLogging(net.morimekta.providence.tools.rpc.internal.NoLogging) TServerSocket(org.apache.thrift.transport.TServerSocket) MyService(net.morimekta.test.thrift.MyService) ExecutorService(java.util.concurrent.ExecutorService) TSimpleServer(org.apache.thrift.server.TSimpleServer) Before(org.junit.Before)

Example 3 with TSimpleServer

use of org.apache.thrift.server.TSimpleServer in project vcell by virtualcell.

the class VCellProxyServer method startSimpleVCellProxyServer.

private static void startSimpleVCellProxyServer(VCellProxy.Processor<VCellProxyHandler> processor) {
    try {
        InetSocketAddress inetSocketAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 9090);
        TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
        TServer vcellProxyServer = new TSimpleServer(new org.apache.thrift.server.TServer.Args(serverTransport).processor(processor));
        System.out.println("Starting the VCell-VisIt Data Server thread...");
        vcellProxyServer.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) TServer(org.apache.thrift.server.TServer) InetSocketAddress(java.net.InetSocketAddress) TSimpleServer(org.apache.thrift.server.TSimpleServer) TServerTransport(org.apache.thrift.transport.TServerTransport)

Example 4 with TSimpleServer

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

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