Calling org.apache.zookeeper.server.quorum.QuorumPeerMain.main() isn\'t working.
Building on 1's answer by adding the use of an ephemeral port (shown by zkPort
) and updated for latest ZK API:
int tickTime = 2000;
int numConnections = 5000;
String dataDirectory = System.getProperty("java.io.tmpdir");
File dir = new File(dataDirectory, "zookeeper").getAbsoluteFile();
ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTime);
standaloneServerFactory = ServerCnxnFactory.createFactory(0, numConnections);
int zkPort = standaloneServerFactory.getLocalPort();
standaloneServerFactory.startup(server);