Search in sources :

Example 21 with QuorumPeerConfig

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;
        }
    });
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) Properties(java.util.Properties) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 22 with QuorumPeerConfig

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);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) Properties(java.util.Properties) IOException(java.io.IOException)

Aggregations

QuorumPeerConfig (org.apache.zookeeper.server.quorum.QuorumPeerConfig)21 IOException (java.io.IOException)12 ServerConfig (org.apache.zookeeper.server.ServerConfig)10 Properties (java.util.Properties)9 File (java.io.File)8 ZooKeeperServerMain (org.apache.zookeeper.server.ZooKeeperServerMain)5 InputStream (java.io.InputStream)3 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)3 Test (org.junit.jupiter.api.Test)3 ServerCnxnFactory (org.apache.zookeeper.server.ServerCnxnFactory)2 QuorumPeer (org.apache.zookeeper.server.quorum.QuorumPeer)2 Timeout (org.junit.jupiter.api.Timeout)2 RuntimeProperties (io.fabric8.api.RuntimeProperties)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 Map (java.util.Map)1 CarbonProperties (org.apache.carbondata.core.util.CarbonProperties)1 ServerConfig (org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig)1 ZooKeeperServerMain (org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain)1