Search in sources :

Example 1 with RPCInterface

use of org.apache.hyracks.ipc.api.RPCInterface in project asterixdb by apache.

the class IPCTest method test.

@Test
public void test() throws Exception {
    IPCSystem server = createServerIPCSystem();
    server.start();
    InetSocketAddress serverAddr = server.getSocketAddress();
    RPCInterface rpci = new RPCInterface();
    IPCSystem client = createClientIPCSystem(rpci);
    client.start();
    IIPCHandle handle = client.getHandle(serverAddr);
    for (int i = 0; i < 100; ++i) {
        Assert.assertEquals(rpci.call(handle, Integer.valueOf(i)), Integer.valueOf(2 * i));
    }
    try {
        rpci.call(handle, "Foo");
        Assert.assertTrue(false);
    } catch (Exception e) {
        Assert.assertTrue(true);
    }
}
Also used : IIPCHandle(org.apache.hyracks.ipc.api.IIPCHandle) InetSocketAddress(java.net.InetSocketAddress) RPCInterface(org.apache.hyracks.ipc.api.RPCInterface) IOException(java.io.IOException) IPCException(org.apache.hyracks.ipc.exceptions.IPCException) IPCSystem(org.apache.hyracks.ipc.impl.IPCSystem) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 IIPCHandle (org.apache.hyracks.ipc.api.IIPCHandle)1 RPCInterface (org.apache.hyracks.ipc.api.RPCInterface)1 IPCException (org.apache.hyracks.ipc.exceptions.IPCException)1 IPCSystem (org.apache.hyracks.ipc.impl.IPCSystem)1 Test (org.junit.Test)1