gpt4 book ai didi

io.pravega.segmentstore.storage.impl.bookkeeper.ZooKeeperServiceRunner类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 15:38:31 27 4
gpt4 key购买 nike

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

ZooKeeperServiceRunner介绍

[英]Helps run ZooKeeper Server in process.
[中]帮助运行ZooKeeper服务器。

代码示例

代码示例来源:origin: pravega/pravega

/**
 * Resumes ZooKeeper (if it had previously been suspended).
 *
 * @throws Exception If an exception got thrown.
 */
public void resumeZooKeeper() throws Exception {
  val zk = new ZooKeeperServiceRunner(this.zkPort, this.secureZK, this.tLSKeyStore, this.tLSKeyStorePasswordPath, this.tlsTrustStore);
  if (this.zkServer.compareAndSet(null, zk)) {
    // Initialize ZK runner (since nobody else did it for us).
    zk.initialize();
    log.info("ZooKeeper initialized.");
  } else {
    zk.close();
  }
  // Start or resume ZK.
  this.zkServer.get().start();
  log.info("ZooKeeper resumed.");
}

代码示例来源:origin: pravega/pravega

public static boolean waitForServerUp(int zkPort) {
  return waitForServerUp(zkPort, false, "", "", "", "");
}

代码示例来源:origin: pravega/pravega

@Override
public void close() throws Exception {
  stop();
  File t = this.tmpDir.getAndSet(null);
  if (t != null) {
    log.info("Cleaning up " + t);
    FileUtils.deleteDirectory(t);
  }
}

代码示例来源:origin: pravega/pravega

private void startLocalZK() throws Exception {
  zkService = new ZooKeeperServiceRunner(zkPort, secureZK, jksKeyFile, keyPasswordFile, jksTrustFile);
  zkService.initialize();
  zkService.start();
}

代码示例来源:origin: pravega/pravega

@Override
public void close() throws Exception {
  try {
    this.servers.stream().filter(Objects::nonNull).forEach(BookieServer::shutdown);
    if (this.zkServer.get() != null) {
      this.zkServer.get().close();
    }
  } finally {
    cleanupDirectories();
  }
  Thread c = this.cleanup.getAndSet(null);
  if (c != null) {
    Runtime.getRuntime().removeShutdownHook(c);
  }
}

代码示例来源:origin: pravega/pravega

try {
  SSLContext context = SSLContext.getInstance("TLS");
  TrustManagerFactory trustManager = getTrustManager(trustStore, trustStorePasswordPath);
  KeyManagerFactory keyFactory = getKeyManager(keyStore, keyStorePasswdPath);
  context.init(keyFactory.getKeyManagers(), trustManager.getTrustManagers(), null);

代码示例来源:origin: pravega/pravega

/**
 * Blocks the current thread and awaits ZooKeeper to start running locally on the given port.
 *
 * @param zkPort The ZooKeeper Port.
 * @param secureZk Flag to notify whether the ZK is secure.
 * @param trustStore Location of the trust store.
 * @param keyStore Location of the key store.
 * @param keyStorePasswordPath Location of password path for key store.
 *                             Empty string if `secureZk` is false or a password does not exist.
 * @param trustStorePasswordPath Location of password path for trust store.
 *                               Empty string if `secureZk` is false or a password does not exist.
 * @return True if ZooKeeper started within a specified timeout, false otherwise.
 */
public static boolean waitForServerUp(int zkPort, boolean secureZk, String trustStore, String keyStore,
                   String keyStorePasswordPath, String trustStorePasswordPath) {
  val address = LOOPBACK_ADDRESS + ":" + zkPort;
  if (secureZk) {
    return waitForSSLServerUp(address, LocalBookKeeper.CONNECTION_TIMEOUT, trustStore, keyStore,
        keyStorePasswordPath, trustStorePasswordPath);
  } else {
    return LocalBookKeeper.waitForServerUp(address, LocalBookKeeper.CONNECTION_TIMEOUT);
  }
}

代码示例来源:origin: pravega/pravega

ZooKeeperServiceRunner runner = new ZooKeeperServiceRunner(zkPort, secureZK,
    zkKeyStore, zkKeyStorePasswd, zkTrustStore);
runner.initialize();
runner.start();
Thread.sleep(Long.MAX_VALUE);

代码示例来源:origin: pravega/pravega

@Override
  @Synchronized
  public void close() throws Exception {
    if (isInProcSegmentStore) {
      for ( ServiceStarter starter : this.nodeServiceStarter ) {
        starter.shutdown();
      }
    }
    if (isInProcController) {
      for ( ControllerServiceMain controller : this.controllerServers ) {
          controller.stopAsync();
        }
    }

    if (this.zkService != null) {
      this.zkService.close();
      this.zkService = null;
    }
  }
}

