@Test public void testPortNumberResolution() throws Exception { final InetSocketAddress host11 = new InetSocketAddress(HOST1_IP1, 9003); final InetSocketAddress host12 = new InetSocketAddress(HOST1_IP2, 9003); final InetSocketAddress host21 = new InetSocketAddress(HOST2_IP1, 9004); final InetSocketAddress host22 = new InetSocketAddress(HOST2_IP2, 9004); final InetSocketAddress host31 = new InetSocketAddress(HOST3_IP1, 9005); final InetSocketAddress host32 = new InetSocketAddress(HOST3_IP2, 9005); NetworkAddressResolver resolver = mock(NetworkAddressResolver.class); when(resolver.resolve(HOST1)).thenReturn(asSet(HOST1_IP1, HOST1_IP2)); when(resolver.resolve(HOST2)).thenReturn(asSet(HOST2_IP1, HOST2_IP2)); when(resolver.resolve(HOST3)).thenReturn(asSet(HOST3_IP1 + ":9005", HOST3_IP2 + ":9005")); String hostsString = "HOST1,HOST2:9004,HOST3:9001"; final SessionRecycler recycler = new SessionRecycler(sessionFactory, resolver, hostsString, 5000); recycler.run(); verify(sessionFactory, times(6)).openSession(any(InetSocketAddress.class)); verify(sessionFactory).openSession(host11); verify(sessionFactory).openSession(host21); verify(sessionFactory).openSession(host31); verify(sessionFactory).openSession(host12); verify(sessionFactory).openSession(host22); verify(sessionFactory).openSession(host32); }
@Override public void run() { recycleSessions(); }
SessionRecycler implements Runnable { @Override public void run() { recycleSessions(); } }
SessionRecycler implements Runnable { @Override public void run() { recycleSessions(); } SessionRecycler(IoSessionFactory sessionFactory, NetworkAddressResolver resolver, String hosts, long sessionRecycleInterval); }
SessionRecycler implements Runnable { @Override public void run() { recycleSessions(); } SessionRecycler(IoSessionFactory sessionFactory, NetworkAddressResolver resolver, String hosts, long sessionRecycleInterval); void initialise(); @Override void run(); @ManagedOperation void recycleSessions(); @ManagedAttribute String getHosts(); @ManagedAttribute String getLastResolvedHosts(); @ManagedAttribute String getLastOpenedSessions(); @ManagedAttribute String getLastClosedSessions(); @ManagedAttribute Date getLastErrorTimestamp(); @ManagedAttribute String getLastErrorMessage(); @ManagedAttribute long getSessionRecycleInterval(); @ManagedAttribute Date getLastRecycleTimestamp(); @ManagedAttribute Date getLastCheckTimestamp(); }
SessionRecycler implements Runnable { @Override public void run() { recycleSessions(); } SessionRecycler(IoSessionFactory sessionFactory, NetworkAddressResolver resolver, String hosts, long sessionRecycleInterval); void initialise(); @Override void run(); @ManagedOperation void recycleSessions(); @ManagedAttribute String getHosts(); @ManagedAttribute String getLastResolvedHosts(); @ManagedAttribute String getLastOpenedSessions(); @ManagedAttribute String getLastClosedSessions(); @ManagedAttribute Date getLastErrorTimestamp(); @ManagedAttribute String getLastErrorMessage(); @ManagedAttribute long getSessionRecycleInterval(); @ManagedAttribute Date getLastRecycleTimestamp(); @ManagedAttribute Date getLastCheckTimestamp();  }