org.apache.zookeeper.server.ServerConfig#getTickTime ( )源码实例Demo

下面列出了org.apache.zookeeper.server.ServerConfig#getTickTime ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lucene-solr   文件: ZkTestServer.java
/**
 * Run from a ServerConfig.
 * @param config ServerConfig to use.
 * @throws IOException If there is a low-level I/O error.
 */
public void runFromConfig(ServerConfig config) throws IOException {
  ObjectReleaseTracker.track(this);
  log.info("Starting server");
  try {
    // ZooKeeper maintains a static collection of AuthenticationProviders, so
    // we make sure the SASL provider is loaded so that it can be used in
    // subsequent tests.
    System.setProperty("zookeeper.authProvider.1",
      "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
    // 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
    FileTxnSnapLog ftxn = new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir());

    zooKeeperServer = new ZooKeeperServer(ftxn, config.getTickTime(),
        config.getMinSessionTimeout(), config.getMaxSessionTimeout(),
        new TestZKDatabase(ftxn, limiter));
    cnxnFactory = new TestServerCnxnFactory(limiter);
    cnxnFactory.configure(config.getClientPortAddress(),
        config.getMaxClientCnxns());
    cnxnFactory.startup(zooKeeperServer);
    cnxnFactory.join();

    if (violationReportAction != LimitViolationAction.IGNORE) {
      String limitViolations = limiter.reportLimitViolations();
      if (!limitViolations.isEmpty()) {
        log.warn("Watch limit violations: {}", limitViolations);
        if (violationReportAction == LimitViolationAction.FAIL) {
          throw new AssertionError("Parallel watch limits violated");
        }
      }
    }
  } catch (InterruptedException e) {
    // warn, but generally this is ok
    log.warn("Server interrupted", e);
  }
}
 
源代码2 项目: incubator-pinot   文件: ZkStarter.java
@Override
public void runFromConfig(final ServerConfig config)
    throws IOException {
  ServerConfig newServerConfig = new ServerConfig() {

    public void parse(String[] args) {
      config.parse(args);
    }

    public void parse(String path)
        throws QuorumPeerConfig.ConfigException {
      config.parse(path);
    }

    public void readFrom(QuorumPeerConfig otherConfig) {
      config.readFrom(otherConfig);
    }

    public InetSocketAddress getClientPortAddress() {
      return config.getClientPortAddress();
    }

    public String getDataDir() {
      return config.getDataDir();
    }

    public String getDataLogDir() {
      return config.getDataLogDir();
    }

    public int getTickTime() {
      return config.getTickTime();
    }

    public int getMaxClientCnxns() {
      dataDir = getDataDir();
      dataLogDir = getDataLogDir();
      tickTime = getTickTime();
      minSessionTimeout = getMinSessionTimeout();
      maxSessionTimeout = getMaxSessionTimeout();
      maxClientCnxns = 0;
      return 0;
    }

    public int getMinSessionTimeout() {
      return config.getMinSessionTimeout();
    }

    public int getMaxSessionTimeout() {
      return config.getMaxSessionTimeout();
    }
  };

  newServerConfig.getMaxClientCnxns();

  super.runFromConfig(newServerConfig);
}