use of org.apache.zookeeper.server.quorum.QuorumPeerConfig in project jmxtrans by jmxtrans.
the class EmbeddedZookeeper method before.
@Override
public void before() throws Exception {
LOGGER.info("Starting Zookeeper");
Properties properties = getResourceAsProperties("zookeeper.properties");
dataDir = temporaryFolder.newFolder("zookeeper");
properties.setProperty("dataDir", dataDir.getAbsolutePath());
QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
try {
quorumConfiguration.parseProperties(properties);
} catch (Exception e) {
throw new RuntimeException(e);
}
final ServerConfig configuration = new ServerConfig();
configuration.readFrom(quorumConfiguration);
// Start Zookeeper in separate thread
executor.execute(new Runnable() {
@Override
public void run() {
runServer(configuration);
}
});
// Wait for Zookeeper to be started
await().atMost(5, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return getServerCnxnFactory() != null;
}
});
}
use of org.apache.zookeeper.server.quorum.QuorumPeerConfig in project hbase by apache.
the class HQuorumPeer method main.
/**
* Parse ZooKeeper configuration from HBase XML config and run a QuorumPeer.
* @param args String[] of command line arguments. Not used.
*/
public static void main(String[] args) {
Configuration conf = HBaseConfiguration.create();
try {
Properties zkProperties = ZKConfig.makeZKProps(conf);
writeMyID(zkProperties);
QuorumPeerConfig zkConfig = new QuorumPeerConfig();
zkConfig.parseProperties(zkProperties);
// login the zookeeper server principal (if using security)
ZKAuthentication.loginServer(conf, HConstants.ZK_SERVER_KEYTAB_FILE, HConstants.ZK_SERVER_KERBEROS_PRINCIPAL, zkConfig.getClientPortAddress().getHostName());
runZKServer(zkConfig);
} catch (Exception e) {
LOG.error("Failed to start ZKServer", e);
System.exit(-1);
}
}
Aggregations