Search in sources :

Example 26 with ServerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig 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 27 with ServerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project hbase by apache.

the class HQuorumPeer method runZKServer.

private static void runZKServer(QuorumPeerConfig zkConfig) throws IOException, AdminServer.AdminServerException {
    /**
     *  Start and schedule the purge task
     *  autopurge.purgeInterval is 0 by default,so in fact the DatadirCleanupManager task will not
     *  be started to clean the logs by default. Config is recommended only for standalone server.
     */
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(zkConfig.getDataDir(), zkConfig.getDataLogDir(), zkConfig.getSnapRetainCount(), zkConfig.getPurgeInterval());
    purgeMgr.start();
    if (zkConfig.isDistributed()) {
        QuorumPeerMain qp = new QuorumPeerMain();
        qp.runFromConfig(zkConfig);
    } else {
        ZooKeeperServerMain zk = new ZooKeeperServerMain();
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.readFrom(zkConfig);
        zk.runFromConfig(serverConfig);
    }
}
Also used : DatadirCleanupManager(org.apache.zookeeper.server.DatadirCleanupManager) ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerMain(org.apache.zookeeper.server.quorum.QuorumPeerMain) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 28 with ServerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project xian by happyyangyuan.

the class TestingZooKeeperMain method runFromConfig.

@Override
public void runFromConfig(QuorumPeerConfig config) throws Exception {
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.readFrom(config);
    latch.countDown();
    try {
        super.runFromConfig(serverConfig);
    } catch (IOException e) {
        startingException.set(e);
        throw e;
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) IOException(java.io.IOException)

Aggregations

ServerConfig (org.apache.zookeeper.server.ServerConfig)27 IOException (java.io.IOException)15 File (java.io.File)13 QuorumPeerConfig (org.apache.zookeeper.server.quorum.QuorumPeerConfig)11 ZooKeeperServerMain (org.apache.zookeeper.server.ZooKeeperServerMain)10 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)8 Properties (java.util.Properties)7 ZooKeeperServer (org.apache.zookeeper.server.ZooKeeperServer)6 NIOServerCnxnFactory (org.apache.zookeeper.server.NIOServerCnxnFactory)5 InputStream (java.io.InputStream)3 ServerCnxnFactory (org.apache.zookeeper.server.ServerCnxnFactory)3 QuorumPeerMain (org.apache.zookeeper.server.quorum.QuorumPeerMain)3 UnknownHostException (java.net.UnknownHostException)2 DatadirCleanupManager (org.apache.zookeeper.server.DatadirCleanupManager)2 QuorumPeer (org.apache.zookeeper.server.quorum.QuorumPeer)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InetSocketAddress (java.net.InetSocketAddress)1 URL (java.net.URL)1 Date (java.util.Date)1