public void setMaxClientCnxnsPerHost(int max) { if (zks.serverCnxnFactory != null) { zks.serverCnxnFactory.setMaxClientCnxnsPerHost(max); } if (zks.secureServerCnxnFactory != null) { zks.secureServerCnxnFactory.setMaxClientCnxnsPerHost(max); } }
public void setMaxClientCnxnsPerHost(int max) { // if fac is null the exception will be propagated to the client zks.getServerCnxnFactory().setMaxClientCnxnsPerHost(max); }
@Test public void testMaximumCnxnPerIP() throws Exception { final int maxClientCnxnsPerIP = 3; serverFactory.setMaxClientCnxnsPerHost(maxClientCnxnsPerIP); ZooKeeper[] clients = new ZooKeeper[maxClientCnxnsPerIP + 1]; for (int i = 0; i < clients.length; i++) { CountdownWatcher watcher = new CountdownWatcher(); // wait for 3s int timeout = 3000; clients[i] = new DisconnectableZooKeeper(HOSTPORT, timeout, watcher); boolean result = watcher.clientConnected.await(timeout, TimeUnit.MILLISECONDS); if (i >= maxClientCnxnsPerIP) { Assert.assertFalse(result); } else { Assert.assertTrue(result); } } } }