/** * Test {@link AuditLogger} with IP set. */ public void testAuditLoggerWithIP() throws Exception { Configuration conf = new Configuration(); // start the IPC server Server server = RPC.getServer(new MyTestRPCServer(), "0.0.0.0", 0, conf); server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); // Make a client connection and test the audit log TestProtocol proxy = (TestProtocol)RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); // Start the testcase proxy.ping(); server.stop(); } }
TestProtocol.class, TestProtocol.versionID, addr, conf); proxy.ping();
@Test(timeout=90000) public void testRPCInterruptedSimple() throws IOException { final Configuration conf = new Configuration(); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS) .setPort(0).setNumHandlers(5).setVerbose(true) .setSecretManager(null).build(); server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); final TestProtocol proxy = RPC.getProxy( TestProtocol.class, TestProtocol.versionID, addr, conf); // Connect to the server proxy.ping(); // Interrupt self, try another call Thread.currentThread().interrupt(); try { proxy.ping(); fail("Interruption did not cause IPC to fail"); } catch (IOException ioe) { if (!ioe.toString().contains("InterruptedException")) { throw ioe; } // clear interrupt status for future tests Thread.interrupted(); } finally { server.stop(); } }
try { for (int i=0; i<1000; i++) { proxy.ping(); proxy.echo("" + i); proxy2.echo("" + i);
proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); proxy.ping();
proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); proxy.ping();
try { for (int i=0; i<1000; i++) { proxy.ping(); proxy.echo("" + i);
proxy = (TestProtocol)RPC.getProxy( TestProtocol.class, TestProtocol.versionID, addr, conf); proxy.ping();
/** * Test {@link RMAuditLogger} with IP set. */ @Test public void testRMAuditLoggerWithIP() throws Exception { Configuration conf = new Configuration(); // start the IPC server Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new MyTestRPCServer()).setBindAddress("0.0.0.0") .setPort(0).setNumHandlers(5).setVerbose(true).build(); server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); // Make a client connection and test the audit log TestProtocol proxy = (TestProtocol)RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); // Start the testcase proxy.ping(); server.stop(); } }
/** * Test {@link AuditLogger} with IP set. */ public void testAuditLoggerWithIP() throws Exception { Configuration conf = new Configuration(); // start the IPC server Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new MyTestRPCServer()).setBindAddress("0.0.0.0") .setPort(0).build(); server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); // Make a client connection and test the audit log TestProtocol proxy = (TestProtocol)RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); // Start the testcase proxy.ping(); server.stop(); } }