com.twitter.common.zookeeper.testing.ZooKeeperTestServer.startNetwork()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中com.twitter.common.zookeeper.testing.ZooKeeperTestServer.startNetwork()方法的一些代码示例,展示了ZooKeeperTestServer.startNetwork()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperTestServer.startNetwork()方法的具体详情如下:
包路径:com.twitter.common.zookeeper.testing.ZooKeeperTestServer
类名称:ZooKeeperTestServer
方法名:startNetwork

ZooKeeperTestServer.startNetwork介绍

[英]Starts zookeeper up on the configured port. If the configured port is the ephemeral port (@{code 0}), then the actual chosen port is returned.
[中]在配置的端口上启动zookeeper。如果配置的端口是临时端口(@{code 0}),则返回实际选择的端口。

代码示例

代码示例来源:origin: com.twitter.common/zookeeper-testing

/**
 * Starts zookeeper back up on the last used port.
 */
public final void restartNetwork() throws IOException, InterruptedException {
 checkEphemeralPortAssigned();
 Preconditions.checkState(!isStarted, "Must call shutdownNetwork() before restarting network");
 startNetwork();
}

代码示例来源:origin: com.twitter.common.zookeeper.guice/client

@Override
 public ZooKeeperClient get() {
  ZooKeeperTestServer zooKeeperServer;
  try {
   zooKeeperServer = new ZooKeeperTestServer(0, shutdownRegistry);
   zooKeeperServer.startNetwork();
  } catch (IOException e) {
   throw Throwables.propagate(e);
  } catch (InterruptedException e) {
   throw Throwables.propagate(e);
  }
  LOG.info("Embedded zookeeper cluster started on port " + zooKeeperServer.getPort());
  return zooKeeperServer.createClient(config.sessionTimeout, config.credentials);
 }
}

代码示例来源:origin: com.twitter.common/zookeeper-testing

@Before
public final void setUp() throws Exception {
 final ShutdownRegistryImpl shutdownRegistry = new ShutdownRegistryImpl();
 addTearDown(new TearDown() {
  @Override public void tearDown() {
   shutdownRegistry.execute();
  }
 });
 zkTestServer = new ZooKeeperTestServer(0, shutdownRegistry, defaultSessionTimeout);
 zkTestServer.startNetwork();
}

相关文章