public ServerCnxnFactory mkInprocessZookeeper(String localdir, int port) throws IOException, InterruptedException { LOG.info("Starting inprocess zookeeper at port " + port + " and dir " + localdir); File localfile = new File(localdir); ZooKeeperServer zk = new ZooKeeperServer(localfile, localfile, 2000); ServerCnxnFactory factory =NIOServerCnxnFactory.createFactory( new InetSocketAddress(port),60); factory.startup(zk); return factory; }
public EmbeddedZookeeper(int port) throws IOException { this.port = port; zkDataDir = Files.createTempDir(); zkServer = new ZooKeeperServer(); FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir); zkServer.setTxnLogFactory(ftxn); cnxnFactory = NIOServerCnxnFactory.createFactory(new InetSocketAddress(port), 0); }
private String startZk() throws IOException, InterruptedException, URISyntaxException { String zkValue = properties.getProperty("zookeeper.connect"); LOG.info("Starting zookeeper at {}", zkValue); URL zkAddress = getURL(zkValue); File snapshotDir = constructDir("zk/txn"); File logDir = constructDir("zk/snap"); factory = NIOServerCnxnFactory.createFactory(new InetSocketAddress(zkAddress.getHost(), zkAddress.getPort()), 1024); factory.startup(new ZooKeeperServer(snapshotDir, logDir, 500)); String ret = factory.getLocalAddress().getAddress().toString(); LOG.info("Embedded zookeeper for Kafka started at {}", ret); return ret; }
public void startup() { File snapshotDir; File logDir; try { snapshotDir = java.nio.file.Files.createTempDirectory("zookeeper-snapshot").toFile(); logDir = java.nio.file.Files.createTempDirectory("zookeeper-logs").toFile(); } catch (IOException e) { throw new RuntimeException("Unable to start Kafka", e); } snapshotDir.deleteOnExit(); logDir.deleteOnExit(); try { int tickTime = 500; ZooKeeperServer zkServer = new ZooKeeperServer(snapshotDir, logDir, tickTime); this.factory = NIOServerCnxnFactory.createFactory(); this.factory.configure(new InetSocketAddress("localhost", port), 16); factory.startup(zkServer); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (IOException e) { throw new RuntimeException("Unable to start ZooKeeper", e); } }
private String startZk() throws IOException, InterruptedException, URISyntaxException { String zkValue = properties.getProperty("zookeeper.connect"); LOG.info("Starting zookeeper at {}", zkValue); URL zkAddress = getURL(zkValue); File snapshotDir = constructDir("zk/txn"); File logDir = constructDir("zk/snap"); factory = NIOServerCnxnFactory.createFactory(new InetSocketAddress(zkAddress.getHost(), zkAddress.getPort()), 1024); factory.startup(new ZooKeeperServer(snapshotDir, logDir, 500)); String ret = factory.getLocalAddress().getAddress().toString(); LOG.info("Embedded zookeeper for Kafka started at {}", ret); return ret; }
int tickTime = 500; ZooKeeperServer zkServer = new ZooKeeperServer(snapshotDir, logDir, tickTime); this.factory = NIOServerCnxnFactory.createFactory(); this.factory.configure(new InetSocketAddress("localhost", port), maxConnections); factory.startup(zkServer);
int tickTime = 500; ZooKeeperServer zkServer = new ZooKeeperServer(snapshotDir, logDir, tickTime); this.factory = NIOServerCnxnFactory.createFactory(); this.factory.configure(new InetSocketAddress("localhost", port), 16); factory.startup(zkServer);
public EmbeddedZookeeper() throws IOException { zkDataDir = Files.createTempDir(); zkServer = new ZooKeeperServer(); FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir); zkServer.setTxnLogFactory(ftxn); cnxnFactory = NIOServerCnxnFactory.createFactory(0, 0); }
public void setup() { try { snapshotDir = FileUtil.createFileInTempDir(SNAPSHOT_DIR_RELATIVE_PATH); logDir = FileUtil.createFileInTempDir(LOG_DIR_RELATIVE_PATH); } catch (IOException e) { LOGGER.error("Failed to setup Zookeeper Server Environment", e); Assert.fail("Failed to setup Zookeeper Server Environment"); } try { zooKeeperServer = new ZooKeeperServer(snapshotDir, logDir, TICK_TIME); serverCnxnFactory = NIOServerCnxnFactory.createFactory(); InetSocketAddress addr = new InetSocketAddress("127.0.0.1", RANDOM_PORT); serverCnxnFactory.configure(addr, MAX_CLIENT_CONNECTIONS); serverCnxnFactory.startup(zooKeeperServer); } catch (Exception e) { LOGGER.error("Zookeeper Server failed to start", e); Assert.fail("Zookeeper Server failed to start"); } }