Examples of RpcChannel


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

Examples of com.google.protobuf.RpcChannel

  private void doTest(RpcServer rpcServer) throws InterruptedException,
      ServiceException, IOException {
    BlockingRpcChannel blockingChannel = RpcChannels
        .newBlockingRpcChannel(clientConnectionFactory);
    RpcChannel channel = RpcChannels.newRpcChannel(clientConnectionFactory,
        threadPool);
    BlockingInterface blockingStub = TestService
        .newBlockingStub(blockingChannel);
    TestService stub = TestService.newStub(channel);
View Full Code Here

Examples of com.google.protobuf.RpcChannel

      throws Exception
  {
    Socket socket = new Socket("127.0.0.1", 7777);
    final DataInputStream dis = new DataInputStream(socket.getInputStream());
    final DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
    RpcChannel channel = new RpcChannel()
    {
      public void callMethod (MethodDescriptor method,
                              RpcController controller,
                              Message request,
                              Message responsePrototype,
View Full Code Here

Examples of com.google.protobuf.RpcChannel

  public static void main (String... args)
      throws Exception
  {
    final HttpClient client = new HttpClient();
    RpcChannel channel = new RpcChannel()
    {
      public void callMethod (MethodDescriptor method,
                              RpcController controller,
                              Message request,
                              Message responsePrototype,
View Full Code Here

Examples of muduo.rpc.RpcChannel

public class Client {

    private static void blockingConnect(InetSocketAddress addr) throws Exception {
        RpcClient client = new RpcClient();
        RpcChannel channel = client.blockingConnect(addr);
        //sendRequest(channel, client);
        BlockingInterface remoteService = Sudoku.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

Examples of muduo.rpc.RpcChannel

        @Override
        public void run() {
            System.out.println(Thread.currentThread());
            RpcClient client = new RpcClient(channelFactory);
            RpcChannel channel = client.blockingConnect(serverAddr);
            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

Examples of muduo.rpc.RpcChannel

    SudokuResponse gotResponse;

    @Test
    public void testClient() throws Exception {
        MockChannel mockChannel = new MockChannel();
        RpcChannel channel = new RpcChannel(mockChannel);
        SudokuService remoteService = Sudoku.SudokuService.newStub(channel);
        SudokuRequest request = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        remoteService.solve(null, request, new RpcCallback<Sudoku.SudokuResponse>() {
            @Override
            public void run(SudokuResponse response) {
                // System.out.println(parameter);
                gotResponse = response;
            }
        });
        RpcMessage message = (RpcMessage) mockChannel.message;
        assertEquals(1, message.getId());
        assertEquals(MessageType.REQUEST, message.getType());
        assertEquals(remoteService.getDescriptorForType().getFullName(), message.getService());
        assertEquals("Solve", message.getMethod());

        SudokuResponse sudokuResponse = SudokuResponse.newBuilder()
                .setSolved(true)
                .setCheckerboard("123456")
                .build();
        RpcMessage response = RpcMessage.newBuilder()
                .setType(MessageType.RESPONSE)
                .setId(1)
                .setResponse(sudokuResponse.toByteString())
                .build();
        channel.messageReceived(null, new UpstreamMessageEvent(mockChannel, response, null));
        assertEquals(sudokuResponse, gotResponse);
    }
View Full Code Here

Examples of muduo.rpc.RpcChannel

                done.run(sudokuResponse);
            }
        };
        services.put(SudokuService.getDescriptor().getFullName(),
                SudokuService.newReflectiveService(mockImpl));
        RpcChannel channel = new RpcChannel(mockChannel);
        channel.setServiceMap(services);

        SudokuRequest sudokuRequest = SudokuRequest.newBuilder().setCheckerboard("001010").build();
        RpcMessage request = RpcMessage.newBuilder()
                .setType(MessageType.REQUEST)
                .setId(2)
                .setService(SudokuService.getDescriptor().getFullName())
                .setMethod("Solve")
                .setRequest(sudokuRequest.toByteString())
                .build();

        channel.messageReceived(null, new UpstreamMessageEvent(mockChannel, request, null));
        assertEquals(sudokuRequest, gotRequest);

        RpcMessage response = RpcMessage.newBuilder()
                .setType(MessageType.RESPONSE)
                .setId(2)
View Full Code Here

Examples of org.apache.catalina.tribes.group.RpcChannel

            this.mapContextName = mapContextName.getBytes();
        }
        if ( log.isTraceEnabled() ) log.trace("Created Lazy Map with name:"+mapContextName+", bytes:"+Arrays.toString(this.mapContextName));

        //create an rpc channel and add the map as a listener
        this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
        //add this map as a message listener
        this.channel.addChannelListener(this);
        //listen for membership notifications
        this.channel.addMembershipListener(this);
       
View Full Code Here

Examples of org.apache.catalina.tribes.group.RpcChannel

        //unique context is more efficient if it is stored as bytes
        this.mapContextName = mapContextName.getBytes(StandardCharsets.ISO_8859_1);
        if ( log.isTraceEnabled() ) log.trace("Created Lazy Map with name:"+mapContextName+", bytes:"+Arrays.toString(this.mapContextName));

        //create an rpc channel and add the map as a listener
        this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
        //add this map as a message listener
        this.channel.addChannelListener(this);
        //listen for membership notifications
        this.channel.addMembershipListener(this);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.