Package com.chenshuo.muduo.protorpc

Examples of com.chenshuo.muduo.protorpc.RpcChannel


public class Client {

    private static void blockingConnect(InetSocketAddress addr) throws Exception {
        RpcClient client = new RpcClient();
        RpcChannel channel = client.blockingConnect(addr);
        //sendRequest(channel, client);
        SudokuService.BlockingInterface remoteService = SudokuProto.SudokuService.newBlockingStub(channel);
        SudokuRequest request = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        SudokuResponse response = remoteService.solve(null, request);
        System.out.println(response);
        channel.disconnect();
        client.stop();
    }
View Full Code Here


        @Override
        public void run() {
            System.out.println(Thread.currentThread());
            RpcClient client = new RpcClient(channelFactory);
            RpcChannel channel = client.blockingConnect(serverAddr);
            EchoService.BlockingInterface remoteService = EchoService.newBlockingStub(channel);
            String payload = new String(new byte[100]);
            payload = "Hello";
            EchoRequest request = EchoRequest.newBuilder().setPayload(payload).build();

            allConnected.countDown();
            try {
                startLatch.await();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            for (int i = 0; i < kRequests; ++i) {
                EchoResponse response;
                try {
                    response = remoteService.echo(null, request);
                    assert response.getPayload().equals(payload);
                } catch (ServiceException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                // System.out.println(response);
            }
            allFinished.countDown();
            System.out.println(Thread.currentThread());
            // System.out.println(response);
            channel.disconnect();
            // client.stop();
        }
View Full Code Here

TOP

Related Classes of com.chenshuo.muduo.protorpc.RpcChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.