gpt4 book ai didi

org.apache.zookeeper.server.ZooKeeperServer.isRunning()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 05:08:40 25 4
gpt4 key购买 nike

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

ZooKeeperServer.isRunning介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

/**
 * @return true if the server is running, false otherwise.
 */
boolean isZKServerRunning() {
  return zkServer != null && zkServer.isRunning();
}

代码示例来源:origin: apache/zookeeper

/**
 * @return true if the server is running, false otherwise.
 */
boolean isZKServerRunning() {
  return zkServer != null && zkServer.isRunning();
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

/**
   * @return true if the server is running, false otherwise.
   */
  boolean isZKServerRunning() {
    return zkServer != null && zkServer.isRunning();
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

/**
   * @return true if the server is running, false otherwise.
   */
  boolean isZKServerRunning() {
    return zkServer != null && zkServer.isRunning();
  }
}

代码示例来源:origin: apache/zookeeper

/**
 * Run the registered command with name cmdName. Commands should not produce
 * any exceptions; any (anticipated) errors should be reported in the
 * "error" entry of the returned map. Likewise, if no command with the given
 * name is registered, this will be noted in the "error" entry.
 *
 * @param cmdName
 * @param zkServer
 * @param kwargs String-valued keyword arguments to the command
 *        (may be null if command requires no additional arguments)
 * @return Map representing response to command containing at minimum:
 *    - "command" key containing the command's primary name
 *    - "error" key containing a String error message or null if no error
 */
public static CommandResponse runCommand(String cmdName, ZooKeeperServer zkServer, Map<String, String> kwargs) {
  if (!commands.containsKey(cmdName)) {
    return new CommandResponse(cmdName, "Unknown command: " + cmdName);
  }
  if (zkServer == null || !zkServer.isRunning()) {
    return new CommandResponse(cmdName, "This ZooKeeper instance is not currently serving requests");
  }
  return commands.get(cmdName).run(zkServer, kwargs);
}

代码示例来源:origin: apache/zookeeper

if (zks == null || !zks.isRunning()) {
  throw new IOException("ZK down");

代码示例来源:origin: apache/zookeeper

@Before
public void setUp() {
  outputWriter = new StringWriter();
  ServerCnxn serverCnxnMock = mock(ServerCnxn.class);
  zks = mock(ZooKeeperServer.class);
  when(zks.isRunning()).thenReturn(true);
  serverStats = mock(ServerStats.class);
  when(zks.serverStats()).thenReturn(serverStats);
  statResetCommand = new StatResetCommand(new PrintWriter(outputWriter), serverCnxnMock);
  statResetCommand.setZkServer(zks);
}

代码示例来源:origin: apache/zookeeper

@Test
public void testStatResetWithZKNotRunning() {
  // Arrange
  when(zks.isRunning()).thenReturn(false);
  // Act
  statResetCommand.commandRun();
  // Assert
  String output = outputWriter.toString();
  assertEquals(ZK_NOT_SERVING + "\n", output);
}

代码示例来源:origin: apache/zookeeper

@Test
public void testStatResetWithFollower() {
  // Arrange
  when(zks.isRunning()).thenReturn(true);
  when(serverStats.getServerState()).thenReturn("follower");
  // Act
  statResetCommand.commandRun();
  // Assert
  String output = outputWriter.toString();
  assertEquals("Server stats reset.\n", output);
  verify(serverStats, times(1)).reset();
}

代码示例来源:origin: prestodb/presto

@Override
public void close()
    throws IOException
{
  if (started.get() && !stopped.getAndSet(true)) {
    cnxnFactory.shutdown();
    try {
      cnxnFactory.join();
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
    if (zkServer.isRunning()) {
      zkServer.shutdown();
    }
    deleteRecursively(zkDataDir.toPath(), ALLOW_INSECURE);
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

if (zks == null || !zks.isRunning()) {
  throw new IOException("ZK down");

代码示例来源:origin: apache/nifi

@Override
public synchronized void shutdown() {
  if (started) {
    started = false;
    if (transactionLog != null) {
      try {
        transactionLog.close();
      } catch (final IOException ioe) {
        logger.warn("Failed to close Transaction Log", ioe);
      }
    }
    if (connectionFactory != null) {
      connectionFactory.shutdown();
    }
    if (quorumPeer != null && quorumPeer.isRunning()) {
      quorumPeer.shutdown();
    }
    if (embeddedZkServer != null && embeddedZkServer.isRunning()) {
      embeddedZkServer.shutdown();
    }
    if (datadirCleanupManager != null) {
      datadirCleanupManager.shutdown();
    }
  }
}

代码示例来源:origin: org.apache.giraph/giraph-core

@Override
 public void run() {
  try {
   cnxnFactory.join();
   if (zkServer.isRunning()) {
    zkServer.shutdown();
   }
  } catch (InterruptedException e) {
   LOG.error(e.getMessage(), e);
  }
 }
});

代码示例来源:origin: com.intropro.prairie/zookeeper-unit

public void run() {
    try {
      cnxnFactory.join();
      if (zkServer.isRunning()) {
        zkServer.shutdown();
      }
    } catch (InterruptedException e) {
      if (zkServer.isRunning()) {
        zkServer.shutdown();
      }
    }
  }
};

代码示例来源:origin: com.intropro.prairie/zookeeper-unit

@Override
protected void destroy() throws DestroyUnitException {
  thread.interrupt();
  if (zkServer.isRunning()) {
    zkServer.shutdown();
  }
  cnxnFactory.shutdown();
  try {
    txnLog.close();
  } catch (IOException e) {
    throw new DestroyUnitException(e);
  }
}

代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common

public void shutdown() throws Exception {
  try {
    connectionFactory.shutdown();
    connectionFactory.join();
    zkServer.shutdown();
    while (zkServer.isRunning()) {
      zkServer.shutdown();
      Thread.sleep(100);
    }
  } finally {
    try {
      cleanZookeeperDir();
    } catch (Exception e) {
      LOG.warn("Error cleaning up ZK data directory {}", e);
    }
  }
}

代码示例来源:origin: wildfly-extras/wildfly-camel

public void shutdown() throws Exception {
  try {
    connectionFactory.shutdown();
    connectionFactory.join();
    zkServer.shutdown();
    while (zkServer.isRunning()) {
      zkServer.shutdown();
      Thread.sleep(100);
    }
  } finally {
    try {
      cleanZookeeperDir();
    } catch (Exception e) {
      LOG.warn("Error cleaning up ZK data directory {}", e);
    }
  }
}

代码示例来源:origin: apache/tajo

@Override
public void close() {
 if (started.get()) {
  cnxnFactory.shutdown();
  try {
   cnxnFactory.join();
  } catch (InterruptedException e) {
   Thread.currentThread().interrupt();
  }
  if (zkServer.isRunning()) {
   zkServer.shutdown();
  }
  deleteRecursively(zkDataDir);
 }
}

代码示例来源:origin: prestosql/presto

@Override
public void close()
    throws IOException
{
  if (started.get() && !stopped.getAndSet(true)) {
    cnxnFactory.shutdown();
    try {
      cnxnFactory.join();
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
    if (zkServer.isRunning()) {
      zkServer.shutdown();
    }
    deleteRecursively(zkDataDir.toPath(), ALLOW_INSECURE);
  }
}

代码示例来源:origin: com.intropro.prairie/zookeeper-unit

private void runFromConfig(ServerConfig config) throws IOException {
  zkServer = new ZooKeeperServer();
  try {
    txnLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
    zkServer.setTxnLogFactory(txnLog);
    zkServer.setTickTime(config.getTickTime());
    zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
    cnxnFactory = ServerCnxnFactory.createFactory();
    cnxnFactory.configure(config.getClientPortAddress(),
        config.getMaxClientCnxns());
    cnxnFactory.startup(zkServer);
  } catch (InterruptedException e) {
    if (zkServer.isRunning()) {
      zkServer.shutdown();
    }
  }
}

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