Search in sources :

Example 16 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project motan by weibocom.

the class EmbeddedZookeeper method start.

public void start() throws IOException, QuorumPeerConfig.ConfigException {
    Properties properties = new Properties();
    InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
    properties.load(in);
    QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
    quorumConfiguration.parseProperties(properties);
    in.close();
    zookeeperServer = new ZooKeeperServerMain();
    final ServerConfig configuration = new ServerConfig();
    configuration.readFrom(quorumConfiguration);
    t1 = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                zookeeperServer.runFromConfig(configuration);
            } catch (IOException e) {
            }
        }
    });
    t1.start();
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 17 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project motan by weibocom.

the class EmbeddedZookeeper method start.

public void start() throws IOException, QuorumPeerConfig.ConfigException {
    Properties properties = new Properties();
    InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
    properties.load(in);
    QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
    quorumConfiguration.parseProperties(properties);
    in.close();
    zookeeperServer = new ZooKeeperServerMain();
    final ServerConfig configuration = new ServerConfig();
    configuration.readFrom(quorumConfiguration);
    t1 = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                zookeeperServer.runFromConfig(configuration);
            } catch (IOException e) {
            }
        }
    });
    t1.start();
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 18 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project flink by apache.

the class FlinkZooKeeperQuorumPeer method runFlinkZkQuorumPeer.

// ------------------------------------------------------------------------
/**
 * Runs a ZooKeeper {@link QuorumPeer} if further peers are configured or a single {@link
 * ZooKeeperServer} if no further peers are configured.
 *
 * @param zkConfigFile ZooKeeper config file 'zoo.cfg'
 * @param peerId ID for the 'myid' file
 */
public static void runFlinkZkQuorumPeer(String zkConfigFile, int peerId) throws Exception {
    Properties zkProps = new Properties();
    try (InputStream inStream = new FileInputStream(new File(zkConfigFile))) {
        zkProps.load(inStream);
    }
    LOG.info("Configuration: " + zkProps);
    // Set defaults for required properties
    setRequiredProperties(zkProps);
    // Write peer id to myid file
    writeMyIdToDataDir(zkProps, peerId);
    // The myid file needs to be written before creating the instance. Otherwise, this
    // will fail.
    QuorumPeerConfig conf = new QuorumPeerConfig();
    conf.parseProperties(zkProps);
    if (conf.isDistributed()) {
        // Run quorum peer
        LOG.info("Running distributed ZooKeeper quorum peer (total peers: {}).", conf.getServers().size());
        QuorumPeerMain qp = new QuorumPeerMain();
        qp.runFromConfig(conf);
    } else {
        // Run standalone
        LOG.info("Running standalone ZooKeeper quorum peer.");
        ZooKeeperServerMain zk = new ZooKeeperServerMain();
        ServerConfig sc = new ServerConfig();
        sc.readFrom(conf);
        zk.runFromConfig(sc);
    }
}
Also used : ServerConfig(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig) QuorumPeerMain(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerMain) QuorumPeerConfig(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) ZooKeeperServerMain(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain)

Example 19 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.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 20 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.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