List of usage examples for org.apache.zookeeper.server ServerCnxnFactory getMaxClientCnxnsPerHost
public abstract int getMaxClientCnxnsPerHost();
From source file:com.palantir.curatortestrule.DefaultZooKeeperRuleConfig.java
License:Open Source License
@Override public ServerCnxnFactory getServer(int port) { ZooKeeperServer zkServer = new NoJMXZooKeeperServer(); FileTxnSnapLog ftxn;//from w w w . j av a2 s. c om try { File dataDir = Files.createTempDir(); File snapDir = Files.createTempDir(); if (cleanupOnExit) { directoriesToCleanup.add(dataDir); directoriesToCleanup.add(snapDir); } ftxn = new FileTxnSnapLog(dataDir, snapDir); } catch (IOException e) { throw new RuntimeException(e); } zkServer.setTxnLogFactory(ftxn); try { ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory(); cnxnFactory.configure(new InetSocketAddress(port), cnxnFactory.getMaxClientCnxnsPerHost()); cnxnFactory.startup(zkServer); return cnxnFactory; } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } }