zkTmpDir.delete();
zkTmpDir.mkdir();
ZooKeeperServer zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, zkPort);
NIOServerCnxnFactory serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(zkPort), 100);
serverFactory.startup(zks);
boolean b = ClientBase.waitForServerUp("127.0.0.1:" + zkPort, 5000);
ServerConfiguration serverConf = new ServerConfiguration();
serverConf.loadConf(hedwigConfigFile.toURI().toURL());
logger.info("Zookeeper server up and running!");
ZooKeeper zkc = new ZooKeeper("127.0.0.1:" + zkPort, 5000, null);
// initialize the zk client with (fake) values
zkc.create("/ledgers", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
zkc.create("/ledgers/available", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
zkc.close();
PubSubServer hedwigServer = null;
try {
logger.info("starting hedwig broker!");
hedwigServer = new PubSubServer(serverConf, new ClientConfiguration(), new LoggingExceptionHandler());
hedwigServer.start();
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertNotNull("failed to instantiate hedwig pub sub server", hedwigServer);
hedwigServer.shutdown();
serverFactory.shutdown();
zks.shutdown();
zkTmpDir.delete();