Package org.apache.hama.ipc

Examples of org.apache.hama.ipc.Server


    }

  }

  public void testCalls() throws Exception {
    Server server = RPC.getServer(new TestImpl(), ADDRESS, PORT, conf);
    server.start();

    InetSocketAddress addr = new InetSocketAddress(PORT);
    TestProtocol proxy = (TestProtocol) RPC.getProxy(TestProtocol.class,
        TestProtocol.versionID, addr, conf);

    proxy.ping();

    String stringResult = proxy.echo("foo");
    assertEquals(stringResult, "foo");

    stringResult = proxy.echo((String) null);
    assertEquals(stringResult, null);

    String[] stringResults = proxy.echo(new String[] { "foo", "bar" });
    assertTrue(Arrays.equals(stringResults, new String[] { "foo", "bar" }));

    stringResults = proxy.echo((String[]) null);
    assertTrue(Arrays.equals(stringResults, null));

    int intResult = proxy.add(1, 2);
    assertEquals(intResult, 3);

    intResult = proxy.add(new int[] { 1, 2 });
    assertEquals(intResult, 3);

    boolean caught = false;
    try {
      proxy.error();
    } catch (IOException e) {
      LOG.debug("Caught " + e);
      caught = true;
    }
    assertTrue(caught);

    proxy.testServerGet();

    // try some multi-calls
    Method echo = TestProtocol.class.getMethod("echo",
        new Class[] { String.class });
    String[] strings = (String[]) RPC.call(echo, new String[][] { { "a" },
        { "b" } }, new InetSocketAddress[] { addr, addr }, null, conf);
    assertTrue(Arrays.equals(strings, new String[] { "a", "b" }));

    Method ping = TestProtocol.class.getMethod("ping", new Class[] {});
    Object[] voids = RPC.call(ping, new Object[][] { {}, {} },
        new InetSocketAddress[] { addr, addr }, null, conf);
    assertEquals(voids, null);

    server.stop();
  }
View Full Code Here

TOP

Related Classes of org.apache.hama.ipc.Server

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.