Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger");
field.setAccessible(true);
LeasePinger pinger = (LeasePinger) field.get(clientInvoker);
// Prevent server from answering PINGs.
SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker();
field = SocketServerInvoker.class.getDeclaredField("clientpool");
field.setAccessible(true);
LRUPool clientpool = (LRUPool) field.get(serverInvoker);
assertEquals(1, clientpool.size());
ServerThread st = (ServerThread) clientpool.getContents().iterator().next();
while (clientpool.size() > 0)
{
st.evict();
Thread.sleep(1000);
}
field = SocketServerInvoker.class.getDeclaredField("threadpool");
field.setAccessible(true);
List threadpool = (List) field.get(serverInvoker);
threadpool.clear();
assertEquals(0, threadpool.size());
log.info("clientpool.size(): " + clientpool.size());
log.info("threadpool.size(): " + threadpool.size());
serverInvoker.setMaxPoolSize(0);
// Verify that PING fails after default timeout.
Field succeedField = LeasePinger.class.getDeclaredField("pingSucceeded");
succeedField.setAccessible(true);
Field invokedField = LeasePinger.class.getDeclaredField("pingInvoked");