Search in sources :

Example 1 with BindingInformation

use of org.apache.hadoop.registry.client.impl.zk.BindingInformation in project hadoop by apache.

the class MicroZookeeperService method serviceStart.

/**
   * Startup: start ZK. It is only after this that
   * the binding information is valid.
   * @throws Exception
   */
@Override
protected void serviceStart() throws Exception {
    setupSecurity();
    ZooKeeperServer zkServer = new ZooKeeperServer();
    FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(tickTime);
    LOG.info("Starting Local Zookeeper service");
    factory = ServerCnxnFactory.createFactory();
    factory.configure(getAddress(port), -1);
    factory.startup(zkServer);
    String connectString = getConnectionString();
    LOG.info("In memory ZK started at {}\n", connectString);
    if (LOG.isDebugEnabled()) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        zkServer.dumpConf(pw);
        pw.flush();
        LOG.debug(sw.toString());
    }
    binding = new BindingInformation();
    binding.ensembleProvider = new FixedEnsembleProvider(connectString);
    binding.description = getName() + " reachable at \"" + connectString + "\"";
    addDiagnostics(binding.description);
    // finally: set the binding information in the config
    getConfig().set(KEY_REGISTRY_ZK_QUORUM, connectString);
}
Also used : StringWriter(java.io.StringWriter) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog) BindingInformation(org.apache.hadoop.registry.client.impl.zk.BindingInformation) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 FixedEnsembleProvider (org.apache.curator.ensemble.fixed.FixedEnsembleProvider)1 BindingInformation (org.apache.hadoop.registry.client.impl.zk.BindingInformation)1 ZooKeeperServer (org.apache.zookeeper.server.ZooKeeperServer)1 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)1