Search in sources :

Example 1 with ConnectTimeoutException

use of org.apache.hadoop.net.ConnectTimeoutException in project hadoop by apache.

the class TestIPC method assertRetriesOnSocketTimeouts.

private void assertRetriesOnSocketTimeouts(Configuration conf, int maxTimeoutRetries) throws IOException {
    SocketFactory mockFactory = Mockito.mock(SocketFactory.class);
    doThrow(new ConnectTimeoutException("fake")).when(mockFactory).createSocket();
    Client client = new Client(LongWritable.class, conf, mockFactory);
    InetSocketAddress address = new InetSocketAddress("127.0.0.1", 9090);
    try {
        call(client, RANDOM.nextLong(), address, conf);
        fail("Not throwing the SocketTimeoutException");
    } catch (SocketTimeoutException e) {
        Mockito.verify(mockFactory, Mockito.times(maxTimeoutRetries)).createSocket();
    }
    client.stop();
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) SocketFactory(javax.net.SocketFactory) InetSocketAddress(java.net.InetSocketAddress) ConnectTimeoutException(org.apache.hadoop.net.ConnectTimeoutException)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 SocketTimeoutException (java.net.SocketTimeoutException)1 SocketFactory (javax.net.SocketFactory)1 ConnectTimeoutException (org.apache.hadoop.net.ConnectTimeoutException)1