/** * 启动单机模式 * @param zkPropertiesPath * @throws IOException * @throws InterruptedException * @throws ConfigException */ public void startStandalone(String zkPropertiesPath) throws IOException, ConfigException, AdminServer.AdminServerException { ServerConfig config = new ServerConfig(); config.parse(zkPropertiesPath); startStandalone(config); }
/** * 通过官方的ZooKeeperServerMain启动类启动单机模式 * @param config * @throws IOException * @throws AdminServer.AdminServerException */ public void startStandalone(ServerConfig config) throws IOException, AdminServer.AdminServerException { ZooKeeperServerMain main = new ZooKeeperServerMain(); main.runFromConfig(config); }
/** * 通过官方的QuorumPeerMain启动类启动真集群模式 * 会执行quorumPeer.join(); * 需要在不同的服务器上执行 * @param config * @throws IOException * @throws AdminServer.AdminServerException */ public void startCluster(QuorumPeerConfig config) throws IOException, AdminServer.AdminServerException { QuorumPeerMain main = new QuorumPeerMain(); main.runFromConfig(config); }