当前位置: 首页>>代码示例>>Java>>正文


Java ZooKeeperServer.setMaxSessionTimeout方法代码示例

本文整理汇总了Java中org.apache.zookeeper.server.ZooKeeperServer.setMaxSessionTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperServer.setMaxSessionTimeout方法的具体用法?Java ZooKeeperServer.setMaxSessionTimeout怎么用?Java ZooKeeperServer.setMaxSessionTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.server.ZooKeeperServer的用法示例。


在下文中一共展示了ZooKeeperServer.setMaxSessionTimeout方法的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.setMaxSessionTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。