Beispiel #1
0
  @Test(timeout = 120000)
  @SetupRpcConnection(setupRpcClient = false)
  public void testUnresolvedAddress2() throws Exception {

    String hostAndPort = RpcUtils.normalizeInetSocketAddress(server.getListenAddress());
    RpcConnectionKey rpcConnectionKey =
        new RpcConnectionKey(RpcUtils.createUnresolved(hostAndPort), DummyProtocol.class, false);

    Properties connParams = new Properties();
    connParams.setProperty(RpcConstants.CLIENT_RETRY_NUM, retries + "");

    BlockingRpcClient client =
        new BlockingRpcClient(NettyUtils.getDefaultEventLoopGroup(), rpcConnectionKey, connParams);
    client.connect();
    assertTrue(client.isConnected());

    try {
      BlockingInterface stub = client.getStub();
      EchoMessage message = EchoMessage.newBuilder().setMessage(MESSAGE).build();
      EchoMessage response2 = stub.echo(null, message);
      assertEquals(MESSAGE, response2.getMessage());
    } finally {
      client.close();
    }
  }
Beispiel #2
0
  public void setUpRpcClient() throws Exception {
    retries = 1;

    Properties connParams = new Properties();
    connParams.setProperty(RpcConstants.CLIENT_RETRY_NUM, "1");
    connParams.setProperty(
        RpcConstants.CLIENT_SOCKET_TIMEOUT, String.valueOf(TimeUnit.SECONDS.toMillis(10)));
    connParams.setProperty(RpcConstants.CLIENT_HANG_DETECTION, "true");

    RpcConnectionKey rpcConnectionKey =
        new RpcConnectionKey(
            RpcUtils.getConnectAddress(server.getListenAddress()), DummyProtocol.class, false);
    client = manager.newClient(rpcConnectionKey, connParams);
    assertTrue(client.isConnected());
    stub = client.getStub();
  }