/**
   * Run from a ServerConfig.
   *
   * @param config ServerConfig to use.
   * @throws IOException
   */
  public void runFromConfig(ServerConfig config) throws IOException {
    LOG.info("Starting server");
    try {
      // Note that this thread isn't going to be doing anything else,
      // so rather than spawning another thread, we will just call
      // run() in this thread.
      // create a file logger url from the command line args
      ZooKeeperServer zkServer = new ZooKeeperServer();

      FileTxnSnapLog ftxn =
          new FileTxnSnapLog(new File(config.dataLogDir), new File(config.dataDir));
      zkServer.setTxnLogFactory(ftxn);
      zkServer.setTickTime(config.tickTime);
      zkServer.setMinSessionTimeout(config.minSessionTimeout);
      zkServer.setMaxSessionTimeout(config.maxSessionTimeout);
      cnxnFactory =
          new NIOServerCnxn.Factory(config.getClientPortAddress(), config.getMaxClientCnxns());
      cnxnFactory.startup(zkServer);
      cnxnFactory.join();
      if (zkServer.isRunning()) {
        zkServer.shutdown();
      }
    } catch (InterruptedException e) {
      // warn, but generally this is ok
      LOG.warn("Server interrupted", e);
    }
  }
 /** Shutdown the serving instance */
 protected void shutdown() {
   cnxnFactory.shutdown();
 }