Search in sources :

Example 6 with FixedEnsembleProvider

use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider 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)

Example 7 with FixedEnsembleProvider

use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider in project hadoop by apache.

the class CuratorService method supplyBindingInformation.

/**
   * Supply the binding information.
   * This implementation returns a fixed ensemble bonded to
   * the quorum supplied by {@link #buildConnectionString()}
   * @return the binding information
   */
@Override
public BindingInformation supplyBindingInformation() {
    BindingInformation binding = new BindingInformation();
    String connectString = buildConnectionString();
    binding.ensembleProvider = new FixedEnsembleProvider(connectString);
    binding.description = "fixed ZK quorum \"" + connectString + "\"";
    return binding;
}
Also used : FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider)

Aggregations

FixedEnsembleProvider (org.apache.curator.ensemble.fixed.FixedEnsembleProvider)7 ExhibitorEnsembleProvider (org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider)4 Injector (com.google.inject.Injector)3 Properties (java.util.Properties)3 EnsembleProvider (org.apache.curator.ensemble.EnsembleProvider)3 Test (org.junit.Test)3 Provides (com.google.inject.Provides)1 LazySingleton (io.druid.guice.LazySingleton)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 DefaultExhibitorRestClient (org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient)1 Exhibitors (org.apache.curator.ensemble.exhibitor.Exhibitors)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 BoundedExponentialBackoffRetry (org.apache.curator.retry.BoundedExponentialBackoffRetry)1 RetryOneTime (org.apache.curator.retry.RetryOneTime)1 BindingInformation (org.apache.hadoop.registry.client.impl.zk.BindingInformation)1 Id (org.apache.zookeeper.data.Id)1 ZooKeeperServer (org.apache.zookeeper.server.ZooKeeperServer)1 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)1