Description
while (true) { try { standaloneServerFactory = new NIOServerCnxnFactory(); standaloneServerFactory.configure( new InetSocketAddress(tentativePort), configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, 1000)); } catch (BindException e) { LOG.debug("Failed binding ZK Server to client port: " + tentativePort); // This port is already in use, try to use another. tentativePort++; continue; } break; }
In the case of failure and all the above ports have already been binded, you can extend past the max port. Need to check against a max value.