代码示例来源:origin: pravega/pravega

/**
 * Starts the ZooKeeper Service in process.
 *
 * @throws Exception If an exception occurred.
 */
public void start() throws Exception {
  Preconditions.checkState(this.tmpDir.get() != null, "Not Initialized.");
  val s = new ZooKeeperServer(this.tmpDir.get(), this.tmpDir.get(), ZooKeeperServer.DEFAULT_TICK_TIME);
  if (!this.server.compareAndSet(null, s)) {
    s.shutdown();
    throw new IllegalStateException("Already started.");
  }
  this.serverFactory.set(NettyServerCnxnFactory.createFactory());
  val address = LOOPBACK_ADDRESS + ":" + this.zkPort;
  log.info("Starting Zookeeper server at " + address + " ...");
  this.serverFactory.get().configure(new InetSocketAddress(LOOPBACK_ADDRESS, this.zkPort), 1000, secureZK);
  this.serverFactory.get().startup(s);
  if (!waitForServerUp(this.zkPort, this.secureZK, this.trustStore, this.keyStore, this.keyStorePassword, this.keyStorePassword)) {
    throw new IllegalStateException("ZooKeeper server failed to start");
  }
}

代码示例来源:origin: pravega/pravega

/**
 * Suspends (stops) ZooKeeper, without destroying its underlying data (so a subsequent resume can pick up from the
 * state where it left off).
 */
public void suspendZooKeeper() {
  val zk = this.zkServer.get();
  Preconditions.checkState(zk != null, "ZooKeeper not started.");
  // Stop, but do not close, the ZK runner.
  zk.stop();
  log.info("ZooKeeper suspended.");
}

代码示例来源:origin: pravega/pravega

private void startZooKeeper() throws Exception {
  Preconditions.checkState(this.zooKeeperProcess.get() == null, "ZooKeeper is already started.");
  this.zooKeeperProcess.set(ProcessStarter
      .forClass(ZooKeeperServiceRunner.class)
      .sysProp(ZooKeeperServiceRunner.PROPERTY_ZK_PORT, this.testConfig.getZkPort())
      .stdOut(ProcessBuilder.Redirect.to(new File(this.testConfig.getComponentOutLogPath("zk", 0))))
      .stdErr(ProcessBuilder.Redirect.to(new File(this.testConfig.getComponentErrLogPath("zk", 0))))
      .start());
  if (!ZooKeeperServiceRunner.waitForServerUp(this.testConfig.getZkPort())) {
    throw new RuntimeException("Unable to start ZooKeeper at port " + this.testConfig.getZkPort());
  }
  log("ZooKeeper started (Port = %s).", this.testConfig.getZkPort());
}

代码示例来源:origin: pravega/pravega

/**
   * Starts a BookKeeper (using a number of bookies) along with a ZooKeeper out-of-process.
   *
   * @param config The Test Config to use. This indicates the BK Port(s), ZK Port, as well as Bookie counts.
   * @param logId  A String to use for logging purposes.
   * @return A Process referring to the newly started Bookie process.
   * @throws IOException If an error occurred.
   */
  static Process startBookKeeperOutOfProcess(TestConfig config, String logId) throws IOException {
    int bookieCount = config.getBookieCount();
    Process p = ProcessStarter
        .forClass(BookKeeperServiceRunner.class)
        .sysProp(BookKeeperServiceRunner.PROPERTY_BASE_PORT, config.getBkPort(0))
        .sysProp(BookKeeperServiceRunner.PROPERTY_BOOKIE_COUNT, bookieCount)
        .sysProp(BookKeeperServiceRunner.PROPERTY_ZK_PORT, config.getZkPort())
        .sysProp(BookKeeperServiceRunner.PROPERTY_LEDGERS_PATH, TestConfig.BK_LEDGER_PATH)
        .sysProp(BookKeeperServiceRunner.PROPERTY_START_ZK, true)
        .stdOut(ProcessBuilder.Redirect.to(new File(config.getComponentOutLogPath("bk", 0))))
        .stdErr(ProcessBuilder.Redirect.to(new File(config.getComponentErrLogPath("bk", 0))))
        .start();
    ZooKeeperServiceRunner.waitForServerUp(config.getZkPort());
    TestLogger.log(logId, "Zookeeper (Port %s) and BookKeeper (Ports %s-%s) started.",
        config.getZkPort(), config.getBkPort(0), config.getBkPort(bookieCount - 1));
    return p;
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com