use of java.net.InetSocketAddress in project hadoop by apache.
the class TestRPC method testServerAddress.
@Test
public void testServerAddress() throws IOException {
Server server;
server = setupTestServer(conf, 5);
try {
InetSocketAddress bindAddr = NetUtils.getConnectAddress(server);
assertEquals(InetAddress.getLocalHost(), bindAddr.getAddress());
} finally {
stop(server, null);
}
}
use of java.net.InetSocketAddress in project hadoop by apache.
the class TestIPC method testIpcConnectTimeout.
@Test(timeout = 60000)
public void testIpcConnectTimeout() throws IOException {
// start server
Server server = new TestServer(1, true);
InetSocketAddress addr = NetUtils.getConnectAddress(server);
//Intentionally do not start server to get a connection timeout
// start client
Client.setConnectTimeout(conf, 100);
Client client = new Client(LongWritable.class, conf);
// set the rpc timeout to twice the MIN_SLEEP_TIME
try {
call(client, new LongWritable(RANDOM.nextLong()), addr, MIN_SLEEP_TIME * 2, conf);
fail("Expected an exception to have been thrown");
} catch (SocketTimeoutException e) {
LOG.info("Get a SocketTimeoutException ", e);
}
client.stop();
}
use of java.net.InetSocketAddress in project hadoop by apache.
the class TestIPC method testIpcAfterStopping.
@Test(timeout = 30000, expected = IOException.class)
public void testIpcAfterStopping() throws IOException {
// start server
Server server = new TestServer(5, false);
InetSocketAddress addr = NetUtils.getConnectAddress(server);
server.start();
// start client
Client client = new Client(LongWritable.class, conf);
call(client, addr, 0, conf);
client.stop();
// This call should throw IOException.
call(client, addr, 0, conf);
}
use of java.net.InetSocketAddress in project hadoop by apache.
the class TestIPC method testIpcWithServiceClass.
/**
* Check service class byte in IPC header is correct on wire.
*/
@Test(timeout = 60000)
public void testIpcWithServiceClass() throws IOException {
// start server
Server server = new TestServer(5, false);
InetSocketAddress addr = NetUtils.getConnectAddress(server);
server.start();
// start client
Client.setConnectTimeout(conf, 10000);
callAndVerify(server, addr, 0, true);
// Service Class is low to -128 as byte on wire.
// -128 shouldn't be casted on wire but -129 should.
callAndVerify(server, addr, -128, true);
callAndVerify(server, addr, -129, false);
// Service Class is up to 127.
// 127 shouldn't be casted on wire but 128 should.
callAndVerify(server, addr, 127, true);
callAndVerify(server, addr, 128, false);
server.stop();
}
use of java.net.InetSocketAddress in project hadoop by apache.
the class TestIPC method testInitialCallRetryCount.
/**
* Test if the rpc server gets the default retry count (0) from client.
*/
@Test(timeout = 60000)
public void testInitialCallRetryCount() throws IOException {
// Override client to store the call id
final Client client = new Client(LongWritable.class, conf);
// Attach a listener that tracks every call ID received by the server.
final TestServer server = new TestServer(1, false);
server.callListener = new Runnable() {
@Override
public void run() {
// we have not set the retry count for the client, thus on the server
// side we should see retry count as 0
Assert.assertEquals(0, Server.getCallRetryCount());
}
};
try {
InetSocketAddress addr = NetUtils.getConnectAddress(server);
server.start();
final SerialCaller caller = new SerialCaller(client, addr, 10);
caller.run();
assertFalse(caller.failed);
} finally {
client.stop();
server.stop();
}
}
Aggregations