Package org.apache.zookeeper.server

Examples of org.apache.zookeeper.server.ServerConfig


        LOGGER.info("Created zookeeper peer configuration: {}", peerConfig);
        return peerConfig;
    }

    private static ServerConfig getServerConfig(QuorumPeerConfig peerConfig) {
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.readFrom(peerConfig);
        LOGGER.info("Created zookeeper server configuration: {}", serverConfig);
        return serverConfig;
    }
View Full Code Here


    private static class SimpleServer {
        private ZooKeeperServer zkServer;
        private NIOServerCnxnFactory cnxnFactory;

        void start(QuorumPeerConfig peerConfig) throws Exception {
            ServerConfig serverConfig = getServerConfig(peerConfig);

            zkServer = new ZooKeeperServer();
            zkServer.setTxnLogFactory(new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir())));
            zkServer.setTickTime(serverConfig.getTickTime());
            zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
            zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

            cnxnFactory = new NIOServerCnxnFactory() {
                protected void configureSaslLogin() throws IOException {
                }
            };
            cnxnFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());

            try {
                LOGGER.debug("Starting ZooKeeper server on address %s", peerConfig.getClientPortAddress());
                cnxnFactory.startup(zkServer);
                LOGGER.debug("Started ZooKeeper server");
View Full Code Here

                                  quorumConfig.getDataLogDir(),
                                  quorumConfig.getSnapRetainCount(),
                                  quorumConfig.getPurgeInterval());
    purgeManager.start();

    ServerConfig serverConfig = new ServerConfig();
    serverConfig.readFrom(quorumConfig);

    zkServer = new ZooKeeperServer();
    zkServer.setTickTime(serverConfig.getTickTime());
    zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

    transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()),
                                        new File(serverConfig.getDataDir()));
    zkServer.setTxnLogFactory(transactionLog);

    connectionFactory = ServerCnxnFactory.createFactory();
    connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
    connectionFactory.startup(zkServer);
  }
View Full Code Here

   * @throws ConfigException
   */
  public static final ZooKeeperServerRunnable newInstance(
      String zkConfigFile, boolean addShutdownHook)
      throws ConfigException {
    final ServerConfig zkServerConfig = new ServerConfig();
    zkServerConfig.parse(zkConfigFile);
    return newInstance(zkServerConfig, addShutdownHook);
  }
View Full Code Here

    zkConfProps.setProperty("clientPort", new Integer(zkClientPort).toString());
    zkConfProps.setProperty("maxClientCnxns", "500");
    zkConfProps.store(new FileOutputStream(zkConfFile), "");

    // create config object
    ServerConfig zkConf = new ServerConfig();
    zkConf.parse(ZK_CONF_FILE);

    return zkConf;
  }
View Full Code Here

    return zkConf;
  }

  private static ServerConfig getZooKeeperConf() throws Exception {
    if (new File(ZK_CONF_FILE).exists()) {
      ServerConfig zkConf = new ServerConfig();
      zkConf.parse(ZK_CONF_FILE);

      return zkConf;
    } else {
      return createZooKeeperConf();
    }
View Full Code Here

      return createZooKeeperConf();
    }
  }

  public static boolean clearZooKeeperData() throws Exception {
    ServerConfig zkConf = getZooKeeperConf();
    File dataLogDir = new File(zkConf.getDataLogDir());
    File dataDir = new File(zkConf.getDataDir());
    return (FileUtil.fullyDelete(dataLogDir) && FileUtil.fullyDelete(dataDir));
  }
View Full Code Here

   
  public static void createAndStartZooKeeper()
    throws IOException, ConfigException, InterruptedException {
    logStateChange("Creating zookeeper server");
    AvatarShell.retrySleep = 1000;
    ServerConfig zkConf = createZooKeeperConf();

    zooKeeper = new ZooKeeperServer();
    FileTxnSnapLog ftxn = new
      FileTxnSnapLog(new File(zkConf.getDataLogDir()),
                     new File(zkConf.getDataDir()));
    zooKeeper.setTxnLogFactory(ftxn);
    zooKeeper.setTickTime(zkConf.getTickTime());
    zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
    zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());

    cnxnFactory = new NIOServerCnxnFactory();
    cnxnFactory.configure(zkConf.getClientPortAddress(),
        zkConf.getMaxClientCnxns());
    cnxnFactory.startup(zooKeeper);
    logStateChange("Creating zookeeper server - completed");
  }
View Full Code Here

    try {
      final QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
      quorumPeerConfig.parse(conf.getConfFile());
      QuorumPeer.Factory qpFactory = new QuorumPeer.Factory() {
        public QuorumPeer create(NIOServerCnxn.Factory cnxnFactory) throws IOException {
          ServerConfig serverConfig = new ServerConfig();
          serverConfig.readFrom(quorumPeerConfig);
          QuorumPeer peer = new QuorumPeer(quorumPeerConfig.getServers(), new File(serverConfig.getDataDir()), new File(
              serverConfig.getDataLogDir()), quorumPeerConfig.getElectionAlg(), quorumPeerConfig.getServerId(),
              quorumPeerConfig.getTickTime(), quorumPeerConfig.getInitLimit(), quorumPeerConfig.getSyncLimit(), cnxnFactory,
              quorumPeerConfig.getQuorumVerifier());
          ZooDiscoveryContainer.this.quorumPeer = peer;
          return peer;
        }
View Full Code Here

  /**
   * If block is set, wait until the server comes up
   */
  protected void createInstanceFromConfig(boolean block) throws IOException,
      InterruptedException {
    final ServerConfig serverConfig = new ServerConfig();
    if (standalone) {
      zkServerMain = new FlumeZKServerMain();
    } else {
      quorumPeer = new FlumeZKQuorumPeerMain();
    }
    new Thread() {
      public void run() {
        if (standalone) {
          this.setName("ZooKeeper standalone thread");

          LOG.info("Starting ZooKeeper server");
          serverConfig.readFrom(config);
          try {
            zkServerMain.runFromConfig(serverConfig);
          } catch (IOException e) {
            LOG.error("Couldn't start ZooKeeper server!", e);
          }
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.ServerConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.