當前位置: 首頁>>代碼示例>>Java>>正文


Java ZooKeeperServer.setMinSessionTimeout方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.server.ZooKeeperServer.setMinSessionTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java ZooKeeperServer.setMinSessionTimeout方法的具體用法?Java ZooKeeperServer.setMinSessionTimeout怎麽用?Java ZooKeeperServer.setMinSessionTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.server.ZooKeeperServer的用法示例。


在下文中一共展示了ZooKeeperServer.setMinSessionTimeout方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMinMaxSessionTimeout

import org.apache.zookeeper.server.ZooKeeperServer; //導入方法依賴的package包/類
@Test
public void testMinMaxSessionTimeout() throws Exception {
    // override the defaults
    final int MINSESS = 20000;
    final int MAXSESS = 240000;
    {
        ZooKeeperServer zs = ClientBase.getServer(serverFactory);
        zs.setMinSessionTimeout(MINSESS);
        zs.setMaxSessionTimeout(MAXSESS);
    }

    // validate typical case - requested == negotiated
    int timeout = 120000;
    DisconnectableZooKeeper zk = createClient(timeout);
    Assert.assertEquals(timeout, zk.getSessionTimeout());
    // make sure tostring works in both cases
    LOG.info(zk.toString());
    zk.close();
    LOG.info(zk.toString());

    // validate lower limit
    zk = createClient(MINSESS/2);
    Assert.assertEquals(MINSESS, zk.getSessionTimeout());
    LOG.info(zk.toString());
    zk.close();
    LOG.info(zk.toString());

    // validate upper limit
    zk = createClient(MAXSESS * 2);
    Assert.assertEquals(MAXSESS, zk.getSessionTimeout());
    LOG.info(zk.toString());
    zk.close();
    LOG.info(zk.toString());
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:35,代碼來源:SessionTest.java

示例2: start

import org.apache.zookeeper.server.ZooKeeperServer; //導入方法依賴的package包/類
/**
 * Starts Zookeeper.
 *
 * @throws IOException if an error occurs during initialization
 * @throws InterruptedException if an error occurs during initialization
 */
public synchronized void start() throws IOException, InterruptedException {
  log.info("Starting Zookeeper on port {}", port);

  dataDir = Files.createTempDirectory(LocalZKServer.class.getSimpleName());
  dataDir.toFile().deleteOnExit();

  QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
  try {
    quorumConfig.parseProperties(ConfigUtils.keyValueToProperties(
        "dataDir", dataDir.toAbsolutePath(),
        "clientPort", port
    ));
  } catch (QuorumPeerConfig.ConfigException e) {
    throw new IllegalArgumentException(e);
  }

  purgeManager =
      new DatadirCleanupManager(quorumConfig.getDataDir(),
                                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());

  // These two ServerConfig methods returned String in 3.4.x and File in 3.5.x
  transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
                                      new File(serverConfig.getDataDir().toString()));
  zkServer.setTxnLogFactory(transactionLog);

  connectionFactory = ServerCnxnFactory.createFactory();
  connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
  connectionFactory.startup(zkServer);
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:47,代碼來源:LocalZKServer.java


注:本文中的org.apache.zookeeper.server.ZooKeeperServer.setMinSessionTimeout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。