Created
February 26, 2014 19:52
-
-
Save abramsm/9237098 to your computer and use it in GitHub Desktop.
Configuration for fast start embedded Zookeeper, useful for unit tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InstanceSpec spec = new InstanceSpec(null, -1, -1, -1, true, -1, 2000, 10); | |
System.setProperty("zookeeper.serverCnxnFactory", "org.apache.zookeeper.server.NettyServerCnxnFactory"); | |
myKeeper = new TestingServer(spec); | |
String keeperPort = String.valueOf(spec.getPort()); | |
System.setProperty("zk.servers", "localhost:" + keeperPort); | |
zkClient = CuratorFrameworkFactory.builder() | |
.sessionTimeoutMs(60000) | |
.connectionTimeoutMs(10000) | |
.connectString("localhost:" + keeperPort) | |
.retryPolicy(new RetryOneTime(1000)) | |
.defaultData(null) | |
.build(); | |
zkClient.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment