Search in sources :

Example 11 with ServerConfig

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

the class EnforceAuthenticationTest method testServerCannotStart.

private void testServerCannotStart(Map<String, String> prop) throws Exception {
    File confFile = getConfFile(prop);
    ServerConfig config = new ServerConfig();
    config.parse(confFile.toString());
    ZooKeeperServerMain serverMain = new ZooKeeperServerMain();
    try {
        serverMain.runFromConfig(config);
        fail("IllegalArgumentException is expected.");
    } catch (IllegalArgumentException e) {
    // do nothing
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) File(java.io.File) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 12 with ServerConfig

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

the class GroupTest method startZooKeeper.

private NIOServerCnxnFactory startZooKeeper(int port) throws Exception {
    ServerConfig cfg = new ServerConfig();
    cfg.parse(new String[] { Integer.toString(port), "target/zk/data" });
    ZooKeeperServer zkServer = new ZooKeeperServer();
    FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(cfg.getDataLogDir()), new File(cfg.getDataDir()));
    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(cfg.getTickTime());
    zkServer.setMinSessionTimeout(6000);
    zkServer.setMaxSessionTimeout(9000);
    NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
    cnxnFactory.configure(cfg.getClientPortAddress(), cfg.getMaxClientCnxns());
    cnxnFactory.startup(zkServer);
    return cnxnFactory;
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) NIOServerCnxnFactory(org.apache.zookeeper.server.NIOServerCnxnFactory) File(java.io.File) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog)

Example 13 with ServerConfig

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

the class ZooKeeperStateServer method startStandalone.

private void startStandalone() throws IOException {
    logger.info("Starting Embedded ZooKeeper Server");
    final ServerConfig config = new ServerConfig();
    config.readFrom(quorumPeerConfig);
    try {
        transactionLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
        embeddedZkServer = new ZooKeeperServer();
        embeddedZkServer.setTxnLogFactory(transactionLog);
        embeddedZkServer.setTickTime(config.getTickTime());
        embeddedZkServer.setMinSessionTimeout(config.getMinSessionTimeout());
        embeddedZkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
        connectionFactory = ServerCnxnFactory.createFactory();
        connectionFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns());
        connectionFactory.startup(embeddedZkServer);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        logger.warn("Embedded ZooKeeper Server interrupted", e);
    } catch (final IOException ioe) {
        throw new IOException("Failed to start embedded ZooKeeper Server", ioe);
    } catch (final Exception e) {
        throw new RuntimeException("Failed to start embedded ZooKeeper Server", e);
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) IOException(java.io.IOException) File(java.io.File) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) ConfigException(org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException) IOException(java.io.IOException)

Example 14 with ServerConfig

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

the class EmbeddedKafka method startZookeeper.

/**
 * Will start Zookeeper server via {@link ServerCnxnFactory}
 */
private void startZookeeper() {
    QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
    try {
        quorumConfiguration.parseProperties(this.zookeeperConfig);
        ServerConfig configuration = new ServerConfig();
        configuration.readFrom(quorumConfiguration);
        FileTxnSnapLog txnLog = new FileTxnSnapLog(new File(configuration.getDataLogDir()), new File(configuration.getDataDir()));
        zkServer.setTxnLogFactory(txnLog);
        zkServer.setTickTime(configuration.getTickTime());
        zkServer.setMinSessionTimeout(configuration.getMinSessionTimeout());
        zkServer.setMaxSessionTimeout(configuration.getMaxSessionTimeout());
        ServerCnxnFactory zookeeperConnectionFactory = ServerCnxnFactory.createFactory();
        zookeeperConnectionFactory.configure(configuration.getClientPortAddress(), configuration.getMaxClientCnxns());
        zookeeperConnectionFactory.startup(zkServer);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start Zookeeper server", e);
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) ServerCnxnFactory(org.apache.zookeeper.server.ServerCnxnFactory) File(java.io.File) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog) IOException(java.io.IOException)

Example 15 with ServerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project fabric8 by jboss-fuse.

the class ZookeeperServerTestSupport method startZooKeeper.

protected NIOServerCnxnFactory startZooKeeper(int port) throws Exception {
    ServerConfig cfg = new ServerConfig();
    cfg.parse(new String[] { Integer.toString(port), "target/zk/data-" + String.format("%15d", new Date().getTime()) });
    ZooKeeperServer zkServer = new ZooKeeperServer();
    FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(cfg.getDataLogDir()), new File(cfg.getDataDir()));
    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(cfg.getTickTime());
    zkServer.setMinSessionTimeout(cfg.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(cfg.getMaxSessionTimeout());
    NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
    cnxnFactory.configure(cfg.getClientPortAddress(), cfg.getMaxClientCnxns());
    cnxnFactory.startup(zkServer);
    return cnxnFactory;
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) NIOServerCnxnFactory(org.apache.zookeeper.server.NIOServerCnxnFactory) File(java.io.File) Date(java.util.Date) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog)

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