Пример #1
0
  @Test(timeout = 60000)
  @SetupRpcConnection(setupRpcServer = false, setupRpcClient = false)
  public void testClientRetryFailureOnStartup() throws Exception {
    retries = 2;
    ServerSocket serverSocket = new ServerSocket(0);
    final InetSocketAddress address =
        new InetSocketAddress("127.0.0.1", serverSocket.getLocalPort());
    serverSocket.close();

    EchoMessage message = EchoMessage.newBuilder().setMessage(MESSAGE).build();

    RpcConnectionKey rpcConnectionKey = new RpcConnectionKey(address, DummyProtocol.class, false);

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

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

    try {
      client.connect();
      fail();
    } catch (ConnectTimeoutException e) {
      assertFalse(e.getMessage(), client.isConnected());
    }

    BlockingInterface stub = client.getStub();
    try {
      EchoMessage response = stub.echo(null, message);
      fail();
    } catch (TajoServiceException e) {
      assertFalse(e.getMessage(), client.isConnected());
    }
    RpcClientManager.cleanup(client);
  }
Пример #2
0
  @Test
  public void testThrowException() throws Exception {
    EchoMessage message = EchoMessage.newBuilder().setMessage(MESSAGE).build();

    try {
      stub.throwException(null, message);
      fail("RpcCall should throw exception");
    } catch (TajoServiceException te) {
      assertEquals("Exception Test", te.getMessage());
      assertEquals("org.apache.tajo.rpc.test.DummyProtocol", te.getProtocol());
      assertEquals(
          server.getListenAddress().getAddress().getHostAddress()
              + ":"
              + server.getListenAddress().getPort(),
          te.getRemoteAddress());
    }
  }