Search in sources :

Example 1 with RpcMetrics

use of org.apache.hadoop.ipc.metrics.RpcMetrics in project hadoop by apache.

the class TestProtoBufRpc method testLogSlowRPC.

@Test(timeout = 12000)
public void testLogSlowRPC() throws IOException, ServiceException {
    TestRpcService2 client = getClient2();
    // make 10 K fast calls
    for (int x = 0; x < 10000; x++) {
        try {
            client.ping2(null, newEmptyRequest());
        } catch (Exception ex) {
            throw ex;
        }
    }
    // Ensure RPC metrics are updated
    RpcMetrics rpcMetrics = server.getRpcMetrics();
    assertTrue(rpcMetrics.getProcessingSampleCount() > 999L);
    long before = rpcMetrics.getRpcSlowCalls();
    // make a really slow call. Sleep sleeps for 1000ms
    client.sleep(null, newSleepRequest(SLEEP_DURATION * 3));
    long after = rpcMetrics.getRpcSlowCalls();
    // Ensure slow call is logged.
    Assert.assertEquals(before + 1L, after);
}
Also used : RpcMetrics(org.apache.hadoop.ipc.metrics.RpcMetrics) ServiceException(com.google.protobuf.ServiceException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with RpcMetrics

use of org.apache.hadoop.ipc.metrics.RpcMetrics in project hadoop by apache.

the class TestProtoBufRpc method testEnsureNoLogIfDisabled.

@Test(timeout = 12000)
public void testEnsureNoLogIfDisabled() throws IOException, ServiceException {
    // disable slow RPC  logging
    server.setLogSlowRPC(false);
    TestRpcService2 client = getClient2();
    // make 10 K fast calls
    for (int x = 0; x < 10000; x++) {
        client.ping2(null, newEmptyRequest());
    }
    // Ensure RPC metrics are updated
    RpcMetrics rpcMetrics = server.getRpcMetrics();
    assertTrue(rpcMetrics.getProcessingSampleCount() > 999L);
    long before = rpcMetrics.getRpcSlowCalls();
    // make a really slow call. Sleep sleeps for 1000ms
    client.sleep(null, newSleepRequest(SLEEP_DURATION));
    long after = rpcMetrics.getRpcSlowCalls();
    // make sure we never called into Log slow RPC routine.
    assertEquals(before, after);
}
Also used : RpcMetrics(org.apache.hadoop.ipc.metrics.RpcMetrics) Test(org.junit.Test)

Aggregations

RpcMetrics (org.apache.hadoop.ipc.metrics.RpcMetrics)2 Test (org.junit.Test)2 ServiceException (com.google.protobuf.ServiceException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1